docbook-apps

  • 1.  class.value mode with multiple values

    Posted 10-15-2013 13:38
    hi, I have an element that I want to have multiple class values by matching
    in class.value mode.

    I've read this doc, but still not sure how to proceed:
    http://www.sagehill.net/docbookxsl/HtmlCustomEx.html

    Currently I have these two templates:
    <xsl:template match="d:term" mode="class.value">
    <xsl:value-of select="'AAterm'" />
    </xsl:template>

    <xsl:template match="d:*[@conformance='experimental']" mode="class.value">
    <xsl:value-of select="local-name()" />
    <xsl:value-of select="' AAexperimental'" />
    </xsl:template>

    My DocBook source has a <term conformance="experimental">; it seems that
    the last template wins so this is the result:

    but I need


    the attribute conformance="experimental" can appear on multiple element
    types, (e.g., section, term)

    How to get the two templates to work together?

    thanks,
    --Tim



  • 2.  Re: [docbook-apps] class.value mode with multiple values

    Posted 10-15-2013 17:10
    Hi Tim,
    The processing model for XSLT, as stated in the standard, is "A node is
    processed by finding all the template rules with patterns that match the
    node, and choosing the best amongst them". There is an algorithm for
    decided which is "best", but it always comes down to one template. So the
    XSLT mechanism won't ever match on both of your templates.

    Within the body of that single chosen template, however, you can apply other
    templates to the same element using these methods:

    <xsl:call-template name="othertemplate"/>
    <xsl:apply-imports/>
    <xsl:apply-templates select="." mode="othermode"/>

    You can also use an xsl:choose within that single template to test the
    current element (xsl:when test="self::d:term") and add another value or call
    another template.

    You'll need to examine the organization of your class values to see which
    method would work best for you.

    Bob Stayton
    Sagehill Enterprises
    bobs@sagehill.net


    From: Tim Arnold
    Sent: Tuesday, October 15, 2013 6:37 AM
    To: DocBook Apps
    Subject: [docbook-apps] class.value mode with multiple values


    hi, I have an element that I want to have multiple class values by matching
    in class.value mode.


    I've read this doc, but still not sure how to proceed:
    http://www.sagehill.net/docbookxsl/HtmlCustomEx.html



    Currently I have these two templates:
    <xsl:template match="d:term" mode="class.value">
    <xsl:value-of select="'AAterm'" />
    </xsl:template>



    <xsl:template match="d:*[@conformance='experimental']" mode="class.value">
    <xsl:value-of select="local-name()" />
    <xsl:value-of select="' AAexperimental'" />
    </xsl:template>



    My DocBook source has a <term conformance="experimental">; it seems that the
    last template wins so this is the result:

    but I need



    the attribute conformance="experimental" can appear on multiple element
    types, (e.g., section, term)


    How to get the two templates to work together?


    thanks,
    --Tim




  • 3.  Re: [docbook-apps] class.value mode with multiple values

    Posted 10-16-2013 19:17
    thanks Bob, as usual your answer was spot-on. I used the xsl:choose method
    since that seemed the simplest way to go.

    thanks,
    --Tim



    On Tue, Oct 15, 2013 at 1:09 PM, Bob Stayton <bobs@sagehill.net> wrote:

    > Hi Tim,
    > The processing model for XSLT, as stated in the standard, is "A node is
    > processed by finding all the template rules with patterns that match the
    > node, and choosing the best amongst them". There is an algorithm for
    > decided which is "best", but it always comes down to one template. So the
    > XSLT mechanism won't ever match on both of your templates.
    >
    > Within the body of that single chosen template, however, you can apply
    > other templates to the same element using these methods:
    >
    > <xsl:call-template name="othertemplate"/>
    > <xsl:apply-imports/>
    > <xsl:apply-templates select="." mode="othermode"/>
    >
    > You can also use an xsl:choose within that single template to test the
    > current element (xsl:when test="self::d:term") and add another value or
    > call another template.
    >
    > You'll need to examine the organization of your class values to see which
    > method would work best for you.
    >
    > Bob Stayton
    > Sagehill Enterprises
    > bobs@sagehill.net
    >
    >
    > From: Tim Arnold
    > Sent: Tuesday, October 15, 2013 6:37 AM
    > To: DocBook Apps
    > Subject: [docbook-apps] class.value mode with multiple values
    >
    >
    >
    > hi, I have an element that I want to have multiple class values by
    > matching in class.value mode.
    >
    >
    > I've read this doc, but still not sure how to proceed:
    > http://www.sagehill.net/**docbookxsl/HtmlCustomEx.html<http://www.sagehill.net/docbookxsl/HtmlCustomEx.html>
    >
    >
    >
    > Currently I have these two templates:
    > <xsl:template match="d:term" mode="class.value">
    > <xsl:value-of select="'AAterm'" />
    > </xsl:template>
    >
    >
    >
    > <xsl:template match="d:*[@conformance='**experimental']"
    > mode="class.value">
    > <xsl:value-of select="local-name()" />
    > <xsl:value-of select="' AAexperimental'" />
    > </xsl:template>
    >
    >
    >
    > My DocBook source has a <term conformance="experimental">; it seems that
    > the last template wins so this is the result:
    >

    > but I need
    >

    >
    >
    > the attribute conformance="experimental" can appear on multiple element
    > types, (e.g., section, term)
    >
    >
    > How to get the two templates to work together?
    >
    >
    > thanks,
    > --Tim
    >