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: Carlos Problem (II) how to show some results y some places:


Hello Carlos,

Another solution it is based at the first xml you send to this list.

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:param name="row" select="3"/>
  <xsl:strip-space elements="*"/>

  <xsl:template match="/NUMBERS">
 <html>
  <head/>
  <body>

   <table border="1">
    <tr>
    <!-- select the first 3 nodes -->
       <xsl:apply-templates select='NUMBER[(position() &lt; $row) or
(position() = $row) ]'/>
    </tr>
   </table>
  </body>
 </html>
  </xsl:template>

 <xsl:template match="NUMBER">
 <td>
   <xsl:apply-templates />
  </td>
  </xsl:template>


  <xsl:template match="VALUE">
 <xsl:value-of select="."/>
 <xsl:text>&#x20;</xsl:text>
<!-- select the node which is $row numbers from the current node -->
<xsl:apply-templates select="../following::NUMBER[$row]/VALUE"/>
  </xsl:template>

</xsl:stylesheet>

----- Original Message -----
From: "Carlos" <linux@lpis.com>
To: <xsl-list@lists.mulberrytech.com>
Sent: Friday, May 10, 2002 10:45 AM
Subject: Re: [xsl] Carlos Problem (II) how to show some results y some
places:


> is a very good method but i need other thing; in the fist td 1 4 7
elements,
> in the second 2 5 8 in the tree elemnt 3 6 9
> can anybody help me please, i must to solve this problem in my hob, i am
> exasperated, i am working in this problem one week and i cannot solve.
> please help me
>
>
> i want to present in this form:
> <table>
> <tr>
> <td>1 4 7....</td><td>2 5 8....</td><td>3 6 9....</td>
> </tr>
> </table>
> and i dont want:
> <table>
> <tr>
> <td>1</td><td>2</td><td>3</td>
> </tr>
> <tr>
> <td>4</td><td>5</td><td>6</td>
> </tr>
> <tr>
> <td>7</td><td>8</td><td>9</td>
> </tr>
> </table>
>
> i have this xml and this 2 xslt tempaltes but i dont know how to lake in
> correct mode
>
> ##################
> XML
> ##################
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <INMOBILIARIAS>
>     <REGISTRO>
>         <REFERENCIA>1
>         </REFERENCIA>
>     </REGISTRO>
>     <REGISTRO>
>         <REFERENCIA>2
>         </REFERENCIA>
>      </REGISTRO>
>     <REGISTRO>
>         <REFERENCIA>3
>         </REFERENCIA>
>      </REGISTRO>
>     <REGISTRO>
>         <REFERENCIA>4
>         </REFERENCIA>
>     </REGISTRO>
>     <REGISTRO>
>         <REFERENCIA>5
>         </REFERENCIA>
>     </REGISTRO>
>     <REGISTRO>
>         <REFERENCIA>6
>         </REFERENCIA>
>     </REGISTRO>
>     <REGISTRO>
>         <REFERENCIA>7
>         </REFERENCIA>
>      </REGISTRO>
>     <REGISTRO>
>         <REFERENCIA>8
>         </REFERENCIA>
>      </REGISTRO>
>     <REGISTRO>
>         <REFERENCIA>9
>         </REFERENCIA>
>      </REGISTRO>
> </INMOBILIARIAS>
>
> #####################
> the XSL
> ####################
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> version="1.0">
> <xsl:output method="html"/>
> <xsl:param name="cols" select="3"/>
> <xsl:param name="rows" select="3"/>
> <xsl:param name="by" select="'row'"/>
> <xsl:template match="/INMOBILIARIAS">
>     <html>
>         <head></head>
>         <body>
>             <xsl:apply-templates select="REGISTRO[position() mod ($rows *
> $cols) = 1]" mode="table"/>
>         </body>
>     </html>
> </xsl:template>
>
> <xsl:template match="REGISTRO" mode="table">
>     <table border="1">
>         <xsl:variable name="items-in-this-table" select=". |
> following-sibling::REGISTRO[position() &lt; ($rows * $cols)]"/>
>         <xsl:choose>
>             <xsl:when test="$by = 'row'">
>                 <xsl:apply-templates
select="$items-in-this-table[position()
> mod $cols = 1]" mode="row"/>
>             </xsl:when>
>             <xsl:when test="$by = 'col'">
>                 <xsl:apply-templates
select="$items-in-this-table[position()
> &lt;= $rows]" mode="row"/>
>             </xsl:when>
>         </xsl:choose>
>         <!-- here you can implement some logic for filling the last table,
> if there are not enough items to fill all <td>s -->
>     </table>
> </xsl:template>
>
> <xsl:template match="REGISTRO" mode="row">
>     <tr>
>         <xsl:choose>
>             <xsl:when test="$by = 'row'">
>                 <xsl:apply-templates select=". |
> following-sibling::REGISTRO[position() &lt; $cols]"/>
>             </xsl:when>
>             <xsl:when test="$by = 'col'">
>                 <xsl:apply-templates select="(. |
> following-sibling::REGISTRO)[position() &lt; ($cols * $rows)][position()
mod
> $rows = 1]"/>
>             </xsl:when>
>         </xsl:choose>
>     </tr>
> </xsl:template>
> <xsl:template match="REGISTRO">
>     <td>
>        <xsl:value-of select="./REFERENCIA"/><br/>
>     </td>
> </xsl:template>
> </xsl:stylesheet>
>
> #######################
> or this XSLT template
> #######################
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> version="1.0">
> <xsl:output method="html"/>
>   <xsl:template match="/">
>        <xsl:apply-templates select="*" />
>   </xsl:template>
>   <xsl:template match="/">
> <table border="2" width="200">
> <tr>
> <xsl:for-each select="/INMOBILIARIAS/REGISTRO">
> <xsl:if test="position() mod 3 = 1 or position()=1">
> <xsl:call-template name="Make3ColumnRow">
> <xsl:with-param name="FirstItemPositionNo">
> <xsl:value-of select="position()"/>
> </xsl:with-param>
> </xsl:call-template>
> </xsl:if>
> </xsl:for-each>
> </tr></table>
> </xsl:template>
> <xsl:template name="Make3ColumnRow">
> <xsl:param name="FirstItemPositionNo"/>
> <tr>
> <td >
> <xsl:value-of
>
select="/INMOBILIARIAS/REGISTRO[position()=$FirstItemPositionNo]/REFERENCIA"
> /><BR/>
> </td>
> <td >
> <xsl:value-of
>
select="/INMOBILIARIAS/REGISTRO[position()=$FirstItemPositionNo+1]/REFERENCI
> A"/><BR/>
> </td>
> <td >
> <xsl:value-of
>
select="/INMOBILIARIAS/REGISTRO[position()=$FirstItemPositionNo+2]/REFERENCI
> A"/><BR/>
> </td></tr>
>   </xsl:template>
> </xsl:stylesheet>
>
>
>
>
>
>  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]