[xsl] Re:Re:in for-each: absolut position

Subject: [xsl] Re:Re:in for-each: absolut position
From: "Yang" <sfyang@xxxxxxxxxxxxx>
Date: Fri, 21 Sep 2001 19:39:43 +0800
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.


Sun-fu Yang

<?xml version="1.0" encoding="ISO-8859-1" ?>
- <xsl:stylesheet version="1.0"
  <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(.) =
 and count(key('rowkey',concat(@name0,'::',@name1)))>1]" />
- <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 match="row" mode="zeile">
- <!--    get line number on the document file
  <xsl:number />
- <xsl:if test="position()!=last()">

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread