Hi Folks,
I've finally gotten back to trying to perform strict validation of an XML
document that has no namespace. Given the example that Geert provided below
and Mary's feedback, the following xquery is able to successfully validate
an XML document and to display the validated document (with one exception
which I will mention afterwards):
xquery version "1.0-ml";
import schema "" at "/my-schema.xsd";
declare default element namespace "";
let $node := fn:doc("/A/B/my-doc.xml")
return validate strict { $node }
where the namespace is defined in my-doc.xml as follows:
<root xsi:noNamespaceSchemaLocation="/my-schema.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
Note that the schema is located in the root of the Schema database.
The exception is that if the schema name lacks the forward slash in the xml
document as follows:
<root xsi:noNamespaceSchemaLocation="my-schema.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
then the validation proceeds without any errors being thrown but returns no
document (so I don't think validation is working in this case). I don't
know if it needs the "/" because the document is not located in the root
path of its database or if the path is required to find the schema in the
Schema database. The documents I am trying to validate do not include the
"/" path. I can always revise them, but I'm looking for a quick fix.
Thank you!
Tim Meagher
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Mary Holstege
Sent: Sunday, November 01, 2009 9:58 AM
To: General Mark Logic Developer Discussion
Subject: Re: [MarkLogic Dev General] Validating an XML
documentinMarkLogicthat references a DTD as part of a precommit trigger
On Sat, 31 Oct 2009 06:19:28 -0700, Geert Josten
<[email protected]> wrote:
> Mary,
>
> I tried putting things together and was looking at import schema to make
> it work with no-namespace schemas and xml, and found the instructive
> message http://markmail.org/message/o2f4yi477hbqq67o telling that I
> should use something like this:
>
> declare default element namespace "";
> import schema namespace "" at "/my-schema.xsd";
>
> But it keeps throwing:
>
> [1.0-ml] XDMP-SCHPRFX: (err:XQST0057) Cannot declare a prefix
> for the empty namespace URI in a schema import
>
> I tried various combinations and syntax changes, but none seem to work.
> I am running MarkLogic Server 4.1-3.
>
> Any suggestions?
>
> Kind regards,
> Geert
The problem is that you are declaring the namespace twice.
The correct way to do this is:
declare default element namespace "";
import schema "" at "/my-schema.xsd";
//Mary
[email protected]
Lead Applications Engineer
Mark Logic Corporation
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general