Hi, Sheldon,

1 - I am using number-columns-spanned in order to use the same template with sub-section headings and totals. I use the parameter <merge>. For the sub-titles, I give it a value of 13 (all the columns). For the sub-section totals, I give the first one a value of 5, followed by eight cells with a value of 1. It all worked, but I get one blank for the number of columns spanned and one blank for the background color. I isolated it to the following in the xml file:

<bu_line>
  <bu_item>
    <value>TRACKING SALES</value>
    <align>start</align>
    <borderline>solid .5pt</borderline>
    <fontweight>normal</fontweight>
    <fontsize>6pt</fontsize>
    <color>black</color>
    <merge>13</merge>
    <bg_color>#FFFF99</bg_color>
  </bu_item>
</bu_line>

If I remove that block, then there are no errors. In the xsl, it uses those keys for every line in the business bu_tiem section, with no additional errors. I'm stumped. It works, but it isn't "clean".

Without seeing your XSL for this bit, it's hard to provide a for-sure answer. My initial thought is that you're not checking for the existence of the merge element. If you have <fo:table-cell number-columns-spanned="{merge}"> but there's no merge element, you get <fo:table-cell number-columns-spanned=""> in the FO output. At best, it'll be ignored. Instead, use something like this:
<fo:table-cell>
 <xsl:if test="merge &gt; 0">
<!-- test for the presence of the element, that its value is numeric, and that its value is 1 or more --> <xsl:attribute name="number-columns-spanned"><xsl:value-of select="merge"/></xsl:attribute
 </xsl:if>

Again, though, I'm just guessing. If you want a spot-on answer, post your XSLT with the spanning code.

2 - How do I put spaces in place. For example, if I wanted " Admin", rather than "Admin", how do I make that happen? It seems to ignore initial whitespace.

First, you should understand that leading and trailing white space is, by default, stripped when the transform loads the XML input stream. Think of it as having a trim() function run on everything.

However, you can dictate which elements should have their spaces preserved and which shouldn't by using the xsl:strip-space and xsl:preserve-space elements at the top of your transform. In looking at your XML, it looks like you want to preserve space on the value element, so you'd add <xsl:preserve-space elements="value"/> at the top of your transform. Note that both instructions take a space-separated list (rather ironic for instructions that manage spaces, no?). So, if you had a second element (call it widget) on which you needed to preserve spaces, you'd have <xsl:preserve-space elements="value widget"/>. Both instructions take wildcards, so you can do <xsl:preserve-space elements="*"/> and <xsl:strip-space elements="value widget"/> to get exactly the reverse of <xsl:preserve-space elements="value widget"/>.

Also (and this ties to your next question), you can always force a space by using the trusty old entity for a non-breaking space. Note that you have to use the decimal value for it, though (or you have to define an nbsp entity somewhere). So you can do things like <fo:block>Force a space here:&#160;</fo:block> (160 is the decimal code for an nbsp).

3 - How do put in special characters like the ampersand?

XML (and remember that XSL is also XML) defines 5 special entities:
&amp; - the ampersand
&quot; - the double quotation mark
&apos; - the single quotation mark
&lt; - the less than sign (<)
&gt; - the greater than sign (>)

You can always use those 5 entities to get those characters from an XSL transform. Assuming your using the UTF-8 character set, you can also use just about any character in the set by specifying its decimal value in an entity (as I did above for the non-breaking space). In addition to &#160;, I use &#8226; (that's a bullet a charater) when I need bullets. I'm sure you can find umpteen examples with a quick search.

One heavy caveat: entities are guaranteed to bite you hard if you again transform the output of a transform. Consider the trusty ampersand character. In your first transform, you insert one with &amp;. Then your second transform throws an error complaining that it can't resolve an entity because it hit that & character. This leads to weirdness such as: &amp;amp; It's far better to make sure all your processing doesn't involve entities until the last step in your processing chain.

As a side note, I use Ant to control build processes that sometimes have transform after transform (because the process needs to merge data sets and such). I make sure that I get all the content in place before I add any entities in the formatting step (which has to be the last step for just this reason).


As I progress through this, I pick up more and more ideas. For example, in the "shouda dun it that way" category is to use just the template for the data line. I could have run all the lines through that template without the need for specialized xsl stuff. Next time!

Thanks again for your tremendous help.

I'm happy to do it. XSL (both T and FO) is a great language, and FOP is a great tool. I'm glad to see another person using both.

Jay Bryant

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to