This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Using the value of an element in a test condition
- From: "Roger L. Costello" <costello at mitre dot org>
- To: XSL-List at lists dot mulberrytech dot com
- Cc: costello at mitre dot org
- Date: Thu, 07 Feb 2002 12:15:38 -0500
- Subject: [xsl] Using the value of an element in a test condition
- Organization: The MITRE Corporation
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Folks,
I have an XML document that contains conditions which must be tested in
another XML document. For example, here's document 1:
<root>
<condition>not(A and B)</condition>
<condition>A = 'hello'</condition>
</root>
Here's document 2:
<root>
<A>hello</hello>
</root>
I need to test document 2 against each condition (which is data) in
document 1.
Suppose that I create a variable, cond, whose value is the first
condition listed above:
cond
|--------------|
| |
| not(A and B) |
| |
|--------------|
Suppose that my current context is document 2. I cannot simply do this:
<xsl:if test="$cond">
Document 2 meets this condition: <xsl:value-of select="$cond"/>
</xsl:if>
The xsl processor will simply test to see if the cond variable has a
value. That's not what I want. I want the xsl processor to evaluate
the value of cond. So, I want something like this:
<xsl:if test="evaluate($cond)">
Document 2 meets this condition: <xsl:value-of select="$cond"/>
</xsl:if>
Of course I made up this evaluate() function. Is there something
equivalent in xslt/xpath? In other words, how do I solve this problem?
/Roger
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list