[xsl] MSXML, xsl:copy, XML Output and BR tags.

Subject: [xsl] MSXML, xsl:copy, XML Output and BR tags.
From: "Paul Hammond" <paul@xxxxxxxxxxxxxxx>
Date: Thu, 5 Apr 2001 14:29:17 +0100
Hi all,

I have an annoying problem that I can't seem to solve - any help

I am using MSXML3 and doing the transformation from within code using the
DOM.  I have a source XML doc which contains data I later wish to render in
a browser that includes a number of <br /> tags.  When I transform the data
using a simple identity transformation to copy the entire tree, all of the
<br /> tags get changed to <br></br> by the <xsl:copy> I am using.
Actually, the same thing seems to happen for all tags like this (such as
<img /> etc.)

Obviously, <br></br> is still valid XML, but IE and Netscape both render
these as TWO breaks in the browser, not the single one that I require.

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...

Example Source Doc (the simplest one possible!!):
  <?xml version="1.0"?>
  <filecontent><br /></filecontent>

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
  <xsl:output method="xml" />
  <xsl:template match='@* | node()'>
    <xsl:copy><xsl:apply-templates select='@* | node()'/></xsl:copy>

As an experiment I added <xsl:template match="br"><br /></xsl:template> to
the stylesheet and this worked fine.  Again, if I can help it, I'd rather
not have to add a template for each "problem" HTML tag...!

Thanks in advance,

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread