From 5f8ef30572936e51d48dd91249dc8b270f8e3d78 Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Fri, 20 Jun 2008 10:38:16 +0000
Subject: [PATCH] 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
---
 lib/SimpleSAML/Utilities.php | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index f19f05550..9155f0eca 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -751,19 +751,25 @@ class SimpleSAML_Utilities {
 	 *
 	 * 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.
 	 * @return Returns a string with the errors if validation fails. An empty string is
 	 *         returned if validation passes.
 	 */
-	public static function validateXML($message, $schema) {
-		assert('is_string($message)');
+	public static function validateXML($xml, $schema) {
+		assert('is_string($xml) || $xml instanceof DOMDocument');
 		assert('is_string($schema)');
 
 		SimpleSAML_XML_Errors::begin();
 
-		$dom = new DOMDocument;
-		$res = $dom->loadXML($message);
+		if($xml instanceof DOMDocument) {
+			$dom = $xml;
+			$res = TRUE;
+		} else {
+			$dom = new DOMDocument;
+			$res = $dom->loadXML($xml);
+		}
+
 		if($res) {
 
 			$config = SimpleSAML_Configuration::getInstance();
-- 
GitLab