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

Executing variable XPath queries in XSLT

Subject: Executing variable XPath queries in XSLT
From: "Joseph Fourness" <josephf@xxxxxxxxxxx>
Date: Fri, 22 Jun 2001 08:53:26 -0700
xslt variable xpath
Hello,
 
I have a source document that looks like the following:
<rule>
<expression>%/PageContent/session/userid</expression>
<condition>eq</condition>
<expression>112314</expression>
</rule>
 
As you can see I'm trying to encode rules and logic into an XML file and
by using XSLT evaluate these rules.  The % symbol denotes an XPath
expression that needs to be executed against an XML file.  I'm getting
this as a variable as follows:
 
<xsl:variable name="xpath-query"
select="substring-after(rule/expression[1], '%')"/>
 
And I would like to then execute this query using $xpath-query in a
select statement.  I would like to do this entirely in XSLT using no
extension mechanisms.  I'm wondering if there are any tricks, known ways
to execute these kinds of expressions.  The methods I've explored so far
are:
1) Pipelining, using two XSLTs the first one to pre-process the XSLT and
convert all %expressions into XPath queries.  The second one to execute
this new XSLT (with the XPaths already built-in)  This works fine, but
is quite tricky and I was hoping to do this in one XSLT.
2) Using <msxsl:script> MSXML extension mechanism.  Writing some simple
JavaScript I instantiate the MSXML parser and use it to process the
XPath query and return a result node-set.  This solution works and seems
to have no problems, but it ties me to MSXML and I would prefer to stay
within the realm of standard XSLT (we are precompiling our XSLTs and
find that calling extension mechanisms is a small performance hit.)
 
I've searched the FAQs and the resources on the internet, but to no
avail.  Hopefully there is some cool way to do this.  (It should be
possible, I think, but I can't think of anything off hand...)
 
Thanks for your help, I greatly appreciate it!
 
Joe Fourness

 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.