Previous | Next | Indexes
Zvon > Tutorials > XSLT 2.0 Tutorial > Errors (4/6) >

Recoverable dynamic errors

A transformation can recover from some dynamic errors. Such errors are called recoverable dynamic errors.

Usage of matching templates with the same priority represents the most common type of recoverable errors. Rules for recovery from these errors is given in the specification. In the case of multiple matching templates it is used the one which occurs last in the stylesheet. Be aware that this behavior is optional, a processor may terminate transformation if a recoverable dynamic error occurs.

XSLT

      <xsl:stylesheet
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  version="2.0">
            <xsl:output  method="xml"
                        indent="yes"
                        omit-xml-declaration="yes"/>

            <xsl:template  match="/aaa">
                  <xsl:apply-templates  select="*"/>
            </xsl:template>

            <xsl:template  match="aaa/bbb/ccc">
                  <xsl:value-of  select="."/>
            </xsl:template>

            <xsl:template  match="bbb/ccc">
                  <xxx>
                        <xsl:value-of  select=". * 10"/>
                  </xxx>
            </xsl:template>

      </xsl:stylesheet>
XML

      <aaa>
            <bbb>
                  <ccc>12</ccc>
            </bbb>
      </aaa>
Output

      <xxx>120</xxx>

Error:


recoverable error - XTRE0540
Ambiguous rule match for /aaa/bbb[1]/ccc[1] Matches both "bbb/ccc" on line L of file F and "aaa/bbb/ccc" on line L of file F


Previous chapter: Built in Types
Next chapter: Use When
Previous page: Dynamic errors
Next page: Explicit raising of errors