docbook-apps

  • 1.  Re: [docbook-apps] Aligning numbers in table cells with xsl

    Posted 05-25-2012 20:00
    One way to handle those characters is to use the translate() function to remove them before doing the test. If the third argument of translate() is empty, then the matching characters in the second argument disappear, and all other characters are left untouched. Something like:

    string(number(translate(., '<>', '')))


    Bob Stayton
    Sagehill Enterprises
    bobs@sagehill.net





  • 2.  Re: [docbook-apps] Aligning numbers in table cells with xsl

    Posted 05-26-2012 09:33
    Thanks Bob for the tip about translate. I finally worked it out - coding
    as follows:

    <xsl:templatename="table.cell.block.properties">
    <xsl:variablename="stringanglesymbol">
    <xsl:choose>
    <xsl:whentest="contains(., '<')">
    <xsl:value-ofselect="(translate(., '<', ''))"/>
    </xsl:when>
    <xsl:whentest="contains(., '>')">
    <xsl:value-ofselect="(translate(., '>', ''))"/>
    </xsl:when>
    </xsl:choose>
    </xsl:variable>


    <xsl:choose>
    <xsl:whentest="(ancestor-or-self::d:table/@tabstyle = 'numbers' or
    ancestor-or-self::d:table/@tabstyle = 'numberstripe') and
    not(ancestor::d:thead or
    ancestor::d:tfoot) and preceding-sibling::d:entry and
    ((string(number($stringanglesymbol)) != 'NaN') or (string(number(.)) !=
    'NaN'))">
    <xsl:attributename="text-align">right</xsl:attribute>


    <xsl:attributename="margin-right">
    <xsl:choose>
    <xsl:whentest="self::d:entry/d:footnote">
    <xsl:value-ofselect="$cellfootnoteindent"/>
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-ofselect="$cellnumberindent"/>
    </xsl:otherwise>
    </xsl:choose>
    <xsl:text>%</xsl:text>
    </xsl:attribute>
    </xsl:when>
    <xsl:otherwise/>
    </xsl:choose>
    </xsl:template>



    On 26-05-12 5:59 AM, Bob Stayton wrote:
    > One way to handle those characters is to use the translate() function
    > to remove them before doing the test. If the third argument of
    > translate() is empty, then the matching characters in the second
    > argument disappear, and all other characters are left untouched.
    > Something like:
    > string(number(translate(., '<>', '')))
    > Bob Stayton
    > Sagehill Enterprises
    > bobs@sagehill.net <mailto:bobs@sagehill.net>
    >
    >