Re: [xsl] preserving comments in xml through xslt

Subject: Re: [xsl] preserving comments in xml through xslt
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 26 Jan 2001 16:09:16 GMT
> How do I refer to the comments in the first XML to be sure that they appear
> in the finished XML? 


match="comment()"


>  They seem to be dissappearing.
They will anyway with some parsers (which are allowed to throw away
comments) (But I don't think this applies to msxsl)

> Additionally the root node of the input xml has an xmlns attribute 
Two errors or terminology there.
The root node is not the top level element it is the conceptual root of
the tree corresponding to the whole document, and not to any explicit
markup. Root nodes can't have attributes. Also to a namespace aware
system xmlns:x= is _not_ an attribute. In Xpath they do not produce
attribute nodes, but rather result in namespace nodes.
You can't generate namespace declarations using xsl:attribute.

To get the namespace copied, since you are using xsl-element, you just
need to use the remaining attribute of that:

instead of

 name="{translate(name(), 'A...

you could use something like:

 name="{translate(name(), 'A...
 namespace="namespace-uri())

David

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


Current Thread