[MarkLogic Dev General] Xml schema validation problem - reg.,

Danny Sokolsky Danny.Sokolsky at marklogic.com
Wed May 27 09:03:00 PDT 2009


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: general-bounces at developer.marklogic.com [mailto:general-bounces at developer.marklogic.com] 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" <mary.holstege at marklogic.com>
Sent by: general-bounces at developer.marklogic.com

05/26/2009 08:58 PM
Please respond to
General Mark Logic Developer Discussion <general at developer.marklogic.com>


To

"General Mark Logic Developer Discussion" <general at developer.marklogic.com>

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 <santhosh.raj at tcs.com>
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
General at developer.marklogic.com
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




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://xqzone.marklogic.com/pipermail/general/attachments/20090527/14d478fd/attachment-0001.html


More information about the General mailing list