xsl-list
[Top] [All Lists]

[xsl] XSL processor version detection stylesheet with XSLT 2.0 properties

2007-10-01 02:18:22
The XSL processor detection stylesheet [1] referred to from the XSL-List
Guidelines predates XSLT 2.0 by several years, so it doesn't use the
additional system properties defined in XSLT 2.0 [2].  It also omits the
'xsl:version' system property, which at the time had only one possible
value.

The version below uses all the system properties defined in XSLT 2.0:

------------------------------------------------------------
<?xml version="1.0"?>
<?xml-stylesheet href="processor-version.xsl" type="text/xsl"?>
<!-- ============================================================= -->
<!-- MODULE:    XSL Processor Version Detection Stylesheet         -->
<!-- ============================================================= -->

<html xsl:version="1.0"
      xmlns:msxsl="http://www.w3.org/TR/WD-xsl";
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
      xmlns="http://www.w3.org/TR/xhtml1/strict";>
  <head>
    <title>XSLT Processor Version</title>
  </head>
  <body>
    <xsl:choose>
      <xsl:when test="false()">
        <msxsl:if test=".">
          <p>Vendor: Microsoft
          <br/>Processor version:
            Original IE5 (or old version of other processor)</p>
        </msxsl:if>
      </xsl:when>
      <xsl:otherwise>
        <msxsl:choose>
          <msxsl:when test=".">
          </msxsl:when>
          <msxsl:otherwise>
            <p>XSL version:
              <xsl:value-of select="system-property('xsl:version')"/></p>
            <p>Vendor:
              <xsl:value-of select="system-property('xsl:vendor')"/></p>
            <p>Vendor URL:
              <xsl:value-of select="system-property('xsl:vendor-url')"/></p>
            <p>Product name:
              <xsl:value-of select="system-property('xsl:product-name')"/></p>
            <p>Product version:
              <xsl:value-of 
select="system-property('xsl:product-version')"/></p>
            <p>Is schema-aware:
              <xsl:value-of 
select="system-property('xsl:is-schema-aware')"/></p>
            <p>Supports serialization:
              <xsl:value-of 
select="system-property('xsl:supports-serialization')"/></p>
            <p>Supports backwards compatibility:
              <xsl:value-of 
select="system-property('xsl:supports-backwards-compatibility')"/></p>
          </msxsl:otherwise>
        </msxsl:choose>
      </xsl:otherwise>
    </xsl:choose>
  </body>
</html>
------------------------------------------------------------

Sample output from xsltproc:

------------------------------------------------------------
<?xml version="1.0"?>
<html xmlns:msxsl="http://www.w3.org/TR/WD-xsl"; 
xmlns="http://www.w3.org/TR/xhtml1/strict";><head><title>XSLT Processor 
Version</title></head><body><msxsl:choose><msxsl:when 
test="."/><msxsl:otherwise><p>XSL version:
              1.0</p><p>Vendor:
              libxslt</p><p>Vendor URL:
              http://xmlsoft.org/XSLT/</p><p>Product name:
              </p><p>Product version:
              </p><p>Is schema-aware:
              </p><p>Supports serialization:
              </p><p>Supports backwards compatibility:
              </p></msxsl:otherwise></msxsl:choose></body></html>
------------------------------------------------------------

and from Saxon:

------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?><html 
xmlns="http://www.w3.org/TR/xhtml1/strict"; 
xmlns:msxsl="http://www.w3.org/TR/WD-xsl";><head><title>XSLT Processor 
Version</title></head><body><msxsl:choose><msxsl:when 
test="."/><msxsl:otherwise><p>XSL version:
              2.0</p><p>Vendor:
              SAXON 8.9.0.4 from Saxonica</p><p>Vendor URL:
              http://www.saxonica.com/</p><p>Product name:
              SAXON</p><p>Product version:
              8.9.0.4</p><p>Is schema-aware:
              no</p><p>Supports serialization:
              yes</p><p>Supports backwards compatibility:
              yes</p></msxsl:otherwise></msxsl:choose></body></html>
------------------------------------------------------------

Regards,


Tony Graham.
======================================================================
Tony(_dot_)Graham(_at_)MenteithConsulting(_dot_)com   
http://www.menteithconsulting.com

Menteith Consulting Ltd             Registered in Ireland - No. 428599
Registered Office: 13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
----------------------------------------------------------------------
Menteith Consulting -- Understanding how markup works
======================================================================

[1] http://www.mulberrytech.com/xsl/xsl-list/processor-version.xsl
[2] http://www.w3.org/TR/xslt20/#system-property

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>