This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: MSXML, xsl:copy, XML Output and BR tags.
- To: "Paul Hammond" <paul at crazyturtle dot com>
- Subject: Re: [xsl] MSXML, xsl:copy, XML Output and BR tags.
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Fri, 6 Apr 2001 08:59:01 +0100
- CC: XSL-List at lists dot mulberrytech dot com
- Organization: Jeni Tennison Consulting Ltd
- References: <LNBBIEMOBMIACMGAMJAMKEPHDPAA.paul@crazyturtle.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
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