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:


<xsl:param name="cols" select="3"/>

<!-- Selects the ART-elements, which are at the beginning of a row. -->
<xsl:template match="ARTS">
   <table border="1">
     <xsl:apply-templates select="ART[position() mod $cols = 1]" 
mode="row"/>
   </table>
</xsl:template>

<!-- Selects the first ART of a row and the rest in this row. -->
<xsl:template match="ART" mode="row">
   <tr>
     <xsl:apply-templates select=". | following-sibling::ART[position() 
&lt; $cols]" mode="cell"/>
   </tr>
</xsl:template>

<!-- Add the cells. -->
<xsl:template match="ART" mode="cell">
   <td><xsl:value-of select="NAME"/></td>
</xsl:template>

Regards,

Joerg

Carlos schrieb:
> If i have, i have writted bellow xml file, how can i present this file in
> this form:
> <tr><td>1</td><td>2</td><td>3</td></tr>
> <tr><td>4</td><td>5</td><td>6</td></tr>
> 
> this is my intention:
> to format the xml file in a html but only with 3 celds but x rows.
> if i make a foreach i only know ,to writte i a celd, only one row, but i
> want to writte in three celds.
> is posible?
> can anybody helps me?
> thanks
> 
> 
> 
> ############
> XML FILE
> ############
> <?xml version="1.0" encoding="UTF-8"?>
> <ARTS>
>     <ART>
>         <NAME>1
>         </NAME>
>         <VALUE>11
>         </VALUE>
>     </ART>
>     <ART>
>         <NAME>2
>         </NAME>
>         <VALUE>22
>         </VALUE>
>     </ART>
>     <ART>
>         <NAME>3
>         </NAME>
>         <VALUE>33
>         </VALUE>
>     </ART>
>     <ART>
>         <NAME>4
>         </NAME>
>         <VALUE>44
>         </VALUE>
>     </ART>
>     <ART>
>         <NAME>5
>         </NAME>
>         <VALUE>55
>         </VALUE>
>     </ART>
>     <ART>
>         <NAME>6
>         </NAME>
>         <VALUE>66
>         </VALUE>
>     </ART>
>     <ART>
>         <NAME>7
>         </NAME>
>         <VALUE>77
>         </VALUE>
>     </ART>
>     <ART>
>         <NAME>8
>         </NAME>
>         <VALUE>88
>         </VALUE>
>     </ART>
> </ARTS>


 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]