Re: Bug in DOMDocument schemaValidate() function?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 14, 2012 at 1:39 PM, Voß, Marko <Marko.Voss@xxxxxxxxxxxxxxxx> wrote:
> Hello,
>
> I am validating user DOM against schema files using the following piece of code:
>
> $valid = @$doc->schemaValidate($xsdFile);
>
> where $doc is of type DOMDocument and $xsdFile is the file location of the XSD file.
>
> Everything worked fine until the following validation occured:
>
> A validation of a XML against the SRW/U schema (http://www.loc.gov/standards/sru/sru1-1archive/xml-files/srw-types.xsd)
> failed.
>
> Here is the XML:
>
> -----------------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <srw:explainResponse xmlns:srw="http://www.loc.gov/zing/srw/"; xmlns:zr="http://explain.z3950.org/dtd/2.0/";>
>   <srw:version>1.1</srw:version>
>   <srw:record>
>     <srw:recordSchema>http://explain.z3950.org/dtd/2.0/</srw:recordSchema>
>     <srw:recordPacking>XML</srw:recordPacking>
>     <srw:recordData>
>       <zr:explain>
>         <zr:serverInfo wsdl="http://myserver.com/db"; protocol="SRU" version="1.1">
>           <host>myserver.com</host>
>           <port>80</port>
>           <database>sru</database>
>         </zr:serverInfo>
>         <zr:databaseInfo>
>           <title lang="en" primary="true">SRU Test Database</title>
>           <description lang="en" primary="true"> My server SRU Test Database</description>
>         </zr:databaseInfo>
>         <zr:metaInfo>
>           <dateModified>27-11-2003</dateModified>
>         </zr:metaInfo>
>       </zr:explain>
>     </srw:recordData>
>   </srw:record>
> </srw:explainResponse>
> -----------------------------------------------------
>
> This XML is valid. However, I keep getting the following libxml error:
>
> object(LibXMLError)#192 (6) {
>     ["level"]=>
>     int(2)
>     ["code"]=>
>     int(1871)
>     ["column"]=>
>     int(0)
>     ["message"]=>
>     string(133) "Element '{http://www.loc.gov/zing/srw/}record': This element is not expected. Expected is (
> {http://www.loc.gov/zing/srw/}version ).
> "
>     ["file"]=>
>     string(0) ""
>     ["line"]=>
>     int(0)
> }
>
> I think, the validator is unable to handle the xsd:extension part of the schema:
>
> <xsd:complexType name="explainResponseType">
>   <xsd:complexContent>
>     <xsd:extension base="responseType">
>       <xsd:sequence><xsd:element ref="record"/>
>         <xsd:element ref="echoedExplainRequest" minOccurs="0"/>
>         <xsd:element ref="diagnostics" minOccurs="0"/>
>         <xsd:element ref="extraResponseData" minOccurs="0"/>
>       </xsd:sequence>
>     </xsd:extension>
>   </xsd:complexContent>
> </xsd:complexType>
>
> The version-element exists and is at the right place. If I add another version-element after the first one, it complains
> about expecting a record-element instead, which is correct. But it is not correct to expect another version-element
> after the already existing one.
>
> Is this a bug? Or did I made a mistake somewhere and I am not able to see it right now?
>
>
> Thank you for any help!
>
> Best regards,
> Marko
>

If you're 100% sure this XML is valid, then this is a bug. You should
report it at bugs.php.net, but it is most likely this bug is in
libXML, and needs to be fixed there.

- Matijn

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux