Hi All,
After having worked with XSL for months I thought I am able do everything
but I admit I am stuck with a simple problem.
Here is the xml file
<parent>
<child>
<child>
<child>
</parent>
<parent>
<child>
<child>
<child>
</parent>
xsl style sheet is structured in the following way (simplified version,
omitted xsl:)
<for-each select="parent">
<td>
<call-template name="color">
<value-of select="parent">
</td>
<apply-templates select="child">
</for-each>
<template match="child">
<td>
<call-template name="color">
</td>
</template>
<template name="color">
<xsl:choose>
<xsl:when test=" [problem xpath here]position() mod 2">
<xsl:attribute
name="class">lightregion</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute
name="class">darkregion</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</template>
in this case the case statement works (even/odd numbers) based on the
location of <child> element.
Since the design requires such an output
parent child child child (pink color)
parent child child child (blue color)
parent child child child (pink color)
<child> elements should pick up the same class attribute as the <parent>
element
I wanted to avoid code duplication (case statemnet) and tried to write a
jeneric one. Therefore I used a name template to be used in several places.
So the question is, how can I write an xpath for the <when test> element so
when it is called in the <parent> element loop it will check the condition
and when it is in the <child> loop it will check its <parent> element's
condition.
Any suggestions, ideas???
Thanks
Meltem
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|