Hi Pradeep, No, you don't necessarily need a prefix, you could also declare a default namespace by adding xmlns="http://marklogic.com/ls" to your book root element. If you have no prefixes, nor a default namespace, then all your elements are in no namespace and cannot be validated..
Kind regards, Geert > drs. G.P.H. (Geert) Josten Consultant Daidalos BV Hoekeindsehof 1-4 2665 JZ Bleiswijk T +31 (0)10 850 1200 F +31 (0)10 850 1199 mailto:[email protected] http://www.daidalos.nl/ KvK 27164984 P Please consider the environment before printing this mail. De informatie - verzonden in of met dit e-mailbericht - is afkomstig van Daidalos BV en is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onbedoeld hebt ontvangen, verzoeken wij u het te verwijderen. Aan dit bericht kunnen geen rechten worden ontleend. > From: [email protected] > [mailto:[email protected]] On Behalf Of > Pradeep Maddireddy > Sent: woensdag 21 april 2010 14:05 > To: General > Subject: [MarkLogic Dev General] Validate XML file against Schema > > 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 > _______________________________________________ > General mailing list > [email protected] > http://xqzone.com/mailman/listinfo/general > _______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general
