<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/xdmp.validate.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>xdmp.validate</api:function-name><api:suggest>xdmp.validate</api:suggest><api:suggest>xdmp</api:suggest><api:suggest>validate</api:suggest><api:function-link mode="xquery" fullname="xdmp:validate">/apidoc/8.0/xdmp:validate.xml</api:function-link><api:function mode="javascript" name="validate" type="builtin" lib="xdmp" category="Extension" subcategory="MarkLogic Server" hidden="false" bucket="MarkLogic Built-In Functions" prefix="xdmp" namespace="http://marklogic.com/xdmp" fullname="xdmp.validate"><api:summary>
  Returns an element containing a summary of validation errors in a node.
</api:summary><api:params><api:param name="node" type="node()" optional="false"><api:param-description>
  The node to validate.
  </api:param-description><api:param-name>node</api:param-name><api:param-type>Node</api:param-type></api:param><api:param name="mode" type="xs:string" optional="true"><api:param-description>
  The validation mode, either "strict", "lax", or "type".
  </api:param-description><api:param-name>mode</api:param-name><api:param-type>String</api:param-type></api:param><api:param name="typeName" type="xs:QName" optional="true"><api:param-description>
  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".
  </api:param-description><api:param-name>typeName</api:param-name><api:param-type>xs.QName</api:param-type></api:param></api:params><api:return>element(xdmp.validationErrors)</api:return><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
xdmp.validate(
xdmp.unquote('&lt;t:thesaurus xmlns:t="http://marklogic.com/xdmp/thesaurus"&gt;'
+  '&lt;t:entry&gt; \n \
     &lt;t:term&gt;one&lt;/t:term&gt; \n \
     &lt;t:notes&gt;unexpected stuff&lt;/t:notes&gt; \n \
     &lt;t:part-of-speech&gt;expl&lt;/t:part-of-speech&gt; \n \
     &lt;t:synonym&gt; \n \
        &lt;t:term&gt;unique&lt;/t:term&gt; \n \
     &lt;/t:synonym&gt; \n \
  &lt;/t:entry&gt; \n \
&lt;/t:thesaurus&gt;' ) );
=&gt;

&lt;xdmp:validation-errors xmlns:xdmp="http://marklogic.com/xdmp"&gt;
 &lt;error:error xmlns:error="http://marklogic.com/xdmp/error"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
    &lt;error:code&gt;XDMP-VALIDATEUNEXPECTED&lt;/error:code&gt;
    &lt;error:name&gt;err:XQDY0027&lt;/error:name&gt;
    &lt;error:xquery-version&gt;JavaScript&lt;/error:xquery-version&gt;
    &lt;error:message&gt;Invalid node&lt;/error:message&gt;
    &lt;error:format-string&gt;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"&lt;/error:format-string&gt;
    &lt;error:retryable&gt;false&lt;/error:retryable&gt;
    &lt;error:expr&gt;validate full { () }&lt;/error:expr&gt;
    &lt;error:data&gt;
      &lt;error:datum&gt;{http://marklogic.com/xdmp/thesaurus}notes&lt;/error:datum&gt;
      &lt;error:datum&gt;({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+)
      &lt;/error:datum&gt;
      &lt;error:datum&gt;fn:doc('')/t:thesaurus/t:entry/t:notes&lt;/error:datum&gt;
      &lt;error:datum&gt;"thesaurus.xsd"&lt;/error:datum&gt;
    &lt;/error:data&gt;
    &lt;error:stack&gt;
      &lt;error:frame&gt;
  &lt;error:operation&gt;xdmp:eval("xdmp.validate(\nxdmp.unquote('&amp;lt;t:thesaurus
  xmlns:t=\"http://mark...", {}, &amp;lt;options
  xmlns="xdmp:eval"&amp;gt;&amp;lt;database&amp;gt;18210430083193679484&amp;lt;/database&amp;gt;
  &amp;lt;root&amp;gt;/space/appserver&amp;lt;...&amp;lt;/options&amp;gt;)
  &lt;/error:operation&gt;
  &lt;error:xquery-version&gt;JavaScript&lt;/error:xquery-version&gt;
      &lt;/error:frame&gt;
      &lt;error:frame&gt;
  &lt;error:uri&gt;/qconsole/endpoints/evaljs.sjs&lt;/error:uri&gt;
  &lt;error:xquery-version&gt;JavaScript&lt;/error:xquery-version&gt;
      &lt;/error:frame&gt;
    &lt;/error:stack&gt;
  &lt;/error:error&gt;&lt;error:error xmlns:error="http://marklogic.com/xdmp/error"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
    &lt;error:code&gt;XDMP-VALIDATEBADTYPE&lt;/error:code&gt;
    &lt;error:name&gt;err:XQDY0027&lt;/error:name&gt;
    &lt;error:xquery-version&gt;JavaScript&lt;/error:xquery-version&gt;
    &lt;error:message&gt;Invalid node type&lt;/error:message&gt;
    &lt;error:format-string&gt;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"
    &lt;/error:format-string&gt;
    &lt;error:retryable&gt;false&lt;/error:retryable&gt;
    &lt;error:expr&gt;validate full { () }&lt;/error:expr&gt;
    &lt;error:data&gt;
      &lt;error:datum&gt;
        {http://marklogic.com/xdmp/thesaurus}part-of-speech
      &lt;/error:datum&gt;
      &lt;error:datum&gt;"expl"&lt;/error:datum&gt;
      &lt;error:datum&gt;
        #{http://marklogic.com/xdmp/thesaurus}part-of-speech
      &lt;/error:datum&gt;
      &lt;error:datum&gt;fn:doc('')/t:thesaurus/t:entry/t:part-of-speech&lt;/error:datum&gt;
      &lt;error:datum&gt;"thesaurus.xsd"&lt;/error:datum&gt;
    &lt;/error:data&gt;
    &lt;error:stack&gt;
      &lt;error:frame&gt;
  &lt;error:operation&gt;xdmp:eval("xdmp.validate(\nxdmp.unquote('&amp;lt;t:thesaurus
  xmlns:t=\"http://mark...", {}, &amp;lt;options xmlns="xdmp:eval"&amp;gt;&amp;lt;database
  &amp;gt;18210430083193679484&amp;lt;/database&amp;gt;&amp;lt;root&amp;gt;/space/appserver
  &amp;lt;...&amp;lt;/options&amp;gt;)&lt;/error:operation&gt;
  &lt;error:xquery-version&gt;JavaScript&lt;/error:xquery-version&gt;
      &lt;/error:frame&gt;
      &lt;error:frame&gt;
  &lt;error:uri&gt;/qconsole/endpoints/evaljs.sjs&lt;/error:uri&gt;
  &lt;error:xquery-version&gt;JavaScript&lt;/error:xquery-version&gt;
      &lt;/error:frame&gt;
    &lt;/error:stack&gt;
  &lt;/error:error&gt;
&lt;/xdmp:validation-errors&gt;

</pre></api:example></api:function></api:function-page>