
xdmp:validate( $node as node(), [$mode as xs:string], [$typeName as xs:QName] ) as element(xdmp:validation-errors)
Returns an element containing a summary of validation errors in a node.
declare namespace t="http://marklogic.com/xdmp/thesaurus";
xdmp:validate(
document {
<t:thesaurus>
<t:entry>
<t:term>one</t:term>
<t:notes>unexpected stuff</t:notes>
<t:part-of-speech>expl</t:part-of-speech>
<t:synonym>
<t:term>unique</t:term>
</t:synonym>
</t:entry>
</t:thesaurus>
} )
=>
<xdmp:validation-errors>
<error:error xmlns:error="http://marklogic.com/xdmp/error"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<error:code>XDMP-VALIDATEUNEXPECTED</error:code>
<error:name>err:XQDY0027</error:name>
<error:xquery-version>1.0-ml</error:xquery-version>
<error:message>Invalid node</error:message>
<error:format-string>XDMP-VALIDATEUNEXPECTED:
(err:XQDY0027) validate full { () } -- Invalid node: Found t:notes but
expected (t:part-of-speech?,t:qualifiers?,t:scope-notes?,t:synonym*) at
fn:doc("")/t:thesaurus/t:entry/t:notes using schema
"thesaurus.xsd"</error:format-string>
<error:retryable>false</error:retryable>
<error:expr>validate full { () }</error:expr>
<error:data>
<error:datum>t:notes</error:datum>
<error:datum>(t:part-of-speech?,t:qualifiers?,t:scope-notes?,t:synonym*)
</error:datum>
<error:datum>fn:doc("")/t:thesaurus/t:entry/t:notes</error:datum>
<error:datum>"thesaurus.xsd"</error:datum>
</error:data>
<error:stack>
<error:frame>
<error:line>2</error:line>
<error:column>0</error:column>
<error:xquery-version>1.0-ml</error:xquery-version>
</error:frame>
</error:stack>
</error:error><error:error xmlns:error="http://marklogic.com/xdmp/error"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<error:code>XDMP-VALIDATEBADTYPE</error:code>
<error:name>err:XQDY0027</error:name>
<error:xquery-version>1.0-ml</error:xquery-version>
<error:message>Invalid node type</error:message>
<error:format-string>XDMP-VALIDATEBADTYPE: (err:XQDY0027) validate
full { () } -- Invalid node type: t:part-of-speech lexical value "expl"
invalid for expected type #t:part-of-speech at
fn:doc("")/t:thesaurus/t:entry/t:part-of-speech using schema
"thesaurus.xsd"</error:format-string>
<error:retryable>false</error:retryable>
<error:expr>validate full { () }</error:expr>
<error:data>
<error:datum>t:part-of-speech</error:datum>
<error:datum>"expl"</error:datum>
<error:datum>#t:part-of-speech</error:datum>
<error:datum>fn:doc("")/t:thesaurus/t:entry/t:part-of-speech</error:datum>
<error:datum>"thesaurus.xsd"</error:datum>
</error:data>
<error:stack>
<error:frame>
<error:line>2</error:line>
<error:column>0</error:column>
<error:xquery-version>1.0-ml</error:xquery-version>
</error:frame>
</error:stack>
</error:error>
</xdmp:validation-errors>
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.