[MarkLogic Dev General] Validate XML file against Schema
Pradeep Maddireddy
pradeep400 at gmail.com
Wed Apr 21 05:05:29 PDT 2010
Hi ..!
I am trying to validate the following XML file against the below mentioned xsd
-------------------------------- XML File --------------------------------
<book xsi:schemaLocation="http://marklogic.com/ls"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<title>Booktitle</title>
<chapter><title>Chaptertitle</title></chapter>
</book>
-------------------------------- xsd --------------------------------
<xs:schema targetNamespace="http://marklogic.com/ls"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="title">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="BookTitle"/>
<xs:enumeration value="ChapterTitle"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="chapter">
<xs:complexType>
<xs:sequence>
<xs:element ref="title"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="book">
<xs:complexType>
<xs:sequence>
<xs:element ref="title"/>
<xs:element ref="chapter"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
using validate {doc("/testabc.xml")} I am receiving the following error
[1.0-ml] XDMP-VALIDATENODECL: (err:XQDY0084) validate {
fn:doc("/testabc.xml") } -- Missing element declaration: Expected
declaration for node fn:doc("/testabc.xml")/book in non-lax mode using
schema ""
But when I use a name space prefix "ls" to all xml elements as shown
below the validation passes. Is it mandatory to have a namespace as
prefix to validate an XMl against a schema?
<ls:book xsi:schemaLocation="http://marklogic.com/ls"
xmlns:ls="http://marklogic.com/ls"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ls:title>BookTitle</ls:title>
<ls:chapter>
<ls:title>ChapterTitle</ls:title>
</ls:chapter>
</ls:book>
Thanks
Pradeep Maddireddy
More information about the General
mailing list