Re: [xsl] Displaying Icon in Page Margin

Subject: Re: [xsl] Displaying Icon in Page Margin
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 15 Sep 2011 15:44:38 -0400
At 2011-09-15 14:30 -0500, you wrote:
> I wasn't asking your authors to add the ghost column. I was suggesting that
> as you process your author's tables, *you* insert the ghost column on every
> row. That way it is predictable and maintainable.


True. It still seems kinda messy, though, because I'd have to
preprocess each file through that XSL script (to add the column)
before it goes through the normal XSL translation to FO.

Sorry ... that isn't what I meant at all. Please forgive me for not being clear in my explanation. I'd like to clarify this for the benefit of readers of the archive.


I'm suggesting that in your "XSL translation to FO" that you are writing, you introduce the table cell. I wasn't at all suggesting that you preprocess your author's data in order to add that ghost cell.

Again, this is the confusion I find in the class. As a stylesheet writer you do *not* have to mirror your input data in your output. Your output can be augmented however you need to produce your result. You are not the first to think that the input data has to be massaged.

That's not
unmanageable and I'm happy to have something to fall back on, but it
just seems like there has to be a better way.

Wait ... I thought you were writing your own XSL-FO stylesheets and not using another "XSL translation to FO", perhaps one off-the-shelf. That would imply the need for two passes as you suggest. But all of your questions suggest this is not the case.


I'm assuming that you have an XML file in some vocabulary and you are writing a single "XSL translation to FO", and that is where the translation introduces the ghost column.

Say your input is <tbl> and <row> and <col>. You would introduce the ghost column at the time you produce the row:

<xsl:template match="tbl">
  <fo:table>
    <xsl:apply-templates/>
  </fo:table>
</xsl:template>

<xsl:template match="row">
  <fo:table-row>
    <!--first inject the ghost cell with the float-->
    <fo:table-cell>
      <fo:block>
        <fo:float ...>
          <fo:block>
            ...
          </fo:block>
        </fo:float>
      </fo:block>
    </fo:table-cell>
    <!--now process the authored cells-->
    <xsl:apply-templates/>
  </fo:table-row>
</xsl:template>

<xsl:template match="col">
  <fo:table-cell>
    <xsl:apply-templates/>
  </fo:table-cell>
</xsl:template>

In this way your input data does *not* have to have the ghost cells. It is your stylesheet that is injecting the ghost XSL-FO cells. There is no need for your input to have the ghost cells as implied by your suggestion for preprocessing.

Another issue I found with using the negative margins is that I end up
having to write very complicated rules that mirror the  styling
attributes of the affected elements. For example, to draw the icon
aligned to the left of a nested list, I have to know what level I'm at
and what the indent is for each level. Again, not undoable, but it's
overly complex and would be difficult to maintain.

Granted, that would be a challenge. Nothing jumps to mind quickly.


So, yes you may have to abandon my suggested approach. But I just wanted to clarify for the archive that I was not referring to preprocessing your authored content to get the effect I suggested.

I hope this is helpful.

. . . . . . . . . . Ken


-- Contact us for world-wide XML consulting and instructor-led training Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Google+ profile: https://plus.google.com/116832879756988317389/about Legal business disclaimers: http://www.CraneSoftwrights.com/legal

Current Thread