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

RE: string parameter to node-set?

Subject: RE: string parameter to node-set?
From: "Passin, Tom" <tpassin@xxxxxxxxxxxx>
Date: Fri, 3 Jan 2003 12:04:34 -0500
xslt string parameter
[bernd@xxxxxxxxxxxxx]

> I am at a loss, and wonder if anybody can help: I pass two parameter 
> from Javascript into XSLT, the URI of an XML document and an XPath 
> expression. Both parameters are strings as far as JavaScript 
> is concerned.
> 
> I can load the XML data with document($para-xml) just fine:
> 
>     <xsl:param name="para-xml"/>
>     <xsl:param name="para-xpath" select="'/'"/>
> 
>     <xsl:template match="/">
>         <xsl:apply-templates select="document($para-xml)" 
> mode="transform"/>
>     </xsl:template>
> 
> Next, I would like to use the XPath expression to select the 
> node(s) the 
> subsequent transformation should apply to. Something along 
> the lines of 
> this:
> 
>     <xsl:template match="/" mode="transform">
>         <xsl:apply-templates select="/root/data[@id='whatever']"/>
>     </xsl:template>
> 
> That works great, too. However, I find myself unable to using 
> the XPath 
> parameter instead of the constant XPath expression, as in
> 
>     <xsl:template match="/" mode="transform">
>         <xsl:apply-templates select="$para-xpath"/>
>     </xsl:template>
> 
> I suppose this is because the parameter is of type string, and the 
> select attribute requires a node set. How do I solve this?

You cannot use a parameter or variable in a path expression - not in
xslt 1.0.  For a general xpath expression, your best bet is probably to
have your stylesheet create another stylesheet that contains the desired
xpath expression, then run the second one to do the actual
transformation that you want.

Cheers,

Tom P


 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.