xsl-list
[Top] [All Lists]

Re: [xsl] Convert a node-set to a string

2011-03-25 14:31:14
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>