xsl-list
[Top] [All Lists]

Re: xslt 2, forward compatibility mode.

2003-03-04 18:30:02
Michael Kay wrote:
Suppose that XSLT 3.0 has just been published, and it includes a new
<xsl:perform-magic> instruction, which is implemented in Saxon version
19.2, but not yet in MSXML6. You want to invoke this instruction when
your stylesheet is running under Saxon, but when running under MSXML6,
you just want to leave out that part of the output. So you write:

<xsl:template match="thing" version="3.0">
  <xsl:perform-magic select="magic-dust">
    <xsl:fallback>Sorry, Microsoft don't do magic</xsl:fallback>
  </xsl:perform-magic>
</xsl:template>

Specifying version="3.0" means that the Microsoft processor (or any XSLT
1.0 or 2.0 processor) is obliged to execute the xsl:fallback
instruction. If you had said version="1.0" or version="2.0", then the
processor would instead have thrown a static error saying that there is
no such instruction as xsl:perform-magic.

That does not work.

% cat fallback.xsl
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

  <xsl:output method="xml" indent="yes"/>

  <xsl:template match="/" version="3.0">
    <result>
      <xsl:perform-magic select="magic-dust">
        <xsl:fallback>Sorry, we don't do magic</xsl:fallback>
      </xsl:perform-magic>
    </result>
  </xsl:template>

</xsl:stylesheet>

% saxon dummy.xml fallback.xsl
Error at xsl:template on line 7 of file:/opus/home/mike/xml/test/fallback.xsl:
  Attribute version is not allowed on this element
Error at xsl:perform-magic on line 9 of 
file:/opus/home/mike/xml/test/fallback.xsl:
  Unknown XSLT element: perform-magic
Transformation failed: Failed to compile stylesheet. 2 errors detected.

Mike

-- 
  Mike J. Brown   |  http://skew.org/~mike/resume/
  Denver, CO, USA |  http://skew.org/xml/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



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