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: Unique question


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


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