This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Using the value of an element in a test condition


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]