[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

Subject: Re: Converting an attribute value into an XML fragment
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Mon, 9 Apr 2001 23:42:58 +0100
escaping xml attribute value java
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="&lt;section header=&quot;no&quot;&gt;Testing
> testing&lt;/section&gt;introhunk&lt;br/&gt;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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.