[xsl] RE: Unique question

Subject: [xsl] RE: Unique question
From: Darren Hayduk <dhayduk@xxxxxxxxxxxxxxx>
Date: Fri, 5 Oct 2001 14:15:34 -0400
Thanks to Joerg and Dimitre for your thoughts on my count unique question.

After posting my question, I started playing with Saxon and temporary
node-sets to solve the problem, and it seems much easier with v1.1:
    <xsl:for-each select="/groups/group">
      <xsl:variable name="indexes">
        <xsl:for-each select="*/*[@index!='']">
          <xsl:copy>
            <xsl:value-of select="@index"/>
          </xsl:copy>
        </xsl:for-each>
      </xsl:variable>
      <xsl:if test="count(*/*[@index!='']) !=
count($indexes/*[not(.=preceding::*)])">
        <!-- ERROR -->
      </xsl:if>
    </xsl:for-each>

-----Original Message-----
Now, when I'm completely awake, I see that the problem was to count the
unique
"index" attributes ***within a group***.

<xsl:key name="kIndex" match="@index" 
         use="concat(generate-id(../../..), '~',.)"/>

Then if $x contains the position of the "group", for which we need to know
the count
of unique "index" attributes, the following XPath expression returns this
count:

count(
/groups/group[$x]/*/*/@index[generate-id() 
                            = 
                            generate-id(key('kIndex', 
 
concat(generate-id(/groups/group[$x]),
                                                   '~',
                                                   .)
                                           )[1]
                                       )
                            ]
     )


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


Current Thread