[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Xpath problem -follow up

Subject: Xpath problem -follow up
From: Meltem Kogelbauer <meltem.kogelbauer@xxxxxxxxxxxxxxxxxx>
Date: Wed, 18 Jul 2001 10:03:26 +0100
xpath parent child
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.