The interaction of a style sheet with a data file can be a complex process, and style sheet errors might not always be obvious. This section provides troubleshooting advice for the style sheet author. Also see the XSL Debugger, a Web page that offers single-stepping through a style sheet.
If no errors are being reported, the problem is most likely an error in the style sheet design, which can be diagnosed and corrected by the style sheet author. Begin by testing that the root template of the style sheet is being executed, using the method outlined in Expected Template Is Not Being Used.
<xsl:template match="address"> !! inside address template !! <xsl:apply-templates select="zipcode"/> </xsl:template>
If the trace message appears in the output, the template is being executed, and the problem is likely that this <xsl:apply-templates> is not returning anything. For hints on diagnosing why the select pattern returns no results, see No Results from Select Pattern.
If the trace message does not appear, the problem could be that the match pattern is in error. Check the spelling and case of element and attribute names, and check that the full context for the match is actually present in the source data.
Also determine which <xsl:apply-templates> element should invoke the template and ensure that it is selecting the correct nodessee No Results from Select Pattern.
If the template uses the root pattern (/) and is not being called, check that no template later in the style sheet uses the root pattern or omits the match attribute (matching all nodes including the document root). If the style sheet is being executed against a node other than the document root, a template matching that element is used instead of the root template.
<xsl:template match="address"> <PRE><xsl:eval>xml</xsl:eval></PRE> <xsl:apply-templates select="zipcode"/> </xsl:template>
Comparing the actual XML data to the select pattern, spelling mistakes in element and attribute names can be found; for example, the data could show "zip-code" or "zipCode" as the correct element name. The context of the query can be checkedis "zipcode" a child of "address"? And the source data can also be checked for accuracydoes this "address" have a "zipcode"?
For complex patterns it is often helpful to progressively simplify the pattern to isolate the problem.
The correct namespace identifier for XSL is http://www.w3.org/TR/WD-xsl.
<template match="*"> <SPAN STYLE="background-color:yellow"> <xsl:attribute name="title"><<xsl:node-name/>></xsl:attribute> <xsl:apply-templates/> </SPAN> </xsl:template>
Add this template near the top of your style sheet so that it doesn't override templates that handle specific elements. This template will display a yellow background behind the content of any element without a specific template in existence. Running the mouse over the yellow areas will display a ToolTip showing which elements still need to be handled by templates.
Style sheet writing in this fashion almost becomes a gamecreate a template and more yellow disappears. By the time the yellow is gone, your style sheet is finished!
Also see these related topics: