[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: MSXML, xsl:copy, XML Output and BR tags.

Subject: Re: MSXML, xsl:copy, XML Output and BR tags.
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Fri, 6 Apr 2001 08:59:01 +0100
xsl copy xml
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.