using AND operator
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 7
- Joined: Tue May 22, 2012 5:07 pm
using AND operator
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="<"> <!-- 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 < $value"/>
</xsl:when>
<xsl:when test="$operator = 'greater than'">
<xsl:value-of select="$input > $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))) < 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))) < 70" />
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="<"> <!-- 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 < $value"/>
</xsl:when>
<xsl:when test="$operator = 'greater than'">
<xsl:value-of select="$input > $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))) < 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))) < 70" />
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service