RE: [xsl] preserving comments in xml through xslt

Subject: RE: [xsl] preserving comments in xml through xslt
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Fri, 26 Jan 2001 16:03:28 -0000
> How do I refer to the comments in the first XML to be sure
> that they appear
> in the finished XML?  They seem to be dissappearing.

You can generate comments using <xsl:comment>, or using <xsl:copy> on a
comment node. Try

<xsl:template match="comment()"><xsl:copy/></xsl:template>


> Additionally the root node of the input xml has an xmlns
> attribute which doesn't want to show up in the finished xml.

Namespace nodes from the source document will be copied if you use
<xsl:copy> on the element node (which you aren't doing) or a literal result
element (which you aren't using). You are using <xsl:element name="{ --
string-expression -- }", if this expression returns a name containing a
prefix, the prefix must be declared by a namespace declaration _in the
stylesheet_.

Mike Kay


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


Current Thread