XSLT instructions inside Schematron are working fine, but are they supposed to at all?
Posted: Sat Mar 11, 2017 1:36 am
Hi,
I am writing an ISO Schematron file for validating my XML files, and have encountered a nice feature, but am wondering about its status.
It seems that embedded XSLT instructions in a Schematron file are just processed. For example, following Schematron file contains a dummy rule that will always fire on the document element of an XML file and output the value of an XSLT variable, using several XSLT instructions (<xsl:for-each>, <xsl:call-template>, <xsl:function>, and <xsl:variable>):
If this file is stored as "schematron+xslt.sch" and used for validating any XML file:
...it all seems to work perfectly: the value of the XSLT variable $test is correctly retrieved.
So far, so good. Yet, I'm puzzled if this is a feature, or a bug, or an unintended side-effect, either of the specification, the implementation, or Oxygen. The Schematron specification only mentions following XSLT elements in Annex H: Query language binding for XSLT 2:
Best,
Ron
I am writing an ISO Schematron file for validating my XML files, and have encountered a nice feature, but am wondering about its status.
It seems that embedded XSLT instructions in a Schematron file are just processed. For example, following Schematron file contains a dummy rule that will always fire on the document element of an XML file and output the value of an XSLT variable, using several XSLT instructions (<xsl:for-each>, <xsl:call-template>, <xsl:function>, and <xsl:variable>):
Code: Select all
<?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>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="schematron+xslt.sch" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<test/>
So far, so good. Yet, I'm puzzled if this is a feature, or a bug, or an unintended side-effect, either of the specification, the implementation, or Oxygen. The Schematron specification only mentions following XSLT elements in Annex H: Query language binding for XSLT 2:
- <xsl:key>
- <xsl:function>
- <xsl:copy-of>
Best,
Ron