docbook-apps

  • 1.  preceding-sibling::chapter[nummer]

    Posted 12-18-2008 18:30
    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


    --
    Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger



  • 2.  Re: [docbook-apps] preceding-sibling::chapter[nummer]

    Posted 12-18-2008 20:35
    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
    >
    >




  • 3.  Re: [docbook-apps] preceding-sibling::chapter[nummer]

    Posted 12-19-2008 10:10
    Dear both,

    On Thursday 18 December 2008 21:34:45 Richard Hamilton wrote:
    > There may be a better way to do this that someone can suggest,
    [...]

    I think counting the number of siblings should allow the output to be order
    independent. The (untested!) condition for chapter 3 would be:
    <when test="count(preceding-sibling::chapter) = 2">

    If you don't like the zero-offset, then:
    <when test="count(preceding-sibling::chapter | self::chapter) = 3">

    However, maybe there's a better way. If the colour represents some aspect of
    the chapters (introduction, topic-A, topic-B, etc..) rather than their
    structural position (like with Zebra tables) then it might be better to mark
    this within the DocBook (e.g., adding a custom role for the chapter) and base
    the markup on the chapter's role, rather than hard-coding the chapter numbers
    within your XSLT customisation layer. This would give you flexibility to
    reorder the chapters, add new chapters, etc without having to alter your
    stylesheets.

    HTH,

    Paul.



  • 4.  Re: [docbook-apps] preceding-sibling::chapter[nummer]

    Posted 12-19-2008 11:00
    Thank you very much for the help. I think I get.

    Lily


    -------- Original-Nachricht --------
    > Datum: Fri, 19 Dec 2008 11:09:34 +0100
    > Von: Paul Millar <paul@astro.gla.ac.uk>
    > An: docbook-apps@lists.oasis-open.org
    > CC: Richard Hamilton <rlhamilton@frii.com>, Lily Galle <lily.galle@gmx.net>
    > Betreff: Re: [docbook-apps] preceding-sibling::chapter[nummer]

    > Dear both,
    >
    > On Thursday 18 December 2008 21:34:45 Richard Hamilton wrote:
    > > There may be a better way to do this that someone can suggest,
    > [...]
    >
    > I think counting the number of siblings should allow the output to be
    > order
    > independent. The (untested!) condition for chapter 3 would be:
    > <when test="count(preceding-sibling::chapter) = 2">
    >
    > If you don't like the zero-offset, then:
    > <when test="count(preceding-sibling::chapter | self::chapter) = 3">
    >
    > However, maybe there's a better way. If the colour represents some aspect
    > of
    > the chapters (introduction, topic-A, topic-B, etc..) rather than their
    > structural position (like with Zebra tables) then it might be better to
    > mark
    > this within the DocBook (e.g., adding a custom role for the chapter) and
    > base
    > the markup on the chapter's role, rather than hard-coding the chapter
    > numbers
    > within your XSLT customisation layer. This would give you flexibility to
    > reorder the chapters, add new chapters, etc without having to alter your
    > stylesheets.
    >
    > HTH,
    >
    > Paul.
    >
    > ---------------------------------------------------------------------
    > To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
    > For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org

    --
    Sensationsangebot verlängert: GMX FreeDSL - Telefonanschluss + DSL
    für nur 16,37 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K1308T4569a