This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: counter in xsl
- From: "Ilyasov Jienbay" <jienbay at hotmail dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Fri, 08 Feb 2002 11:39:48 +0000
- Subject: Re: [xsl] counter in xsl
- Reply-to: xsl-list at lists dot mulberrytech dot com
hi,
...but i cant access position().
i want to <position() mod 2=0> in *outer* <tr> of a <table> for the
<bgcolor>.
what can i do? here is my xsl, and xml.
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="prose.xsl" ?>
<items>
<item>
<id>xx0xx</id>
<name>ジャン</name>
<user-id>ohtani@ariel-networks.com</user-id>
<last-modified>20000122T022200</last-modified>
<created>20000106T115305</created>
<attachment>file.txt</attachment>
<refer>新文書のid</refer>
<revision>20000106T115305</revision>
<axpire>20000106T115305</axpire>
<private>no</private>
<delete>no</delete>
</item>
<item>
<id>xx1xx</id>
<name>おおたに</name>
<user-id>ohtani@ariel-networks.com</user-id>
<last-modified>20000105T022200</last-modified>
<created>20000106T115305</created>
<attachment>file.txt</attachment>
<refer>新文書のid</refer>
<revision>20000106T115305</revision>
<axpire>20000106T115305</axpire>
<private>no</private>
<delete>no</delete>
</item>
<item>
<id>xx2xx</id>
<name>おおたに</name>
<user-id>ohtani@ariel-networks.com</user-id>
<last-modified>20000105T121210</last-modified>
<created>20000106T115305</created>
<attachment>file.txt</attachment>
<refer>新文書のid</refer>
<revision>20000106T115305</revision>
<axpire>20000106T115305</axpire>
<private>no</private>
<delete>no</delete>
</item>
<item>
<id>xx3xx</id>
<name>おおたに</name>
<user-id>ohtani@ariel-networks.com</user-id>
<last-modified>20000106T115305</last-modified>
<created>20000106T115305</created>
<attachment>file.txt</attachment>
<refer>新文書のid</refer>
<revision>20000106T115305</revision>
<axpire>20000106T115305</axpire>
<private>no</private>
<delete>no</delete>
</item>
<item>
<id>xx4xx</id>
<name>おおたに</name>
<user-id>ohtani@ariel-networks.com</user-id>
<last-modified>20000105T230258</last-modified>
<created>20000106T115305</created>
<attachment>file.txt</attachment>
<refer>新文書のid</refer>
<revision>20000106T115305</revision>
<axpire>20000106T115305</axpire>
<private>no</private>
<delete>no</delete>
</item>
<item>
<id>xx5xx</id>
<name>いわた</name>
<user-id>ohtani@ariel-networks.com</user-id>
<last-modified>20000105T164315</last-modified>
<created>20000106T115305</created>
<attachment>file.txt</attachment>
<refer>新文書のid</refer>
<revision>20000106T115305</revision>
<axpire>20000106T115305</axpire>
<private>no</private>
<delete>no</delete>
</item>
<item>
<id>xx6xx</id>
<name>いわた</name>
<user-id>ohtani@ariel-networks.com</user-id>
<last-modified>20000105T124552</last-modified>
<created>20000106T115305</created>
<attachment>file.txt</attachment>
<refer>新文書のid</refer>
<revision>20000106T115305</revision>
<axpire>20000106T115305</axpire>
<private>no</private>
<delete>no</delete>
</item>
<item>
<id>xx7xx</id>
<name>ジャン</name>
<user-id>ohtani@ariel-networks.com</user-id>
<last-modified>20000825T142945</last-modified>
<created>20000106T115305</created>
<attachment>file.txt</attachment>
<refer>新文書のid</refer>
<revision>20000106T115305</revision>
<axpire>20000106T115305</axpire>
<private>no</private>
<delete>no</delete>
</item>
<item>
<id>xx8xx</id>
<name>ジャン</name>
<user-id>ohtani@ariel-networks.com</user-id>
<last-modified>20000825T214550</last-modified>
<created>20000106T115305</created>
<attachment>file.txt</attachment>
<refer>新文書のid</refer>
<revision>20000106T115305</revision>
<axpire>20000106T115305</axpire>
<private>no</private>
<delete>no</delete>
</item>
<item>
<id>xx9xx</id>
<name>おおたに</name>
<user-id>ohtani@ariel-networks.com</user-id>
<last-modified>20000825T211230</last-modified>
<created>20000106T115305</created>
<attachment>file.txt</attachment>
<refer>新文書のid</refer>
<revision>20000106T115305</revision>
<axpire>20000106T115305</axpire>
<private>no</private>
<delete>no</delete>
</item>
<item>
<id>xx10xx</id>
<name>たなか</name>
<user-id>ohtani@ariel-networks.com</user-id>
<last-modified>20000812T142423</last-modified>
<created>20000106T115305</created>
<attachment>file.txt</attachment>
<refer>新文書のid</refer>
<revision>20000106T115305</revision>
<axpire>20000106T115305</axpire>
<private>no</private>
<delete>no</delete>
</item>
</items>
and xsl is:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:arx="http://www.ariel-networks.com/airone/xalan-ext" version="1.0"
exclude-result-prefixes="arx">
<xsl:output method="html" version="4.01" />
<xsl:param name="somanet_id" />
<xsl:param name="appname" />
<xsl:param name="theme" />
<xsl:key name="lastkey" match="item" use="substring(last-modified,1,8)"/>
<xsl:template match="/">
<html><head><title>Same As Above</title></head>
<body>
<table border="1">
<xsl:apply-templates
select="//item[generate-id(.)=generate-id(key('lastkey',
substring(last-modified,1,8))[1])]" mode="a">
<xsl:sort select="substring(last-modified,1,8)"/>
</xsl:apply-templates>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="//item" mode="a">
<xsl:apply-templates select="key('lastkey',
substring(last-modified,1,8))">
<xsl:sort select="last-modified"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="//item">
<tr>
<xsl:attribute name="bgcolor">
<xsl:choose>
<xsl:when test="position()=1">
<xsl:text>pink</xsl:text>
</xsl:when>
<xsl:when test="position() !=1">
<xsl:if test="position() mod 2=0">
<xsl:text>#e7f2ff</xsl:text>
</xsl:if>
</xsl:when>
</xsl:choose>
</xsl:attribute>
<xsl:choose>
<xsl:when test="position()=1">
<td><xsl:value-of select="substring(last-modified,1,8)"/></td>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="substring(last-modified,10,4)"/></td>
</xsl:when>
<xsl:otherwise><td></td>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="substring(last-modified,10,4)"/></td>
</xsl:otherwise>
</xsl:choose>
</tr>
</xsl:template>
</xsl:stylesheet>
_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list