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

Re: Using parameter in for-each select - newbie questi

Subject: Re: Using parameter in for-each select - newbie question
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Mon, 26 Mar 2001 16:15:17 +0100
chris theisen
Hi Chris,

>       <xsl:for-each select="//$table">
>          <xsl:call-template name="create-csv"/>
>       </xsl:for-each>

Variables aren't text macros - you can't use a variable reference to
insert some text into an XPath.  Basically, this is illegal XPath
expression syntax, which is why you're getting the error.

You're aiming here for a dynamic XPath to pick the elements that you
want.  Rather than trying to construct the XPath dynamically, you can
pick all the elements and filter them (using a predicate) to choose
only those whose name is the same as the value of the $table
parameter, i.e.:

  //*[local-name() = $table]

If you start having $table hold more sophisticated XPaths than just
the name of an element, then you may have to use an extension function
that gives dynamic evaluation of strings as XPaths, such as
saxon:evaluate():

  saxon:evaluate(concat('//', $table))

I don't know of an equivalent extension function in xt, I'm afraid.

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 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.