When the unit tests are not in the stylesheet being tested, the matching of 'match' attributes is very sensitive to whitespace differences between the pattern in the stylesheet and the copy in the external unit test file.
The generate-tests.xsl stylesheet is also not very informative when no match is found.
This patch attempts to correct both.
Regards,
Tony Graham.
--- ant-xslttest-1.0.0/main/src/xslt/generate-tests.xsl (revision 34)
+++ ant-xslttest-1.0.0/main/src/xslt/generate-tests.xsl (revision 39)
@@ -39,6 +39,6 @@
<xsl:key name="matching-templates"
match="xsl:template[@match]"
- use="concat('match=', @match, '+',
- 'mode=', @mode)" />
+ use="normalize-space(concat('match=', @match, '+',
+ 'mode=', @mode))" />
<xsl:template match="/">
@@ -340,8 +340,25 @@
</xsl:when>
<xsl:otherwise>
- <xsl:sequence select="key('matching-templates',
- concat('match=', $xslt/@match, '+',
- 'mode=', $xslt/@mode),
- $stylesheet)" />
+ <xsl:variable name="match"
+ select="key('matching-templates',
+ normalize-space(concat('match=',
+ $xslt/@match,
+ '+mode=',
+ $xslt/@mode)),
+ $stylesheet)"
+ as="element()*"/>
+ <xsl:if test="not($match)">
+ <xsl:message>
+ <xsl:text>No match for 'match="</xsl:text>
+ <xsl:value-of select="$xslt/@match"/>
+ <xsl:if test="$xslt/@mode">
+ <xsl:text>" and 'mode="</xsl:text>
+ <xsl:value-of select="$xslt/@mode"/>
+ </xsl:if>
+ <xsl:text>" in stylesheet </xsl:text>
+ <xsl:value-of select="base-uri($stylesheet)"/>
+ </xsl:message>
+ </xsl:if>
+ <xsl:sequence select="$match"/>
</xsl:otherwise>
</xsl:choose>