Subject: RE: Evaluating an expression as an XPath expression
From: Mark Feblowitz <mfeblowitz@xxxxxxxxxxxxxxxx>
Date: Sat, 22 Dec 2001 19:56:27 -0500
|
Yup - that did it!
And thanks. The different document contexts were something I never would
have gotten.
Mark
----------------------------------------------------------------------------
----
Mark Feblowitz [t] 617.715.7231
Frictionless Commerce Incorporated [f] 617.495.0188
XML Architect [e]
mfeblowitz@xxxxxxxxxxxxxxxx
400 Technology Square, 9th Floor
Cambridge, MA 02139
www.frictionless.com
-----Original Message-----
From: Trevor Nash [mailto:tcn@xxxxxxxxxxxxx]
Sent: Saturday, December 22, 2001 9:58 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: 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
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|