Loading ...
Sorry, an error occurred while loading the content.

Align by decimal place

Expand Messages
  • eentenman
    I am trying to figure out a way to align text inside table cells by the decimal point. I have a table that has columns of financial data. Some of the columns
    Message 1 of 6 , Jun 9, 2004
    • 0 Attachment
      I am trying to figure out a way to align text inside table cells by
      the decimal point. I have a table that has columns of financial
      data. Some of the columns have percentages the need to wrapped with
      parenthesis if the value is negative. So

      10.001%
      (.001%)
      5.02%
      (.2%)

      to look more like

      10.001%
      (.001%)
      5.02%
      (.2%)

      would all align by the decimal point. I am not using a fixed width
      font.

      Anyone have a suggestion?

      Thanks in advance.
    • G. Ken Holman
      ... I don t know which processors support text-align= , but the ones that I use do not. Below is what the spec says you need ... the first blocks are
      Message 2 of 6 , Jun 9, 2004
      • 0 Attachment
        At 2004-06-09 18:12 +0000, eentenman wrote:
        >I am trying to figure out a way to align text inside table cells by
        >the decimal point. I have a table that has columns of financial
        >data.

        I don't know which processors support text-align="<string>", but the ones
        that I use do not.

        Below is what the spec says you need ... the first blocks are not aligned,
        the blocks in the table cells are supposed to be aligned from what I can read.

        I hope this helps.

        ....................... Ken

        <flow xmlns="http://www.w3.org/1999/XSL/Format" flow-name="frame-body"
        font-family="Times" font-size="20pt">

        <block text-align=".">10.001%</block>
        <block text-align=".">(.001%)</block>
        <block text-align=".">5.02%</block>
        <block text-align=".">(.2%)</block>

        <table border="solid 1pt">
        <table-body>
        <table-row>
        <table-cell>
        <block text-align=".">10.001%</block>
        </table-cell>
        </table-row>
        <table-row>
        <table-cell>
        <block text-align=".">(.001%)</block>
        </table-cell>
        </table-row>
        <table-row>
        <table-cell>
        <block text-align=".">5.02%</block>
        </table-cell>
        </table-row>
        <table-row>
        <table-cell>
        <block text-align=".">(.2%)</block>
        </table-cell>
        </table-row>
        </table-body>
        </table>
        </flow>


        --
        Public courses: Spring 2004 world tour of hands-on XSL instruction
        Next: 3-day XSLT/XPath; 2-day XSL-FO - Birmingham, UK June 14,2004

        World-wide on-site corporate, govt. & user group XML/XSL training.
        G. Ken Holman mailto:gkholman@...
        Crane Softwrights Ltd. http://www.CraneSoftwrights.com/f/
        Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
        Male Breast Cancer Awareness http://www.CraneSoftwrights.com/f/bc
        Legal business disclaimers: http://www.CraneSoftwrights.com/legal
      • J.Pietschmann
        ... You can use text-align= . on the tabel cells. Note the inner quotes which is necessary for the FO processor to recognize it as a string. See
        Message 3 of 6 , Jun 9, 2004
        • 0 Attachment
          eentenman wrote:
          > I am trying to figure out a way to align text inside table cells by
          > the decimal point.

          You can use
          text-align="'.'"
          on the tabel cells. Note the inner quotes which is necessary
          for the FO processor to recognize it as a string. See
          http://www.w3.org/TR/xsl/slice7.html#text-align
          for more info.

          If you are using FOP, you'll find that this feature is not
          implemented. As a portable workaround, you can use two
          table cells for each number. Split the number at the decimal
          point and put the left part into the first cell, right aligned,
          and the right part into the second cell, left aligned:
          <fo:table-cell>
          <fo:block text-align="right">10</fo:block>
          </fo:table-cell>
          <fo:table-cell>
          <fo:block text-align="leftt">.001%</fo:block>
          </fo:table-cell>


          J.Pietschmann
        • Eric Entenman
          Thanks for the replies. I tried the text align = . but the renderer does not support it. Splitting it up into two cells seems like a great workaround.
          Message 4 of 6 , Jun 9, 2004
          • 0 Attachment
            Thanks for the replies. I tried the text align = "'.'" but the renderer does not support it. Splitting it up into two cells seems like a great workaround.


            ----- Original Message -----
            From: J.Pietschmann
            To: XSL-FO@yahoogroups.com
            Sent: Wednesday, June 09, 2004 2:52 PM
            Subject: Re: [XSL-FO] Align by decimal place


            eentenman wrote:
            > I am trying to figure out a way to align text inside table cells by
            > the decimal point.

            You can use
            text-align="'.'"
            on the tabel cells. Note the inner quotes which is necessary
            for the FO processor to recognize it as a string. See
            http://www.w3.org/TR/xsl/slice7.html#text-align
            for more info.

            If you are using FOP, you'll find that this feature is not
            implemented. As a portable workaround, you can use two
            table cells for each number. Split the number at the decimal
            point and put the left part into the first cell, right aligned,
            and the right part into the second cell, left aligned:
            <fo:table-cell>
            <fo:block text-align="right">10</fo:block>
            </fo:table-cell>
            <fo:table-cell>
            <fo:block text-align="leftt">.001%</fo:block>
            </fo:table-cell>


            J.Pietschmann

            Yahoo! Groups Sponsor
            ADVERTISEMENT





            ------------------------------------------------------------------------------
            Yahoo! Groups Links

            a.. To visit your group on the web, go to:
            http://groups.yahoo.com/group/XSL-FO/

            b.. To unsubscribe from this group, send an email to:
            XSL-FO-unsubscribe@yahoogroups.com

            c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



            [Non-text portions of this message have been removed]
          • G. Ken Holman
            Thanks for commenting on the format of the property. ... I looked where you cited and I see no examples of the use of a string argument. I checked the CSS
            Message 5 of 6 , Jun 9, 2004
            • 0 Attachment
              Thanks for commenting on the format of the property.

              At 2004-06-09 20:52 +0200, J.Pietschmann wrote:
              >eentenman wrote:
              > > I am trying to figure out a way to align text inside table cells by
              > > the decimal point.
              >
              >You can use
              > text-align="'.'"
              >on the tabel cells. Note the inner quotes which is necessary
              >for the FO processor to recognize it as a string. See
              > http://www.w3.org/TR/xsl/slice7.html#text-align
              >for more info.

              I looked where you cited and I see no examples of the use of a string argument.

              I checked the CSS citation and saw in the syntax of the CSS stylesheet the
              use of quotes, but I thought that was an artifact of the CSS stylesheet syntax.

              Looking at XSL-FO section 5.11 I note the description of <string> to be:

              "A sequence of characters"

              ... which does not imply the need for quotes ... though I will admit that
              if the alignment string were the word "left" you would need to say "'left'"
              in order to distinguish from "left".

              But ... can anyone cite chapter and verse of XSL-FO that <string> *must* be
              quoted inside the attribute value?

              Thanks!

              ........................... Ken

              --
              Public courses: Spring 2004 world tour of hands-on XSL instruction
              Next: 3-day XSLT/XPath; 2-day XSL-FO - Birmingham, UK June 14,2004

              World-wide on-site corporate, govt. & user group XML/XSL training.
              G. Ken Holman mailto:gkholman@...
              Crane Softwrights Ltd. http://www.CraneSoftwrights.com/f/
              Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
              Male Breast Cancer Awareness http://www.CraneSoftwrights.com/f/bc
              Legal business disclaimers: http://www.CraneSoftwrights.com/legal
            • J.Pietschmann
              ... Really? 7.15.9 text-align Value: start | center | end | justify | inside | outside | left | right ... The in the angle brackets is really meant
              Message 6 of 6 , Jun 10, 2004
              • 0 Attachment
                G. Ken Holman wrote:
                > I looked where you cited and I see no examples of the use of a string argument.

                Really?
                7.15.9 "text-align"
                Value: start | center | end | justify | inside | outside | left | right
                | <string> | inherit
                The <string> in the angle brackets is really meant to be an XSLFO
                property expression string, I think, while all the other values are
                enumeration tokens.
                Well, they *could* have been a bit more clear.

                > I checked the CSS citation and saw in the syntax of the CSS stylesheet the
                > use of quotes, but I thought that was an artifact of the CSS stylesheet syntax.
                >
                > Looking at XSL-FO section 5.11 I note the description of <string> to be:
                >
                > "A sequence of characters"
                >
                > ... which does not imply the need for quotes ... though I will admit that
                > if the alignment string were the word "left" you would need to say "'left'"
                > in order to distinguish from "left".

                Section 5.9.8 Strings (lexical structure of property expressions):
                "Strings are represented either as literals or as an enumeration token."
                The string literal is cross referenced to the production:
                [20] Literal ::= '"' [^"]* '"' | "'" [^']* "'"
                (see slice5.html#NT-Literal). These quotes are supposed to be inside
                the XML attribute, like for XSLT strings.
                But then, there is the following in 5.9.8:
                "All properties contexts allow conversion from enumeration tokens to
                strings"
                which means the XML attribute
                foo="bar"
                would represent a valid FO property expression, yielding the
                enumeration token bar which may be implicitly converted to the string
                "bar".
                OTOH, an enumeration token is supposed to be a NCName, and a single
                dot is not a NCName (but a single underline character is). Hence
                the need for the quotes. Or so I believe.

                I remember the discussion regarding page number formats:
                <fo:page-sequence format="01" ...
                The expression will be parsed as number, but because the format is
                expected to be a string and in contrast to XPath XSLFO numbers
                can't be implicitely converted into a string, the property is in
                error (and even if implicit conversion was allowed, it would drop
                the leading zero). The errata allow the FO processor specifically
                for this use case to fall back to use the original string value
                of the XML atribute, after trimming leading and trailing whitespace,
                otherwise everybody would be forced to write
                <fo:page-sequence format="'01'" ...
                Duh!

                And I really like the specification of the hyphenation character:
                7.9.5 "hyphenation-character"
                Value: <character> | inherit
                Yeah, chapter 5 doesn't include a specification for a lexical character,
                nor do the errata. This begs the question whether
                <fo:block hyphenation-character="-">
                is really meant to be written this way, because the only plausible
                interpretation of <character> would be "a string consisting of
                a single character". And what about
                <fo:block hyphenation-character="....">
                Yes, four ASCII dots. Why shouldn't this be allowed?

                I'm reminded of the most renowned example of "specification by
                implementation", the C preprocessor - simple, intuitive syntax,
                straightforward implementation, but leading to an utterly convoluted
                formal description for the sake of getting rid of the "dark corners"
                (which makes the quite innocently looking expression 0xE-0xA an invalid
                PP token).

                Specs with holes suck. But then, I've dealt with texts which were much,
                much worse.
                I hope they fix the property expression grammar and the individual
                property specs in XSLFO 2.0

                Regards
                J.Pietschmann
              Your message has been successfully submitted and would be delivered to recipients shortly.