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 Sasha.

If what you want is a table (you can change it to fo:table later) you
can use this template:

 <xsl:key name="rows" match="DESCRIPTION_ITEM" use="@row"/> <!-- this is
needed so you can get all columns in a row. -->

 <xsl:template match="DESCRIPTION_TABLE">
  <table> <!-- here you create the table -->
  <xsl:call-template name="ShowRow"/>
  </table>
 </xsl:template>

 <xsl:template name="ShowRow"> <!-- this template will create a row in
the table -->
  <xsl:param name="row" select="0"/> <!-- the current row -->
  <xsl:variable name="next" select="$row+1"/> <!-- this will be the next
row, if there is one -->
  <tr>
   <xsl:for-each select="key('rows',$row)">
    <xsl:sort select="@col"/>
    <td><label title="{@row} {@col}"><xsl:value-of
select="LABEL"/></label>&#160;<xsl:value-of select="VALUE"/></td>
   </xsl:for-each>
  </tr>
  <xsl:if test="DESCRIPTION_ITEM[@row=$next]"> <!-- if exists a next row
then deal with it :) -->
   <xsl:call-template name="ShowRow">
    <xsl:with-param name="row" select="$next"/>
   </xsl:call-template>
  </xsl:if>
 </xsl:template>

Hope that this helps you


-----Original Message-----
From: owner-xsl-list@lists.mulberrytech.com
[mailto:owner-xsl-list@lists.mulberrytech.com] On Behalf Of sascha
Sent: Monday, July 29, 2002 1:23 PM
To: xsl-list@lists.mulberrytech.com
Subject: Re: [xsl] math get maximum and subtract 1



----- Original Message -----
From: "Jeni Tennison" <jeni@jenitennison.com>
Subject: Re: [xsl] math get maximum and subtract 1


> 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.


Jeni,

remember that topic? Well, actually that IS what we have right now...
Our client has changed it's export and the description_items aren't
sorted at all. Unfortunately i do not have an example at the moment. But
I am wondering if there is any way at all to solve this then... I hope
that i will get a real example tomorrow.

Here's the sorted example again:


<DESCRIPTION_TABLE>
   <DESCRIPTION_ITEM col="0" row="0">
    <LABEL>Verantwortlicher</LABEL>
    <VALUE>Text</VALUE>
   </DESCRIPTION_ITEM>
   <DESCRIPTION_ITEM col="0" row="1">
    <LABEL>Prozessziel</LABEL>
    <VALUE>Text</VALUE>
   </DESCRIPTION_ITEM>
   <DESCRIPTION_ITEM col="0" row="2">
    <LABEL>Messgrösse</LABEL>
    <VALUE>Text</VALUE>
   </DESCRIPTION_ITEM>
   <DESCRIPTION_ITEM col="0" row="3">
    <LABEL>Benötigte Informationen</LABEL>
    <VALUE>Text</VALUE>
   </DESCRIPTION_ITEM>
   <DESCRIPTION_ITEM col="0" row="4">
    <LABEL>Erzeugte Ergebnisse</LABEL>
    <VALUE>Text</VALUE>
   </DESCRIPTION_ITEM>
   <DESCRIPTION_ITEM col="1" row="0">
    <LABEL>Externe Vorschriften</LABEL>
    <VALUE>Text</VALUE>
   </DESCRIPTION_ITEM>
   <DESCRIPTION_ITEM col="1" row="1">
    <LABEL>Hinweise</LABEL>
    <VALUE>Text</VALUE>
   </DESCRIPTION_ITEM>
   <DESCRIPTION_ITEM col="1" row="2">
    <LABEL>Potenzial</LABEL>
    <VALUE>Text</VALUE>
   </DESCRIPTION_ITEM>
   <DESCRIPTION_ITEM col="1" row="3">
    <LABEL>Mitgeltende Unterlagen</LABEL>
    <VALUE>Text</VALUE>
   </DESCRIPTION_ITEM>
   <DESCRIPTION_ITEM col="1" row="4">
    <LABEL>Offene Fragen</LABEL>
    <VALUE>Text</VALUE>
   </DESCRIPTION_ITEM>
  </DESCRIPTION_TABLE>

and the working template:

<xsl:template match="DESCRIPTION_TABLE">

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


  <fo:table table-layout="fixed" width="100%">

    <xsl:for-each select="DESCRIPTION_ITEM[@row = 0]">
    <fo:table-column column-width="proportional-column-width(1)" />
  </xsl:for-each>


    <fo:table-body font-size="8pt">


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

        <fo:table-cell>
         <fo:block>
  <xsl:call-template name="desc_items"><xsl:with-param name="item"
select="."/></xsl:call-template>
          </fo:block>
        </fo:table-cell>
      </xsl:for-each>
    </fo:table-row>
  </xsl:for-each>

    </fo:table-body>
  </fo:table>
</xsl:template>


any idea, already?

sascha




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



 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]