Re: MSXML, xsl:copy, XML Output and BR tags.
Hi Paul, > I realise this is probably parser implementation specific. Any ideas > how can I make the XSL transformation leave the <br /> as it is?? I > really do not want to use <xsl:output method="html"> since I wish to > have the data preserved as XHTML for later manipulation... I tried a template like this with MSXML3: <xsl:template match="br"> <xsl:copy><xsl:copy-of select="@*|node()" /></xsl:copy> <xsl:copy><xsl:copy-of select="@*" /></xsl:copy> <xsl:copy-of select="." /> <xsl:element name="br" /> <br /> </xsl:template> This produced: <br></br> <br /> <br /> <br /> <br /> So it appears that it's only by trying to add some content in an xsl:copy that you get open-tag/close-tag syntax. What I'd recommend is either copying everything in the subtree you want to copy with xsl:copy-of (which is quicker than doing it recursively anyway) or adding a template that matches *empty* elements and doesn't try to copy any content into them: <xsl:template match="*[not(node())]"> <xsl:copy><xsl:apply-templates select="@*" /></xsl:copy> </xsl:template> In some ways you're lucky - other processors don't have a space before the / in the br element, which is another syntax that confuses HTML browsers, and has to be worked around by adding an attribute as Wendell suggested. But these problems are why there's a need for an 'xhtml' output method (as in Saxon), which might come along in XSLT 2.0 and is something I intend to include in EXSLT when I have a few moments. I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format