Felix Natter
Usenet Archive
- Joined
- Apr 21, 2000
- Messages
- 88
- Reaction score
- 0
hi,
I have a structure like:
<topic name="xxx">
<subtopic name="subxxx">
<subsubtopic name="subsubxxx">
</subsubtopic>
</subtopic>
</topic>
and so on.
in the <topic> template I do this:
<tr>
<!-- alternating background-colors: tr.one/tr.two -->
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="position mod 2 = 0">
<xsl:text>one</xsl:text>
</xsl:when>
<xsl
therwise>
<xsl:text>two</xsl:text>
</xsl
therwise>
</xsl:choose>
</xsl:attribute>
to set alternating background-colors (which works fine). But in a template for 'subsubtopic':
<xsl:template match="topic/subtopic/subsubtopic" mode="toc">
I want to find out the position of the ancestor <topic> element so that the <tr>'s generated by this template use the same background-color as the ancestor <topic> template.
this gives an xpath-error:
<xsl:if test="parent::subtopic/parent::topic/position mod 2 = 0">
So I tried this (this should return an empty node-set if the position of the <topic> is odd) <xsl:if test="parent::subtopic/parent::topic[position mod 2 = 0]">
but it doesn't work. I also tried this:
<xsl:if test="count(parent::subtopic/parent::topic[position mod 2 = 0])!=0">
but it doesn't work either. can you explain why?
(I could pass a parameter to the subtopic and subsubtopic templates which indicates background-color but it seems cleaner this way)
thanks,
I have a structure like:
<topic name="xxx">
<subtopic name="subxxx">
<subsubtopic name="subsubxxx">
</subsubtopic>
</subtopic>
</topic>
and so on.
in the <topic> template I do this:
<tr>
<!-- alternating background-colors: tr.one/tr.two -->
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="position mod 2 = 0">
<xsl:text>one</xsl:text>
</xsl:when>
<xsl
<xsl:text>two</xsl:text>
</xsl
</xsl:choose>
</xsl:attribute>
to set alternating background-colors (which works fine). But in a template for 'subsubtopic':
<xsl:template match="topic/subtopic/subsubtopic" mode="toc">
I want to find out the position of the ancestor <topic> element so that the <tr>'s generated by this template use the same background-color as the ancestor <topic> template.
this gives an xpath-error:
<xsl:if test="parent::subtopic/parent::topic/position mod 2 = 0">
So I tried this (this should return an empty node-set if the position of the <topic> is odd) <xsl:if test="parent::subtopic/parent::topic[position mod 2 = 0]">
but it doesn't work. I also tried this:
<xsl:if test="count(parent::subtopic/parent::topic[position mod 2 = 0])!=0">
but it doesn't work either. can you explain why?
(I could pass a parameter to the subtopic and subsubtopic templates which indicates background-color but it seems cleaner this way)
thanks,