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

Re: Convert a node-set to a string

Subject: Re: Convert a node-set to a string
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Fri, 25 Mar 2011 19:30:56 +0000
Re:  Convert a node-set to a string
On 25/03/2011 18:00, David Frey wrote:
Is it possible to get a string from a node-set in XSLT 1.1?
XSLT 1.1 was a working draft issued around 2001 and withdrawn soon after. Unfortunately during that short period the second edition of my book was published, and many people are still using it, so I suspect that's where you got the name from. But asking a question about a short-lived working draft from 10 years ago isn't helpful.

I suspect that the string you want is one that contains lexical XML markup. For that you need a serialize() function. It's available as an extension in some products, and there are implementations in pure XSLT, but it's not part of the standard library.

Michael Kay
Saxonica


Say I have some XML like this (completely made up):


<Inventory>
<Item price="10" quantity="7" name="widget"/>
<Item price="4" quantity="3" name="chair"/>
</Inventory>


And then I define a template like this:


<xsl:template match="Item">
<xsl:variable name="item" select="."/>
<xsl:variable name="len" select="ext:someExtensionFunction($item)"/>
<Length><xsl:value-of select="$len"/></Length>
</xsl:template>

The problem I think I am having is that my extension function expects a string, but I am passing it a node-set. I want to convert the node-set to a string rather than changing the extension function to accept a node-set as a parameter. Is this possible?

Thanks,
Dave

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.