Detecting XSLT version

One of the problems I encounter is versioning xslt for MSXML and System.Xml.Xsl.  Here is a post that shows a way to detect the xslt engine:

http://www.tkachenko.com/blog/archives/000560.html

<!--StartFragment--><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ms="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="ms">
  <xsl:template match="/">
    <p>
      This XSLT stylesheet is being executed using
      <xsl:choose>
        <xsl:when test="system-property('xsl:vendor') = 'Microsoft'">
          <xsl:text>Microsoft </xsl:text>
          <xsl:variable name="ms-version" select="system-property('ms:version')"/>
          <xsl:choose>
            <xsl:when test="$ms-version = ''">XslTransform</xsl:when>
            <xsl:when test="starts-with($ms-version, 'v')">XslCompiledTransform</xsl:when>
            <xsl:otherwise>
              MSXML
              <xsl:value-of select="$ms-version" />
            </xsl:otherwise>
          </xsl:choose>
        </xsl:when>
        <xsl:otherwise>
          Unrecognized XSLT engine from
          '<xsl:value-of select="system-property('xsl:vendor')" />'
        </xsl:otherwise>
      </xsl:choose>
    </p>
  </xsl:template>
</xsl:stylesheet>

Print | posted on Tuesday, April 29, 2008 12:53 PM