Forward compatibility

XSLT processors developed to support XSLT version 1.0 should be able to cope with stylesheets developed to conform to a later version of this standard. When the stylesheet contains a Version attribute with a value other than '1.0', the processor should adopt a 'forwards-compatible' mode to help it cope with unexpected features.

When the processor has adopted this mode, it is given permission to ignore any top-level elements that it does not recognize:

<xsl:stylesheet version="1.3">
  <xsl:import.../>
  ...
  <xsl:new-feature /> <!-- 1.0 processors IGNORE -->
  ...
  <xsl:template>...</xsl:template>
  ...
</xsl:stylesheet>

Also, any unexpected elements appearing within a template do not cause an error. It is possible to step over such elements by testing the version of XSLT that the processor understands. The system-property() function can be used to request the supported version number by passing the parameter value 'xsl:version' to it (as described in Chapter 20). The return value can then be compared with the version that supports the feature:

<xsl:template>
  <xsl:if test="system-property('xsl:version') >= 1.2">
    <xsl:new-template-feature />
  </xsl:if>
  ...
</xsl:template>

Alternatively, the 'fallback' feature described above can be used:

<xsl:template>
  <xsl:new-template-feature>
    <xsl:fallback>...</xsl:fallback>
  </xsl:new-template-feature>
  ...
</xsl:template>

Finally, unknown attributes are simply ignored.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset