[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: david_n_bertoni@xxxxxxxxxx
Date: Wed, 30 Apr 2003 14:30:22 -0700
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>

This creates a result tree fragment which is a copy of the FLDS element(s)
from that document.  Result tree fragments have some serious limitations in
XSLT 1.0:

   http://www.w3.org/TR/xslt#section-Result-Tree-Fragments

In particular, you cannot treat a result tree fragment as a node-set
without an extension function.  You probably want to do this instead:

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

This creates a node-set containing the nodes from the specified document.
You can use this just like a node set from the main source tree:

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

This assumes the FLDS elements have FLD element children.  That's just a
guess, since you didn't include a snippet from the file usr_member.xml.

By the way saying something like "it doesn't like the $ in the select
statement" is not very clear.  An exact error message is much more useful.

Dave


 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.