This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: math get maximum and subtract 1


Hi Sascha,

> i tried this, but FOP doesn't seem to like the starts-row attribute-
> "not implemented yet" :-(
>
> what am i gonna do now? 

Now you're going to use a grouping method. You need to group your
DESCRIPTION_ITEM elements based on their position and your knowledge
of the number of rows in the table which (if you remember) you can get
by looking at the row attribute of the last DESCRIPTION_ITEM element:

  <xsl:variable name="nrows"
                select="DESCRIPTION_ITEM[last()]/@row + 1" />

Now, in your sample there were 5 rows, and the DESCRIPTION_ITEM
elements were sorted based on their column and then their row, so the
first 5 DESCRIPTION_ITEM elements were for the first column, the next
5 for the second column and so on.

You need to do some processing once per row to create the rows; the
easiest way to do that is to iterate over the first cells in each row
-- the DESCRIPTION_ITEMs whose col attribute has the value 0:

  <xsl:for-each select="DESCRIPTION_ITEM[@col = 0]">
    <fo:table-row>
      ...
    </fo:table-row>
  </xsl:for-each>

Now, if you're on row 0 then you need to populate that row with the
DESCRIPTION_ITEM elements positioned 1, 6, 11 and so on in your list.
If you're on row 1 then you need the DESCRIPTION_ITEM elements
positioned 2, 7, 12 and so on. See the pattern? You need to look at
their position, mod the number of rows in the table ($nrows), and see
if it's the same as the number of row you're currently creating (the
value of the row attribute on the current DESCRIPTION_ITEM) at plus
one:

  <xsl:for-each select="DESCRIPTION_ITEM[@col = 0]">
    <fo:table-row>
      <xsl:for-each select="../DESCRIPTION_ITEM
                              [position() mod $nrows =
                               current()/@row + 1]">
        <fo:table-cell>
          ...
        </fo:table-cell>
      </xsl:for-each>
    </fo:table-row>
  </xsl:for-each>

Note that this only works because your DESCRIPTION_ITEMs are sorted by
column and then by row. If they're sorted in some other way, or aren't
actually sorted at all, then we need to try another method.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]