Lily,

There are a couple of things to consider in this example:

1) The tests are looking for a *preceding* sibling with a particular
   index, so the test for "preceding-sibling::chapter[2]" will only
   be true if you are in Chapter 3 or later, and will be false for
   Chapter 2. That accounts for the results you saw.

2) The test is true if *any" preceding sibling has that index, so
   in your example, chapters 3 through the end will have green headers.
   This example will only do what you want if you order the tests
   from high to low (the same as your example) and include every
   chapter explicitly.

There may be a better way to do this that someone can suggest,
but if you order the tests high to low and change the color
assignments so you assign the color for Chapter N to the test for
"preceding-sibling::chapter[N-1]", you should get what you need.

Hope that helps.
Dick Hamilton
http://managingwriters.com

On Thu, 2008-12-18 at 19:30 +0100, Lily Galle wrote:
> Hi,
> 
> I have the following code in my xsl Stylesheet: 
> 
>   <xsl:attribute-set name="header.table.properties">
>     <xsl:attribute name="background-color">
>       <xsl:choose>       
>         <xsl:when test="preceding-sibling::chapter[2]">green</xsl:when>
>         <xsl:when test="preceding-sibling::chapter[1]">red</xsl:when>      
>         <xsl:otherwise>blue</xsl:otherwise>
>       </xsl:choose>
>     </xsl:attribute>
> … …
>   </xsl:attribute-set>
> 
> In the output file the chapter one does not have red color in header, but 
> blue. Chapter 2 does not have green color, but red. Why?
> 
> Is chapter ein “preceding-sibling” node of header.table? Where can I see 
> this? I think it is not in DocBook-Scheama. I checked for example the docBook 
> Definitive guide (http://www.docbook.org/tdg5/en/html/book.html ). It does 
> not show this. 
> 
> Thanks for any help!
> 
> Lily
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to