RE: [xsl] Easy one! variables & documents)

Subject: RE: [xsl] Easy one! variables & documents)
From: "Martinez, Brian" <brian.martinez@xxxxxxxxxxx>
Date: Wed, 30 Apr 2003 15:29:48 -0600
> From: Karl J. Stubsjoen [mailto:karl@xxxxxxxxxxxxx]
> Sent: Wednesday, April 30, 2003 3:07 PM
> Subject: [xsl] Easy one! variables & documents)
> 
> 
> I am reading an external xml document into a variable at the 
> very top of my
> stylesheet (is this legal?)... later I loop through this 
> document.. but I
> don't know how to access the variable in a select statement 
> (it doesn't like
> the $ in the select statement).  Here's the code:
> 
> <xsl:variable name="xmTmplt"><xsl:copy-of
> select="document('usr_member.xml')//FLDS"/></xsl:variable>

This creates $xmTmplt as a result tree fragment.  Any time the contents of
xsl:variable contain a template-body, you get an RTF, which cannot be used
in XPath expressions as anything but a string unless you use the node-set()
extension function.

A much better way to construct this variable is to use:

<xsl:variable name="xmTmplt" select="document('usr_member.xml')//FLDS"/>

That's still very expensive, especially if it's a large document, but it
will return the desired node-set and you won't have to resort to extension
functions, even though node-set() is supported by nearly all XSLT
processors.

hth,
b.

| brian martinez                           brian.martinez@xxxxxxxxxxx |
| lead gui programmer                                    303.708.7248 |
| cheap tickets, part of trip network                fax 303.790.9350 |
| 6436 s. racine cir.                             englewood, co 80111 |
| cendant travel distribution services   http://www.cheaptickets.com/ |

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread