This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Maybe newbie...
- From: Antonio Fiol <fiol at w3ping dot com>
- To: XSL-List <XSL-List at lists dot mulberrytech dot com>
- Date: Fri, 17 May 2002 15:42:11 +0200
- Subject: [xsl] Maybe newbie...
- Reply-to: xsl-list at lists dot mulberrytech dot com
MY CODE WORKS, SO DO NOT WASTE YOUR TIME IF YOU DO NOT HAVE MUCH...
I have this (working) template:
<xsl:template match="alarmhistory">
<table border="1" cellspacing="0" cellpadding="3">
<tr>
<th bgcolor="#6699CC"><font color="#FFFFFF">D?but</font></th>
<th bgcolor="#6699CC"><font color="#FFFFFF">Fin</font></th>
<th bgcolor="#6699CC"><font color="#FFFFFF">Quantit?</font></th>
<th bgcolor="#6699CC"><font color="#FFFFFF">Type de probl?me</font></th>
</tr>
<xsl:for-each select="alarm">
<xsl:for-each select="problemtype">
<tr>
<xsl:choose>
<xsl:when test="position()=1">
<td><xsl:value-of select="../@start" /></td>
<td><xsl:value-of select="../@end" /></td>
</xsl:when>
<xsl:otherwise>
<td></td><td></td>
</xsl:otherwise>
</xsl:choose>
<td><xsl:value-of select="@qty" /></td>
<td><xsl:value-of select="@type" /></td>
</tr>
</xsl:for-each>
</xsl:for-each>
</table>
</xsl:template>
Which, when applied to the following part of a document:
<alarmhistory>
<alarm start="2002-01-01" end="2002-02-01">
<problemtype qty="3" type="10"/>
<problemtype qty="4" type="6"/>
</alarm>
<alarm start="2002-03-01" end="2002-04-01">
<problemtype qty="1" type="3"/>
<problemtype qty="2" type="4"/>
</alarm>
</alarmhistory>
Generates a beautiful 4-row HTML code, which renders a title row,
followed by two two-row descriptions of alarm events (the start date and
end date show on row 1 of each two-row groups).
I think that using two nested for-each is quite dirty in my case, as a
very similar effect could be achieved with a <xsl:for-each
select="alarm/problemtype">.
However, when using that one, position() is not 1, 2, 1, 2 but 1, 2, 3,
4, so the third line does not show the dates, where it should.
I know I can substitute position by something else, but... what?
Thank you.
Antonio Fiol
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list