hi michael,
sorry for being unclear, i'll start again,
1. YES, im using xslt 1.0 and my citizen data belongs in the same xml file that has my filter i.e.
<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>
.
.
.
<rest of my main 'citizen' xml content sits here>
2. my objective is to get my stylesheet to evaluate the above filterML constraints, so i have a template names 'evaluatefilterML', which consists of my operations, my input and value.
Also, within the same stylesheet, i have declared two match templates (which is incorrect as i explain later) that trigger the evaluation, i.e. they aim to evaluate each operator or condition i.e. 'get me citizens that have studied subject chemistry' and 'get me citizens below age 70', but of course as you can see they are not joined to perform an 'AND'.
-so my trouble is: how do i declare my match template - rather than having two separate ones - that does an AND operation on both conditions in the one go?
<xsl:template match="*/@operation">
<xsl:param name="currentyear" select="2012" />
<xsl:call-template name="evaluateFilterML">
<xsl:with-param name="operation" select="//filterML/constraint/and/operator[@operation='=']" />
<xsl:with-param name="input"> <!-- recursively evaluate input value -->
<xsl:apply-templates select="//citizensOfBritik/citizen/education/qualification/subject" />
</xsl:with-param>
<xsl:with-param name="value"> <!-- recursively evaluate condition value -->
<xsl:apply-templates select="//citizensOfBritik/citizen/education/qualification[subject='chemistry']" />
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<xsl:template match="operator">
<xsl:param name="currentyear" select="2012" />
<xsl:call-template name="evaluateFilterML">
<xsl:with-param name="operation" select="//filterML/constraint/and/operator[@operation='<']" />
<xsl:with-param name="input"> <!-- recursively evaluate input value -->
<xsl:apply-templates select="//citizensOfBritik/citizen/dob" />
</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>
also, when i execute stylesheet above in that state, saxon returns error against the line: <xsl:apply-templates select="($currentyear - substring((dob),1,4)) < 70" />
error: "the value is not a node-set" ??
hope that has made things clearer...
thank you.
|