[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: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 3 Jan 2003 17:09:40 GMT
template string parameter
> I suppose this is because the parameter is of type string, and the 
> select attribute requires a node set. How do I solve this?

this is a FAQ.
Some systems (saxon, and xalan for example) have an evaluate extension
that allows a string to be evaluated as an X{ath expression, however
there are more poratble alternatives.

In simple cases you can pass in a string used to make up
the expression, so instead of

  para-xpath=/root/data[@id='whatever'
...
 <xsl:apply-templates select="$para-xpath"/>

  para-id=whatever

 <xsl:apply-templates select="/root/data[@id=$para-id]"/>


Otherwise if you are calling XSLT from some API rather than the command
line it is usually possible to make the parameter have a value being the
node set itself rather than an Xpath taht selects the node set.
Typically you use some Xpath interface to a DOM to select teh node set
and then pass that in as the parameter, then your

<xsl:apply-templates select="$para-xpath"/>

would work.

> The key problem is that I need to transform a subset of a larger XML 
> stream, where the subset is defined through an XPath expression and all 
> this must happen within XSL in order to avoid cross-domain security 
> constrains in JavaScript.

hmm so the last possibility may not be avaolable to you.


>  Any recommendations welcome.

You could ask the XSLT WG to reconsider adding evaluate to xpath 2....

Or you can have a two pass approach, take the xpath expression from teh
source and generate a stylesheet that uses that expression, then run teh
generated stylesheet.

David



________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

 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.