Santhosh, I advice taking a closer look at your schema. As Mary pointed out in her first reply to you:
"In the current version of ML (4.0) it does not yet do full checking, however, although it will in 4.1. In particular, it does not check the complex type constraints (e.g. which children are required, etc.)." I ran a few quick tests on some demo documents on my laptop and noticed that it only works on elements declared at top-level. It does not work on elements that have been defined inside for instance a sequence. You could try moving all those element declarations to top-level and replacing them inside the sequences with element ref's. So this: > <xs:complexType name ="bookType"> > <xs:sequence> > <xs:element name="title" type="xs:string"/> > <xs:element name="price" type="xs:double"/> > </xs:sequence> > </xs:complexType> Would become this: > <xs:complexType name ="bookType"> > <xs:sequence> > <xs:element ref="title" /> > <xs:element ref="price" /> > </xs:sequence> > </xs:complexType> > > <xs:element name="title" type="xs:string"/> > <xs:element name="price" type="xs:double"/> > I haven't tested this, though. And the remark of Mary still stands, complex contents is still not validated to the extend you might expect.. Hope this helps.. 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 > Santhosh Raj > Sent: donderdag 28 mei 2009 7:04 > To: General Mark Logic Developer Discussion > Subject: RE: [MarkLogic Dev General] Xml schema validation > problem - reg., > > > Hi Danny, > > The uri of the schema in the schemas database is > "library.xsd" only, which i specified correctly in the at > clause as you mentioned. > > For Your Information ., My library.xsd in schemas database is > > <?xml version="1.0" encoding="utf-8"?> > <xs:schema targetNamespace="http://www.harmony.com > <http://www.harmony.com/> " > elementFormDefault="qualified" > xmlns="http://www.harmony.com <http://www.harmony.com/> " > xmlns:xs="http://www.w3.org/2001/XMLSchema > <http://www.w3.org/2001/XMLSchema> "> > > <xs:complexType name ="bookType"> > <xs:sequence> > <xs:element name="title" type="xs:string"/> > <xs:element name="price" type="xs:double"/> > </xs:sequence> > </xs:complexType> > > <xs:complexType name="booksType"> > <xs:sequence> > <xs:element name="book" type="bookType" > maxOccurs="unbounded"></xs:element> > </xs:sequence> > </xs:complexType> > > <xs:element name="books" type="booksType"/> > > </xs:schema> > > My library.xml in Documents database is > > <?xml version="1.0" encoding="utf-8"?> > <books xmlns="http://www.harmony.com <http://www.harmony.com/> " > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance > <http://www.w3.org/2001/XMLSchema-instance> " > xsi:schemaLocation="http://www.harmony.com > <http://www.harmony.com/> library.xsd"> > <book> > <title>Science</title> > <price>30</price> > </book> > <book> > <title>Arts</title> > <price>200</price> > </book> > </books> > > Then what is the problem i don't know? > > Thanks and Regards, > Santhosh Rajasekaran > > > > > Danny Sokolsky <[email protected]> > Sent by: [email protected] > > 05/27/2009 09:33 PM > Please respond to > General Mark Logic Developer Discussion > <[email protected]> > > To > General Mark Logic Developer Discussion > <[email protected]> > cc > Subject > RE: [MarkLogic Dev General] Xml schema validation problem - reg., > > > > > > > Hi Santhosh, > > What is the URI of your schema in the schemas database? That > is what goes in the "at" clause of the "import schema" declaration. > > -Danny > > From: [email protected] > [mailto:[email protected] > <mailto:[email protected]> ] On Behalf > Of Santhosh Raj > Sent: Tuesday, May 26, 2009 10:42 PM > To: General Mark Logic Developer Discussion > Subject: Re: [MarkLogic Dev General] Xml schema validation > problem - reg., > > > Hi Mary, > > Yes i am sure that my shcema is present in the schema > database. > > If schema is not there then executing the following query > will not give the output. > > doc("library.xml")//bk:book[1]/descendant::element(*,xs:double) > > It is correctly giving the desired output. I have also > checked in my schema database, library.xsd is present there. > > I tried what u said, still the same error is coming. > > import schema namespace bk="http://www.harmony.com > <http://www.harmony.com/> " at "library.xsd"; > try { > for $x in doc("library.xml")//bk:books > return xdmp:node-insert-child($x, validate strict { <bk:book> > <bk:title>History</bk:title> > <bk:price>648</bk:price> > </bk:book> } ) > > > } > catch ($e) { > $e > } > > What may be the problem. Or it would be more helpfull if your > give some sample xsd and xml where this validation is working. > > > Thanks and Regards, > Santhosh Rajasekaran > > > > "Mary Holstege" <[email protected]> > Sent by: [email protected] > > 05/26/2009 08:58 PM > > > > Please respond to > General Mark Logic Developer Discussion > <[email protected]> > > > > To > "General Mark Logic Developer Discussion" > <[email protected]> > cc > Subject > Re: [MarkLogic Dev General] Xml schema validation problem - reg., > > > > > > > > > > > > > XDMP-VALIDATENODECL means that no element declaration was found for > the validation root (bk:book in this case). Usually this > means that the > schema > wasn't being found. Your schema needs to be in the schemas > database for > the database of your data (typically, this is the database called > 'Schemas'). > It either needs to be the only schema for that namespace in > scope, or you > to have the location specified somehow. There are a number > of options for > this: a binding for it in the Schemas section of your group > configuration, > a schema import giving the location of the schema in your > query, or you > need > to have an xsi:schemaLocation on the instance itself. I > would suggest a > schema import in the query, e.g. > > import schema namespace bk="bk = "http://www.harmony.com > <http://www.harmony.com/> " > at "/path/to/schema/in/your/schemas/database.xsd"; > > in place of the namespace declaration. > > //Mary > > On Sun, 24 May 2009 23:14:42 -0700, Santhosh Raj > <[email protected]> > wrote: > > > Hi Mary, > > > > Then what is the Way to ensure that always my xml should be > > validated against the xsd.(while insert, update > operations.). I am using > > 4.0-2 version of Marklogic server. > > > > When i tried using the XQuery validate {} expression. It is giving " > > Element declaration not found for validated node in strict > mode" for all > > tye cases. > > > > Case 1: when i give book node with extra element > "<bk:author>Santhosh > > </bk:author>". This is acceptable. > > > > xdmp:node-insert-child($b, validate strict { <bk:book> > > <bk:title>Arts</bk:title> > > <bk:price>200</bk:price> > > <bk:author>Santhosh </bk:author> > > </bk:book> } ) > > > > Case 2: It is giving the same error whem i try to add correct > > elements.(i.e) adding only the elements present in the xsd. > > > > xdmp:node-insert-child($b, validate strict { <bk:book> > > <bk:title>Arts</bk:title> > > <bk:price>200</bk:price> > > </bk:book> } ) > > > > <error:code>XDMP-VALIDATENODECL</error:code> > > <error:name>err:XQDY0084</error:name> > > <error:xquery-version>1.0-ml</error:xquery-version> > > <error:message>Element declaration not found for validated node in > > strict mode</error:message> > > > > > > Thanks and Regards, > > Santhosh Rajasekaran > _______________________________________________ > General mailing list > [email protected] > http://xqzone.com/mailman/listinfo/general > <http://xqzone.com/mailman/listinfo/general> > > ForwardSourceID:NT0000BE56 > =====-----=====-----===== > Notice: The information contained in this e-mail > message and/or attachments to it may contain > confidential or privileged information. If you are > not the intended recipient, any dissemination, use, > review, distribution, printing or copying of the > information contained in this e-mail message > and/or attachments to it are strictly prohibited. If > you have received this communication in error, > please notify us by reply e-mail or telephone and > immediately and permanently delete the message > and any attachments. Thank you > > _______________________________________________ > General mailing list > [email protected] > http://xqzone.com/mailman/listinfo/general > <http://xqzone.com/mailman/listinfo/general> > > ForwardSourceID:NT0000BEDE > > =====-----=====-----===== > Notice: The information contained in this e-mail > message and/or attachments to it may contain > confidential or privileged information. If you are > not the intended recipient, any dissemination, use, > review, distribution, printing or copying of the > information contained in this e-mail message > and/or attachments to it are strictly prohibited. If > you have received this communication in error, > please notify us by reply e-mail or telephone and > immediately and permanently delete the message > and any attachments. Thank you > > > _______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general
