[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Transforming an XML structure into a string

Subject: Re: Transforming an XML structure into a string
From: Ben Senior <ben@xxxxxxxxxxxxx>
Date: Tue, 11 Apr 2006 16:15:44 +0200
Re:  Transforming an XML structure into a string
Here's a solution which works ... but can it be done more elegantly?

<xsl:template match="*" mode="entities">&lt;<xsl:value-of select="name()"/><xsl:for-each select="@*">&#160;<xsl:value-of select="name()"/>="<xsl:value-of select="."/>"</xsl:for-each>&gt;<xsl:apply-templates mode="entities"/>
</xsl:template>


Ben Senior wrote:

*bang* *bang* *bang* goes my head against the desk.

We are passing a fragment of XML into a template as a param.

In this case the XML fragments look something like : <call function="analogous">base_colour=<value target_id="base_colour"/>,choice=1</call>

We are aiming to store this string in the value attribute of a html hidden input form so we would like to map all angular brackets to their &lt; &gt; equivalents, and & to &amp; etc.

String functions like translate or substring work on the text node parts (like "base_colour=" and "choice=1") but do not process the nodes like <call or <value.

Can we do a "toString" on this XML fragment or are we approaching this the wrong way around...

Many thanks for you time,

B&A

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.