XSLT extensions

Extension selection

1. Extension capability

1.

Extension capability

Steve Muench and others.


what processor is using this stylesheet?

Is there something one can put on a test= to determine what
processor is running, e.g. in English,

  <xsl:choose>
   <xsl:when test="saxon is being used to process this stylesheet">
     <-- [do X] -->
    </xsl:when>
    <xsl:otherwise>
     <!-- otherwise it is xt or xalan or etc. -->
     <!-- do Y -->
    </xsl:otherwise>
  </xsl:choose>



The XSLT 1.0 Spec is careful to provide the necessary
mechanisms to built robust, portable XSLT stylesheets, even
in the face of cool extensions.

The <xsl:fallback> and element-available('qname') and
function-available('qname') let you have good, proactive
control as to what should happen if an extension on which
you depend is not available.


Steve Tinney adds


You need to determine the xsl:vendor string using a test
file and then apply that in your real tests.  This could be
modularized so that one could say:

	<xsl:import href="vendors.xsl"/>
        <xsl:variable name="vendor">
          <xsl:call-template name="set-vendor"/>
        </xsl:variable>

and in vendors.xsl:

<xsl:template name="set-vendor">
  <xsl:variable name="xsl-vendor"
                select="system-property('xsl:vendor')"/>
  <xsl:choose>
    <xsl:when test="starts-with($xsl-vendor,'SAXON')">
      <xsl:text>saxon</xsl:text>
    </xsl:when>
    <xsl:when test="contains($xsl-vendor,'Clark')">
      <xsl:text>xt</xsl:text>
    </xsl:when>
    <xsl:otherwise>
      <xsl:text>UNKNOWN VENDOR</xsl:text>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>



Steve finishes with


Using the following stylesheet:

<xsl:stylesheet 
	    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
	    version="1.0" xsl:version="1.0">

 <xsl:template match="/">
xsl:version    = <xsl:value-of select="system-property('xsl:version')"/> 
xsl:vendor     = <xsl:value-of select="system-property('xsl:vendor')"/> 
xsl:vendor-url = <xsl:value-of select="system-property('xsl:vendor-url')"/> 
 </xsl:template>
</xsl:stylesheet>

I get:

Apache Xalan 0.20.0
- -------------------
xsl:version    = 1
xsl:vendor     = Apache Software Foundation
xsl:vendor-url = http://xml.apache.org/xalan

Oracle XSLT Processor 2.0.2.7
- -----------------------------
xsl:version    = 1.0
xsl:vendor     = Oracle Corporation.
xsl:vendor-url = http://www.oracle.com

XT
- --
xsl:version    = 1
xsl:vendor     = James Clark
xsl:vendor-url = http://www.jclark.com/

Saxon 5.2
- ---------
xsl:version    = 1
xsl:vendor     = SAXON from Michael Kay of ICL
xsl:vendor-url = http://users.iclway.co.uk/mhkay/saxon/index.html