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

RE: Easy one! variables & documents)

Subject: RE: Easy one! variables & documents)
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Thu, 1 May 2003 09:25:26 +0100
RE:  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>

Why are you making a copy of (parts of) the document? The original is
just as good. Use:

 <xsl:variable name="xmTmplt"

> <xsl:template name="TEMP">
> <hr/>
>  <xsl:for-each select="xmTmplt/FLD">
>     <xsl:text>testing..</xsl:text>
>  </xsl:for-each>
> <hr/>
> </xsl:template>

You then want $xmTmplt/FLD.

This works when you rewrite the variable as above, because $xmTmplt is
now a node-set. As you wrote it, it was a result-tree-fragment, and in
1.0 you can't use path expressions to index into a result tree fragment.

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


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.
First Name
Last Name
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.