Skip to content
Snippets Groups Projects
Commit 5f8ef305 authored by Olav Morken's avatar Olav Morken
Browse files

Utilities: updated validateXML to accept a DOMDocument in addition to an XML-string.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@680 44740490-163a-0410-bde0-09ae8108e29a
parent e5895fae
No related branches found
No related tags found
No related merge requests found
...@@ -751,19 +751,25 @@ class SimpleSAML_Utilities { ...@@ -751,19 +751,25 @@ class SimpleSAML_Utilities {
* *
* It will parse the string into a DOM document and validate this document against the schema. * It will parse the string into a DOM document and validate this document against the schema.
* *
* @param $xml The XML string which should be validated. * @param $xml The XML string or document which should be validated.
* @param $schema The schema which should be used. * @param $schema The schema which should be used.
* @return Returns a string with the errors if validation fails. An empty string is * @return Returns a string with the errors if validation fails. An empty string is
* returned if validation passes. * returned if validation passes.
*/ */
public static function validateXML($message, $schema) { public static function validateXML($xml, $schema) {
assert('is_string($message)'); assert('is_string($xml) || $xml instanceof DOMDocument');
assert('is_string($schema)'); assert('is_string($schema)');
SimpleSAML_XML_Errors::begin(); SimpleSAML_XML_Errors::begin();
$dom = new DOMDocument; if($xml instanceof DOMDocument) {
$res = $dom->loadXML($message); $dom = $xml;
$res = TRUE;
} else {
$dom = new DOMDocument;
$res = $dom->loadXML($xml);
}
if($res) { if($res) {
$config = SimpleSAML_Configuration::getInstance(); $config = SimpleSAML_Configuration::getInstance();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment