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: 65
Joined: Fri Jan 18, 2008 5:54 pm

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

Post by Ron Van den Branden »

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>):

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>
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"?>
<test/>
...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?

Best,

Ron
tavy
Posts: 364
Joined: Thu Jul 01, 2004 12:29 pm

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

Post by tavy »

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
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply