From f683b74e1be33a32d3a045262b362b2209af1dcf Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Fri, 20 Jun 2008 10:37:53 +0000 Subject: [PATCH] Utilities: Updated validateXML to use the new SimpleSAML_XML_Errors class. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@678 44740490-163a-0410-bde0-09ae8108e29a --- lib/SimpleSAML/Utilities.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php index d31343435..f19f05550 100644 --- a/lib/SimpleSAML/Utilities.php +++ b/lib/SimpleSAML/Utilities.php @@ -760,8 +760,7 @@ class SimpleSAML_Utilities { assert('is_string($message)'); assert('is_string($schema)'); - $xmlErrorState = libxml_use_internal_errors(TRUE); - libxml_clear_errors(); + SimpleSAML_XML_Errors::begin(); $dom = new DOMDocument; $res = $dom->loadXML($message); @@ -773,20 +772,17 @@ class SimpleSAML_Utilities { $res = $dom->schemaValidate($schemaFile); if($res) { - libxml_use_internal_errors($xmlErrorState); + SimpleSAML_XML_Errors::end(); return ''; } - $errorText = 'Schema validation failed on XML string:'; + $errorText = "Schema validation failed on XML string:\n"; } else { - $errorText = 'Failed to parse XML string for schema validation:'; + $errorText = "Failed to parse XML string for schema validation:\n"; } - $errors = libxml_get_errors(); - foreach($errors as $error) { - $errorText .= ' [' . $error->level . ':' . $error->code . '@' - . $error->line . ',' . $error->column . ' ' . trim($error->message) . ']'; - } + $errors = SimpleSAML_XML_Errors::end(); + $errorText .= SimpleSAML_XML_Errors::formatErrors($errors); return $errorText; } -- GitLab