I am getting very strange results processing a particular page. Any ideas on how this behaviour is possible would be very much appreciated!
The page is XHTML. For some reason the transformer can both find and not find (?!) the <body> tag. Here are the templates (I've added obvious text debugging output).
<xsl:template match="html">
... process the head tag...
BEFOREBODYChoose
<xsl:choose>
<xsl:when test="body">
FOUNDBody
<xsl:for-each select="*"><xsl:value-of select="local-name()"/>, </xsl:for-each>
<xsl:apply-templates select="body"/>
</xsl:when>
<xsl:otherwise> <!-- create an empty body -->
CALLBODYBYNAME
<xsl:call-template name="body"/>
</xsl:otherwise>
</xsl:choose>
AFTERBODYChoose
</xsl:template>
<xsl:template match="body" name="body">
InBodyTemplate
...other stuff...
</xsl:template>
Most of the time this works great but for this one particular page, I get the following results.
BEFOREBODYChoose
FOUNDBody
head, body,
AFTERBODYChoose
Because it prints out "FOUNDBody" I know that it the when test for a child body node passed. Just to make sure, I even iterate through the children nodes and print out their names: "head, body". But then the apply-templates command FAILS TO WORK! The body template is never called.
So after all this detailed explanation, my question is, what could possibly be causing this? What sort of obscure circumstances might be causing it to not match the body template? Any ideas for tests to try or ways to change the XSLT to make it work would be very helpful.
Huge thanks in advance!
Brian
