This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: 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() < ($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()
<= $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() < $cols]"/>
</xsl:when>
<xsl:when test="$by = 'col'">
<xsl:apply-templates select="(. |
following-sibling::REGISTRO)[position() < ($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