RE: [xsl] Problems copying elements recursively.

Subject: RE: [xsl] Problems copying elements recursively.
From: "Passin, Tom" <tpassin@xxxxxxxxxxxx>
Date: Thu, 6 Feb 2003 17:04:59 -0500
[ Imrran Wahid ]
> I've been trying with this piece for a while but still
> cannot get it right.
> I am trying to copy a certain node-tree from the xml
> document via xsl style sheet. Basically i would like
> the output to be an xml representation of the node
> tree.

1)  If you just want to copy it, just use xsl:copy-of to copy the whole
nodeset of interest.

2) It appears you are trying to build up elements by inserting "<" and
">" signs (example: "<xsl:text></</xsl:text>").  DO NOT EVEN THINK OF
DOING THIS.  Plus, you do not need to do it since xslt will do what you
want (but you have to explain it clearly first).  With xslt, you build a
tree first, and then the angle brackets get put in by the serializer
when you serialize the tree to the output.  Attempts to circumvent this
process will tend to get you in trouble, and even when they work lead to
misunderstanding of how the xslt system is designed to work. (Look in
the FAQs for "disable-output-escaping" for more on this).

If you want to create an element with a name extracted from the source,
you can use xsl:element or, if you already know the name, just write the
whole element with literal tags:

<name1><xsl:value-of select='theContent'/></name1>

for example.


Tom P

 XSL-List info and archive:

Current Thread