Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Home » Tip Bank » XML » XSLT
Language: XML
Expertise: Intermediate
Oct 2, 2006



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Compatible Stylesheets with xsl:fallback

The following code is an example of how to use the xsl:fallback element to achieve full compatibility between XSLT different versions.

Imagine that some future 5.0 version of XSLT implements an <xsl:condition> element. Processors using earlier versions of XSLT wouldn't understand that element, so you can include an <xsl:fallback> element to enable the processor to continue, using elements it understands from an earlier version of XSLT.

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

<xsl:for-each select="***XPath expression***" >
   <xsl:condition test="***any condition***">
      XSLT 5.0 - OK - XSLT 5.0
            <xsl:if test="***any condition***">
               XSLT 1.0 - OK - XSLT 1.0
A processor using XSLT 1.0/2.0 will fail to recognize the <xsl:condition> element, but because it contains an <xsl:fallback> element the older processor will evaluate the <xsl:if> test in the <xsl:fallback> element instead of throwing an error.

Leonard Anghel
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date