This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re:Re:in for-each: absolut position
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] Re:Re:in for-each: absolut position
- From: "Yang" <sfyang at unisvr dot net dot tw>
- Date: Fri, 21 Sep 2001 19:39:43 +0800
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi, Jochen:
I use <xsl:number> element to print out the absolute postion in
the document file.
>A good idea is to use "::" in the concat.
The reason using '::'' in the concat is to avoid possible collision to node
name inside of xml documentation,
you can check jeni site about this.
I try to keep your xslt inattack as much as possible, so I remove
<xsl:if> element in the second template since it is redundant to one of
conditions of the first template.
I add the the third template to get each absolute position print and
with mode **zeile** to distinguish it from the second template.
A revised xslt list is attached for your reference.
I hope someone in this list could provide u a better solution.
Cheers,
Sun-fu Yang
sfyang@unisvr.net.tw
<?xml version="1.0" encoding="ISO-8859-1" ?>
- <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/TR/REC-html40">
<xsl:output method="html" />
<xsl:strip-space elements="*" />
<xsl:key name="rowkey" match="row" use="concat(@name0,'::',@name1)" />
- <xsl:template match="/gentable">
<xsl:apply-templates select="//row[generate-id(.) =
generate-id(key('rowkey',concat(@name0,'::'@name1))[1])
and count(key('rowkey',concat(@name0,'::',@name1)))>1]" />
</xsl:template>
- <xsl:template match="row">
<xsl:variable name="v_name0" select="@name0" />
<xsl:variable name="v_name1" select="@name1" />
<xsl:variable name="keys"
select="key('rowkey',concat(@name0,'::',@name1))" />
<xsl:variable name="anzahl" select="count($keys)" />
Eintrag '
<xsl:value-of select="@name0" />
,
<xsl:value-of select="@name1" />
' ist
<xsl:value-of select="$anzahl" />
-fach definiert. Zeile
<xsl:apply-templates select="$keys" mode="zeile" />
</xsl:template>
- <xsl:template match="row" mode="zeile">
- <!-- get line number on the document file
-->
<xsl:number />
- <xsl:if test="position()!=last()">
<xsl:text>;</xsl:text>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list