Yet another reason to use Saxon

Testing a sample stylesheet today, I've discovered that Saxon reports a lot of recoverable errors that are silently ignored by other XSLT implementations (MSXML or Gecko).For example, when faced with this stylesheet ...
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 
<xsl:template match="data">
  <xsl:apply-templates /></xsl:template>
 
<xsl:template match="a">
  A: <xsl:value-of select="text()" />
</xsl:template>
 
<xsl:template match="a">
  B: <xsl:value-of select="text()" />
</xsl:template>
 
</xsl:stylesheet>
... Saxon would report ambiguous rule match (even documenting the input element that caused the error and the source line number), whereas all the other XSLT translators would silently produce "best effort" results. In fact, the stylesheet had a typo, the last template should match the b element and I would have lots of problems detecting that with MSXML (for example).

No comments:

Post a Comment