Loading TOC...

MarkLogic 12 EA 1 Product Documentation
xdmp.validate

xdmp.validate(
   node as Node,
   [mode as String],
   [typeName as xs.QName]
) as element(xdmp.validationErrors)

Summary

Returns an element containing a summary of validation errors in a node.

Parameters
node The node to validate.
mode The validation mode, either "strict", "lax", or "type".
typeName The name of the type to validate against, if the mode is "type". An error is raised if a typeName is given with a different validation mode, or if no type is given if the mode is "type".

Example

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('&lt;t:thesaurus
  xmlns:t=\"http://mark...", {}, &lt;options
  xmlns="xdmp:eval"&gt;&lt;database&gt;18210430083193679484&lt;/database&gt;
  &lt;root&gt;/space/appserver&lt;...&lt;/options&gt;)
  </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('&lt;t:thesaurus
  xmlns:t=\"http://mark...", {}, &lt;options xmlns="xdmp:eval"&gt;&lt;database
  &gt;18210430083193679484&lt;/database&gt;&lt;root&gt;/space/appserver
  &lt;...&lt;/options&gt;)</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 iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.