Hi Santhosh, I think the problem is that your xml document is referencing the wrong URI for the schema:
xsi:schemaLocation="http://www.harmony.com<http://www.harmony.com/> library.xsd" I think that line in the document should be: xsi:schemaLocation="library.xsd" The other option is to remove that xsi:schemaLocation attribute. A quick glance at the spec makes me think the behavior of specifying multiple URIs for schemaLocation is implementation-defined, but I am not sure of that. At any rate, try changing that declaration and see if that works. Also, keep in mind that 4.0 only validates simple types; complex types are only partially validated. -Danny From: [email protected] [mailto:[email protected]] On Behalf Of Santhosh Raj Sent: Wednesday, May 27, 2009 10:04 PM 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"> <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" 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]] 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 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 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
