using AND operator

Here should go questions about transforming XML with XSLT and FOP.
gungy
Posts: 7

using AND operator

Sat Jun 02, 2012 5:16 am

hiya,

how can i get two recursive calls in my template to evaluate my constraint using the AND operator?

xml file structure:

<filterML>
<constraint>
<and> <!-- 2 conditions -->
<operator operation="="> <!-- condition1: get all subjects evaluatung to chemistry -->
<input>subject</input>
<value>chemistry</value>
</operator>
<operator operation="&lt;"> <!-- condition2: get all age < 70 -->
<input>age</input>
<value>70</value>
</operator>
</and>
</constraint>
</filterML>


stylesheet:

<xsl:template name="evaluateFilterML">
<xsl:param name="operator" />
<xsl:param name="input" />
<xsl:param name="value" />
<xsl:choose>
<xsl:when test="$operator = 'equal'">
<xsl:value-of select="$input = $value"/>
</xsl:when>
<xsl:when test="$operator = 'not equal to'">
<xsl:value-of select="$input != $value"/>
</xsl:when>
<xsl:when test="$operator = 'less than'">
<xsl:value-of select="$input &lt; $value"/>
</xsl:when>
<xsl:when test="$operator = 'greater than'">
<xsl:value-of select="$input &gt; $value"/>
</xsl:when>
</xsl:choose>
</xsl:template>

<xsl:template match="/">
<xsl:param name="currentyear" select="2012" />
<xsl:call-template name="evaluateFilterML">
<xsl:with-param name="operator" select="//filterML/constraint/and/operator[@operation='=']" />
<xsl:with-param name="input"> <!-- recursively evaluate input value -->
<xsl:apply-templates select="//citizensOfBritik/citizen/education/qualification[subject='chemistry']" />
</xsl:with-param>
<xsl:with-param name="value"> <!-- recursively evaluate condition value -->
<xsl:apply-templates select="($currentyear - (substring((dob),1,4))) &lt; 70" />
</xsl:with-param>
</xsl:call-template>
</xsl:template>


--- so i need my stylesheet to output:
<xsl:apply-templates select="//citizensOfBritik/citizen/education/qualification[subject='chemistry']" /> AND <xsl:apply-templates select="($currentyear - (substring((dob),1,4))) &lt; 70" />

Return to “XSLT and FOP”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 0 guests