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

missing white space and a strange relationship to the ampersand

Expand Messages
  • Omilian, Alex
    Hi, I ve got an XML document with a bunch of lines of text similar to the following: Time & Kms Components $
    Message 1 of 2 , Sep 9, 2002
    • 0 Attachment
      Hi,

      I've got an XML document with a bunch of lines of text similar to the
      following:


      <components1> Time & Kms Components $ Charge
      GST Total</components1>
      <components2> --------------------- ------ Time & Kms 87.27
      8.73 96.00</components2>
      <components3> 2.00 Dy @ 48.00 : 96.00 Drv.Prot Ca 40.00
      4.00 44.00</components3>
      <components4> (GST Included) Admin. Fees 1.27
      0.12 1.39</components4>
      <components5> --------
      ------- --------</components5>
      <components6> 128.54
      12.85 141.39</components6>
      <components7> Commission -8.73
      -0.87 -9.60</components7>


      I need to preserve the original formatting so I render this data in a
      mono-space font, which works fine 90% of the time as follows:


      <fo:table-row font-family="Courier" font-size="10pt" height="60mm" >
      <fo:table-cell padding="5pt" border-color="black" text-align="left">

      <fo:block text-align="left" white-space-collapse="false" ><xsl:value-of
      select="xml-data/invoice/charges_summary/components1"/></fo:block>

      <fo:block text-align="left" white-space-collapse="false" ><xsl:value-of
      select="xml-data/invoice/charges_summary/components2"/></fo:block>

      <fo:block text-align="left" white-space-collapse="false" ><xsl:value-of
      select="xml-data/invoice/charges_summary/components3"/></fo:block>
      <fo:block text-align="left" white-space-collapse="false"><xsl:value-of
      select="xml-data/invoice/charges_summary/components4"/></fo:block>
      <fo:block text-align="left" white-space-collapse="false"><xsl:value-of
      select="xml-data/invoice/charges_summary/components5"/></fo:block>
      <fo:block text-align="left" white-space-collapse="false"><xsl:value-of
      select="xml-data/invoice/charges_summary/components6"/></fo:block>
      <fo:block text-align="left" white-space-collapse="false"><xsl:value-of
      select="xml-data/invoice/charges_summary/components7"/></fo:block>
      <fo:block text-align="left" white-space-collapse="false"><xsl:value-of
      select="xml-data/invoice/charges_summary/components8"/></fo:block>
      <fo:block text-align="left" white-space-collapse="false"><xsl:value-of
      select="xml-data/invoice/charges_summary/components9"/></fo:block>
      <fo:block text-align="left" white-space-collapse="false"><xsl:value-of
      select="xml-data/invoice/charges_summary/components10"/></fo:block>
      <fo:block text-align="left" white-space-collapse="false"><xsl:value-of
      select="xml-data/invoice/charges_summary/components11"/></fo:block>
      <fo:block text-align="left" white-space-collapse="false"><xsl:value-of
      select="xml-data/invoice/charges_summary/components12"/></fo:block>
      <fo:block text-align="left" white-space-collapse="false"><xsl:value-of
      select="xml-data/invoice/charges_summary/components13"/></fo:block>
      </fo:table-cell>
      </fo:table-row>


      However, I find that occasionally the white space to the left disappears and
      one or two lines move to the left. More interesting, I find that if the
      ampersand entity is not used (say using the + instead) then I do not get
      this behavior. I've also noticed that when I have an ampersand on the end of
      a line it strips the white space from the end of that line. Annoyingly, this
      behavior does not seem to follow any predictable pattern, as all my data
      contains the ampersand, yet only 15% or so get this behavior.

      I've run this through both Apache FOP and XEP, and both exhibit the same
      behavior, so I suspect I may be doing something wrong here, but I am trying
      to preserve the white space by specifying the following in my document:

      <xsl:preserve-space elements="components1 components2 components3
      components4 components5 components6 components7 components8
      components9 components10 components11 components12" />

      Anyone got a suggestion?

      Thanks, Alex.


      [Non-text portions of this message have been removed]
    • G. Ken Holman
      ... This is preserving the space in the XSL-FO file but the processor is still acting on the space. ... Check on page 27 of the free download of the preview
      Message 2 of 2 , Sep 9, 2002
      • 0 Attachment
        At 2002-09-10 10:21 +1000, Omilian, Alex wrote:
        > I need to preserve the original formatting so I render this data in a
        >mono-space font, which works fine 90% of the time as follows:
        >...
        ><xsl:preserve-space elements="components1 components2 components3
        >components4 components5 components6 components7 components8
        >components9 components10 components11 components12" />

        This is preserving the space in the XSL-FO file but the processor is still
        acting on the space.

        >Anyone got a suggestion?

        Check on page 27 of the free download of the preview excerpt of our
        electronic book "Practical Formatting Using XSL-FO" (follow the top "Book
        Sales" link on the home page noted below). You'll see I use:

        <block linefeed-treatment="preserve" white-space-collapse="false"
        white-space-treatment="preserve" font-family="Courier">

        There is also the white-space= shorthand, but a processor is not obliged to
        support shorthand properties. When you find it in the property annex on
        page 195, you can click on the properties and be guided to their individual
        descriptions, or to the spec itself in a browser window. In this way you
        can use the free preview excerpt as a way of navigating the actual
        Recommendation document.

        For those with the entire book page 91 is titled "Preserving white space".

        I hope this helps.

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


        --
        Upcoming hands-on in-depth Europe: Sep 18-Sep 20,2002
        XSLT/XPath and XSL-FO North America: Sep 30-Oct 4,2002

        G. Ken Holman mailto:gkholman@...
        Crane Softwrights Ltd. http://www.CraneSoftwrights.com/f/
        Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995)
        ISBN 0-13-065196-6 Definitive XSLT and XPath
        ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath
        ISBN 1-894049-10-1 Practical Formatting Using XSL-FO
        XSL/XML/DSSSL/SGML/OmniMark services, books (electronic, printed),
        articles, training (instructor-live,Internet-live,web/CD,licensed)
        Next public training: 2002-09-11,13,18,19,30,10-03,12-08
      Your message has been successfully submitted and would be delivered to recipients shortly.