XSLT instructions inside Schematron are working fine, but are they supposed to at all?

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
Ron Van den Branden
Posts: 48

XSLT instructions inside Schematron are working fine, but are they supposed to at all?

Sat Mar 11, 2017 1:36 am


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"
  <!-- all XSLT -->
  <xsl:variable name="test">test value</xsl:variable>
  <xsl:template name="get.test">
    <xsl:value-of select="local:get.test()"/>
  <xsl:function name="local:get.test">
    <xsl:value-of select="$test"/>
  <!-- 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: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>'

If this file is stored as "schematron+xslt.sch" and used for validating any XML file:

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"?>

...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:
  • <xsl:key>
  • <xsl:function>
  • <xsl:copy-of>
Yet, the fact that the other XSLT instructions in the example above are working, makes me wonder if I might be misinterpreting the Schematron specification. Put differently: is the use of XSLT instructions in the Schematron example above legitimate and supposed to work (which would be wonderful), or just working unintended?


Posts: 137

Re: XSLT instructions inside Schematron are working fine, but are they supposed to at all?

Mon Mar 13, 2017 6:21 pm

Hello Ron,

The Schematron specification does not mention that you can use XSLT in Schematron. But Schematron was designed somehow to use XSLT.
The reference implementation uses XSLT: http://schematron.com/front-page/the-sc ... ementation

Therefore, the use of XSLT in Schematron is implementation specific. All the implementations that uses "skeleton", including the one from <oXygen/>, will support XSLT inside Schematron.

Best Regards,
Octavian Nadolu
<oXygen/> XML Editor

Return to “Common Problems”

Who is online

Users browsing this forum: No registered users and 1 guest