[MarkLogic Dev General] Validating XML against Schema

Mary Holstege mary.holstege at marklogic.com
Wed Sep 15 08:47:17 PDT 2010


On Wed, 15 Sep 2010 08:26:18 -0700, G.V., Jibin  
<JGVijayan at innodata-isogen.com> wrote:
> I am trying to validate xml document with the below code.
>
> xquery version "1.0-ml";
> import schema "urn:hl7-org:v3" at "/spl.xsd";
> declare default element namespace "urn:hl7-org:v3";
> let $node :=  
> fn:doc("/referenceData/01C3122F-E791-40A5-B52E-963CB6685F71.xml")
> return validate strict{ $node }
>
> I am getting the below error:
>
> XDMP-VALIDATEBADARG: (err:XQTY0030) validate strict { $node } --  
> Argument to validate expression must be document or element node.
>
>

The error is actually complaining about $node, that it either
doesn't exist (or perhaps you don't have permissions to read it)
or it isn't an XML document.

Try just running this to ensure that the document exists and
does have 1 (and only 1) root element node:

fn:doc("/referenceData/01C3122F-E791-40A5-B52E-963CB6685F71.xml")/*

//Mary


More information about the General mailing list