tde:validate( $templates as element(tde:template)*, [$excludeTemplateURIs as xs:string*] ) as map:map
In addition to
xdmp:validate
that can be used for validating against the extraction template schema.
The recommended workflow for users is to validate an extraction template before inserting it into the schema database. Unless you use the tde:template-insert function, Ill-formed templates are not validated or rejected at document insertion time.
For more information on extraction templates, see Template Driven Extraction (TDE) in the Application Developer's Guide.
The tde:validate
function enables users to do the following:
xquery version "1.0-ml"; let $t1:= <template xmlns="http://marklogic.com/xdmp/tde"> <context>/Citation/Article/Journal/Details</context> <rows> <row> <schema-name>Medical</schema-name> <view-name>Publications</view-name> <columns> <column> <name>ID</name> <scalar-type>BAD_SCALAR_TYPE</scalar-type> <val>../../../ID</val></column> </columns> </row> </rows> </template> return tde:validate(($t1),("previous_version_of_t1.xml")) => <map:map xmlns:map="http://marklogic.com/xdmp/map" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <map:entry key="valid"> <map:value xsi:type="xs:boolean">false</map:value> </map:entry> <map:entry key="error"> <map:value xsi:type="xs:string">TDE-INVALIDTEMPLATENODE</map:value> </map:entry> <map:entry key="message"> <map:value xsi:type="xs:string">TDE-INVALIDTEMPLATENODE: Invalid extraction template node: /tde:template/tde:rows/tde:row/tde:columns/tde:column/tde:scalar-type</map:value> </map:entry> </map:map>
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.