- 
                Notifications
    You must be signed in to change notification settings 
- Fork 31
Open
Description
the code sample - provided by me in fa985ed - doesnt work :/.
I tried a lot of different ways but wasnt able to find one which works using the xml-extension.
As a workaround I localy work with a DOMDocument based approach:
    static private function validateXml($xmlString, $schema) {
        $libxml_display_error = function ($error)
        {
            $return = "";
            switch ($error->level) {
                case LIBXML_ERR_WARNING:
                    $return .= "Warning $error->code: ";
                    break;
                case LIBXML_ERR_ERROR:
                    $return .= "Error $error->code: ";
                    break;
                case LIBXML_ERR_FATAL:
                    $return .= "Fatal Error $error->code: ";
                    break;
            }
            $return .= trim($error->message);
            if ($error->file) {
                $return .=    " in $error->file";
            }
            $return .= " on line $error->line";
            return $return;
        };
        libxml_use_internal_errors(TRUE);
        $xml = new \DOMDocument();
        $xml->loadXml($xmlString);
        if (!$xml->schemaValidate($schema)) {
            echo '> DOMDocument::schemaValidate() Generated Errors!'."\n";
            echo 'Schema:'. $schema;
            var_dump($xmlString);
            $errors = libxml_get_errors();
            foreach ($errors as $error) {
                debug($libxml_display_error($error));
            }
            exit();
        }
    }just to let you know...
Metadata
Metadata
Assignees
Labels
No labels