Your basic mistake is to try and write this in "pull style" using xsl:for-each, xsl:if, and xsl:call-template. This is not the XSLT way of doing things, and its deficiencies become strongly apparent when you are handling mixed content, as here.
Read about template rules and xsl:apply-templates, and rewrite your code to use them. The solution will fall into place.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
|