This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
How do you change markup to text in XSLT?
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] How do you change markup to text in XSLT?
- From: "Andrew Kane" <akane at opentext dot com>
- Date: Thu, 6 Sep 2001 10:52:45 -0400
- Reply-To: xsl-list at lists dot mulberrytech dot com
Purpose: I was trying to put an XML subtree into an attribute, but it seemed
like the default in XSLT was to extract the text from the subtree (similar
to an xsl:value-of). I wanted the tags in there as well. Basically it
boiled down to not being able to convert an XML subtree (markup) into text.
I found some information on a tread on this list, and in the FAQ (see end of
message for links), but it seemed to say you couldn't do it. If you change
the markup to be text in the input (IE put it in a CDATA section) it works,
but this doesn't allow dynamic XML subtrees...
The only generic way I can see right now is to reconstruct the XML using
templates, something like:
<xsl:template match="*" mode="out">
<<xsl:value-of select="name()"/>>
<xsl:apply-templates mode="out"/>
</<xsl:value-of select="name()"/>>
</xsl:template>
With added functionality for outputting what you want (attributes, comment
nodes, command nodes, etc).
This is a horrible way to do it, is there another better/easier way?
Cheers,
Andrew.
Thread on XSL List:
http://www.biglist.com/lists/xsl-list/archives/199912/threads.html#00281
FAQ: http://www.dpawson.co.uk/xsl/sect2/N1553.html#d84e357
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list