[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: math get maximum and subtract 1

Subject: RE: math get maximum and subtract 1
From: "Américo Albuquerque" <aalbuquerque@xxxxxxxxxxxxxxxx>
Date: Tue, 30 Jul 2002 11:58:07 +0100
xsl subtract
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@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of sascha
Sent: Monday, July 29, 2002 1:23 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  math get maximum and subtract 1



----- Original Message -----
From: "Jeni Tennison" <jeni@xxxxxxxxxxxxxxxx>
Subject: Re:  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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.