<template xmlns="http://marklogic.com/xdmp/tde">
<context>/test</context>
<vars>
<var>
<name>subprefix</name>
<val>"http://www.test.com/resource/test/"</val>
</var>
<var>
<name>objprefix</name>
<val>"http://www.test.com/resource/test/"</val>
</var>
</vars>
<triples>
<triple>
<subject>
<val>sem:iri($subprefix || ElemenetName)</val>
<invalid-values>ignore</invalid-values>
</subject>
<predicate>
<val>sem:iri('is')</val>
</predicate>
<object>
<val>sem:iri($objprefix || FullName)</val>
<invalid-values>ignore</invalid-values>
</object>
</triple>
</triples>
</template>
I have created a Template to get triples out of XML.
But want to escape null value triples(s,p or o). I am using ignore, but this works only if there is not prefix in subject or object. If there is prefix it creates triples with null(only prefix).
Do we have any way to handle this in MarkLogic TDE?
Nullable object/subject issue.
PFB.
You can take more use from the context expression, particularly if you use sub-templates. Here a crude example showing a sub-template, applied to 3 example docs:
Some more background on sub-templates can be found here:
https://docs.marklogic.com/guide/sql/creating-template-views#id_28999
HTH!