This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

How do you change markup to text in XSLT?


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">
  &lt;<xsl:value-of select="name()"/>&gt;
    <xsl:apply-templates mode="out"/>
  &lt;/<xsl:value-of select="name()"/>&gt;
</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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]