|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Converting an attribute value into an XML fragment
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








