Subject: [xsl] Xpath problem -follow up From: Meltem Kogelbauer <meltem.kogelbauer@xxxxxxxxxxxxxxxxxx> Date: Wed, 18 Jul 2001 10:03:26 +0100 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] format-number, Jeni Tennison | Thread | Re: [xsl] Xpath problem -follow up, David Carlisle |
[xsl] format-number, Daniel Newman | Date | Re: [xsl] Xpath problem -follow up, David Carlisle |
Month |