This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re:Re:in for-each: absolut position


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]