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

RE: convert an attribute's value to a text node?

Subject: RE: convert an attribute's value to a text node?
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Tue, 3 Dec 2002 10:03:34 -0000
convert attribute to text
> Hi, I am in the process of converting my heavy uses of Saxon 
> and it's extensions to more standard XSLT 2.0 + XPath 2.0 and 
> here is the one problem I have left:
> 
> I need to convert a string to a text-node. More specifically, 
> I need to convert the value of an attribute to a text-node, 
> because I have special templates that expect text-nodes.
> 
> In the old days I used:
> 
>     saxon:node-set(string(@att))
> 
> which would give me back a text-node.
> 
> Note that saxon's implementation of exsl:node-set would not 
> allow a string argument, but saxon:node-set would, and would 
> do exactly what I needed.

Actually (for the record), I don't think Saxon ever returned a text node
from this function. In Saxon 6.3 and 6.4 a string argument was rejected.
In Saxon 6.5 a string argument was accepted, but the result was a
document node that owned a text node whose value was the supplied
string.

The exslt common:node-set() function appears to have changed at some
stage and now specifies that with a string argument, the result should
be a text node. Saxon has never implemented this version of the EXSLT
specification (and I don't recall seeing any discussion of the change -
change control is not one of EXSLT's strong points).

The most portable way to get a text node from a string, if you really
want one, is

<xsl:variable name="tree">
   <xsl:value-of select="@att"/>
</xsl:variable>
... exslt:node-set($tree/text()) ...

But it does strike me as a somewhat odd way of doing things.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 


 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.