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

Re: Evaluating an expression as an XPath expression

Subject: Re: Evaluating an expression as an XPath expression
From: Trevor Nash <tcn@xxxxxxxxxxxxx>
Date: Sat, 22 Dec 2001 14:58:17 +0000
Re:  Evaluating an expression as an XPath expression
>In my real example (which didn't have the typo), I have multiple Expr
>elements that I must process. By converting the result to a string, don't I
>lose the ability to process it using a for-each? You said that I can "switch
>it back by using a global variable to hold the root and another
>for-each", at what point do I convert to string?
>
If you have more than one node, then yes you need to convert to a
string within the for-each.  You then need an inner for-each to switch
the context back, like this:

First a global variable
  <xsl:variable name="root" select="/" />

Then modify your original attempt by inserting a for-each as indicated
by the >>>:

<xsl:for-each select="document(VC.xml')//Expr">
	  <xsl:variable name="expr">
		<xsl:value-of select="."/>
	</xsl:variable> 
>>>	<xsl:for-each select="$root">
>>>		<!-- context is now the main input document -->
		<xsl:if test="saxon:eval(saxon:expression($expr))">
				<p>Found it: <xsl:value-of
select="$expr"/></p>
			</xsl:if>
>>>	</xsl:for-each>
</xsl:for-each>

Regards,
Trevor Nash
--
Traditional training & distance learning,
Consultancy by email

Melvaig Software Engineering Limited
voice:     +44 (0) 1445 771 271 
email:     tcn@xxxxxxxxxxxxx

 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.