Subject: Re: [xsl] Converting an attribute value into an XML fragment From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Mon, 9 Apr 2001 23:42:58 +0100 |
Hi Joel, > I am trying to convert the value of an attribute into an XML fragment in > XSL. Here is what my XML looks like: > > <row > title="XMLContent" > value="<section header="no">Testing > testing</section>introhunk<br/>blah" > /> > > So, when converted into an XML fragment, row/@value should look like this: > > <section header="no">Testing testing</section>introhunk<br/>blah As far as the processor is concerned, the value of the 'value' attribute is just a string. It can't recognise the fact that this string is supposed to be serialised XML. So given this XML source, the only sensible option is to use disable-output-escaping to make the processor forget about the fact that it's supposed to be outputting XML, and just make it output precisely the string that you want - a less than sign followed by the string 'section' and so on. You can do this with: <xsl:value-of disable-output-escaping="yes" select="row/@value" /> (Note - the insensible option is to write an XML parser in XSLT ;) Disabling output escaping like this is problematic firstly because you have to be careful that you are actually producing well-formed XML when you use it, and secondly because processors are not guaranteed to support it. You would be a lot better off if the value of the row was stored actually as XML within the row element: <row title="XMLContent"> <section header="no">Testing testing</section>introhunk<br />blah </row> Then you could simply do: <xsl:copy-of select="row/node()" /> I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Converting an attribute value, Joel P Thornton | Thread | [xsl] inserting space in xsl:value-, Java XML |
[xsl] Generating multi-level recurs, Paul Foege | Date | Re: [xsl] Re-visiting a Child Node, Jeni Tennison |
Month |