Skip to content

Instantly share code, notes, and snippets.

@rvdb
Created March 10, 2017 20:28
Show Gist options
  • Save rvdb/ad2dc77bf5fc33b4e02cb3e415d19888 to your computer and use it in GitHub Desktop.
Save rvdb/ad2dc77bf5fc33b4e02cb3e415d19888 to your computer and use it in GitHub Desktop.
a Schematron file and XML test file, illustrating how (any?) XSLT instructions inside in Schematron patterns just seem to be executed
<?xml version="1.0" encoding="UTF-8"?>
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:local="local">
<!-- all XSLT -->
<xsl:variable name="test">test value</xsl:variable>
<xsl:template name="get.test">
<xsl:value-of select="local:get.test()"/>
</xsl:template>
<xsl:function name="local:get.test">
<xsl:value-of select="$test"/>
</xsl:function>
<!-- a dummy Schematron pattern that will always trigger for the document node, just to show how various XSLT instructions seem to be executed in Schematron without problem. -->
<sch:pattern>
<sch:rule context="/*">
<sch:report test="true() or false()">
This rule will always fire, demonstrating how XSLT instructions seem to be executed without problems in Schematron. For example, the named template "get.test" will execute the function "local:get.test()" which will retrieve the value of the variable $test, namely: '<xsl:for-each select="."><xsl:call-template name="get.test"/></xsl:for-each>'
</sch:report>
</sch:rule>
</sch:pattern>
</sch:schema>
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="schematron+xslt.sch" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<test/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment