Subject: RE: [xsl] 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 |
> 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] convert an attribute's va, Gunther Schadow | Thread | Re: [xsl] convert an attribute's va, Jeni Tennison |
RE: [xsl] Let's face it: side effec, Michael Kay | Date | Re: [xsl] Matching on text after em, Jeni Tennison |
Month |