Hi Ashwini,

You are looking for the Xquery validate instruction:

http://www.w3.org/TR/xquery/#id-validate

You will have to register the XML Schema in MarkLogic though. Use the Admin 
interface to do so..

Kind regards,
Geert

>


Drs. G.P.H. Josten
Consultant


http://www.daidalos.nl/
Daidalos BV
Source of Innovation
Hoekeindsehof 1-4
2665 JZ Bleiswijk
Tel.: +31 (0) 10 850 1200
Fax: +31 (0) 10 850 1199
http://www.daidalos.nl/
KvK 27164984
De informatie - verzonden in of met dit emailbericht - 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 Ashwini
> Sent: woensdag 30 september 2009 9:18
> To: [email protected]
> Subject: [MarkLogic Dev General] XML validation across schema
>
> Hi All,
>
> how to validate a XML file againest schema in marklogic.
> i am able to load a XML file which is not following schema
> into marklogic.
> how i can validate xml file and load  valid one.
> can any one help me out.
>
> Here i am giving sample XML file and XSD file.
>
>
> "shiporder.xml"
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <shiporder id="889923"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xsi:noNamespaceSchemaLocation="shiporder.xsd">
>   <orderperson>John Smith</orderperson>
>   <shipto>
>     <name>Ola Nordmann</name>
>     <address>Langgt 23</address>
>     <city>4000 Stavanger</city>
>     <country>Norway</country>
>   </shipto>
>   <item>
>     <title>Empire Burlesque</title>
>     <note>Special Edition</note>
>     <quantity>1</quantity>
>     <price>10.90</price>
>   </item>
>   <item>
>     <title>Hide your heart</title>
>     <quantity>1</quantity>
>     <price>9.90</price>
>   </item>
> </shiporder>
>
>
> "shiporder.xsd"
>
> <?xml version="1.0" encoding="ISO-8859-1" ?> <xs:schema
> xmlns:xs="http://www.w3.org/2001/XMLSchema";>
>
> <xs:simpleType name="stringtype">
>   <xs:restriction base="xs:string"/>
> </xs:simpleType>
>
> <xs:simpleType name="inttype">
>   <xs:restriction base="xs:positiveInteger"/> </xs:simpleType>
>
> <xs:simpleType name="dectype">
>   <xs:restriction base="xs:decimal"/>
> </xs:simpleType>
>
> <xs:simpleType name="orderidtype">
>   <xs:restriction base="xs:string">
>     <xs:pattern value="[0-9]{6}"/>
>   </xs:restriction>
> </xs:simpleType>
>
> <xs:complexType name="shiptotype">
>   <xs:sequence>
>     <xs:element name="name" type="stringtype"/>
>     <xs:element name="address" type="stringtype"/>
>     <xs:element name="city" type="stringtype"/>
>     <xs:element name="country" type="stringtype"/>
>   </xs:sequence>
> </xs:complexType>
>
> <xs:complexType name="itemtype">
>   <xs:sequence>
>     <xs:element name="title" type="stringtype"/>
>     <xs:element name="note" type="stringtype" minOccurs="0"/>
>     <xs:element name="quantity" type="inttype"/>
>     <xs:element name="price" type="dectype"/>
>   </xs:sequence>
> </xs:complexType>
>
> <xs:complexType name="shipordertype">
>   <xs:sequence>
>     <xs:element name="orderperson" type="stringtype"/>
>     <xs:element name="shipto" type="shiptotype"/>
>     <xs:element name="item" maxOccurs="unbounded" type="itemtype"/>
>   </xs:sequence>
>   <xs:attribute name="orderid" type="orderidtype"
> use="required"/> </xs:complexType>
>
> <xs:element name="shiporder" type="shipordertype"/>
>
> </xs:schema>
>
>
> According to the schema "shiporder element" required
> "orderid" attribute.
> in "shiporder.xml" not having "orderid", when i am loading
> the shiporder.xml, it should send a message.
>
>
> Regards,
> Ashwini
> _______________________________________________
> General mailing list
> [email protected]
> http://xqzone.com/mailman/listinfo/general
>

_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to