xdmp.validate( node as Node, [mode as String], [typeName as xs.QName] ) as element(xdmp.validationErrors)
Returns an element containing a summary of validation errors in a node.
xdmp.validate( xdmp.unquote('<t:thesaurus xmlns:t="http://marklogic.com/xdmp/thesaurus">' + '<t:entry> \n \ <t:term>one</t:term> \n \ <t:notes>unexpected stuff</t:notes> \n \ <t:part-of-speech>expl</t:part-of-speech> \n \ <t:synonym> \n \ <t:term>unique</t:term> \n \ </t:synonym> \n \ </t:entry> \n \ </t:thesaurus>' ) ); => <xdmp:validation-errors xmlns:xdmp="http://marklogic.com/xdmp"> <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>JavaScript</error:xquery-version> <error:message>Invalid node</error:message> <error:format-string>XDMP-VALIDATEUNEXPECTED: validate full { () } -- Invalid node: Found {http://marklogic.com/xdmp/thesaurus}notes but expected ({http://marklogic.com/xdmp/thesaurus}part-of-speech?, {http://marklogic.com/xdmp/thesaurus}qualifiers?, {http://marklogic.com/xdmp/thesaurus}scope-notes?, {http://marklogic.com/xdmp/thesaurus}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>{http://marklogic.com/xdmp/thesaurus}notes</error:datum> <error:datum>({http://marklogic.com/xdmp/thesaurus}part-of-speech?, {http://marklogic.com/xdmp/thesaurus}qualifiers?, {http://marklogic.com/xdmp/thesaurus}scope-notes?, {http://marklogic.com/xdmp/thesaurus}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:operation>xdmp:eval("xdmp.validate(\nxdmp.unquote('<t:thesaurus xmlns:t=\"http://mark...", {}, <options xmlns="xdmp:eval"><database>18210430083193679484</database> <root>/space/appserver<...</options>) </error:operation> <error:xquery-version>JavaScript</error:xquery-version> </error:frame> <error:frame> <error:uri>/qconsole/endpoints/evaljs.sjs</error:uri> <error:xquery-version>JavaScript</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>JavaScript</error:xquery-version> <error:message>Invalid node type</error:message> <error:format-string>XDMP-VALIDATEBADTYPE: validate full { () } -- Invalid node type: {http://marklogic.com/xdmp/thesaurus}part-of-speech lexical value "expl" invalid for expected type #{http://marklogic.com/xdmp/thesaurus}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> {http://marklogic.com/xdmp/thesaurus}part-of-speech </error:datum> <error:datum>"expl"</error:datum> <error:datum> #{http://marklogic.com/xdmp/thesaurus}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:operation>xdmp:eval("xdmp.validate(\nxdmp.unquote('<t:thesaurus xmlns:t=\"http://mark...", {}, <options xmlns="xdmp:eval"><database >18210430083193679484</database><root>/space/appserver <...</options>)</error:operation> <error:xquery-version>JavaScript</error:xquery-version> </error:frame> <error:frame> <error:uri>/qconsole/endpoints/evaljs.sjs</error:uri> <error:xquery-version>JavaScript</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.