With proper <sch:ns/>
declared for cts
and dohickey
, I can call MarkLogic API functions such as cts:*
from compiled Schematron as follows (which is awesome, by the way):
<sch:rule context="dohickey:thingummy">
<sch:let name="this-id" value="dohickey:meta/dohickey:id/string()"/>
<sch:let name="known-ids" value="cts:element-values(xs:QName('dohickey:id'))"/>
<sch:report test="$this-id = $known-ids">Warning: This id is known, and that's a business error</sch:report>
</sch:rule>
(Please ignore that the $known-ids
variable would be optimized to lock down on a single value in real life, instead of returning them all---for the sake of the example)
Now I'd like to include custom XQuery modules in my Schematron in the same way that I can call cts:*
in the example above, and in the same way I can call XQuery library functions when working with raw XSLT and MarkLogic XSLT/XQuery integration by defining, e.g., an xsl:stylesheet/@extension-element-prefixes
value, followed by an appropriate <xdmp:import-module/>
.
Example: I'd like to do the following:
<sch:rule context="dohickey:thingummy">
<sch:let name="this-id" value="dohickey:meta/dohickey:id/string()"/>
<sch:let name="is-flagged-for-revision" value="mycustommodule:is-flagged-for-revision($this-id)"/>
<sch:report test="$is-flagged-for-revision">Warning: This id has been flagged for revision</sch:report>
</sch:rule>
Question: is there currently a way to get MarkLogic's schematron:put
compilation behavior to include custom XQuery module imports, analogous to MarkLogic's XSLT <xdmp:import-module/>
support? Or should I just implement a wrapper that transforms the schematron:put
compiled result to include what I need so it's in the compiled XSLT?
xdmp:node-insert-child
.. - grtjn