[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Unique question

Subject: Re: Unique question
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Thu, 4 Oct 2001 21:26:57 -0700 (PDT)
 Re: Unique question
Hi Daren,

This is a short solution:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="text"/>
  <xsl:key name="kIndex" match="@index" use="."/>
  <xsl:template match="/">
    <xsl:variable name="x">
       <xsl:for-each select="/*/*/*/*/@index
                          [generate-id()
                          =
                           generate-id(key('kIndex', .)[1])]">
            <xsl:value-of select="'Z'"/>
       </xsl:for-each>
    </xsl:variable>
    
    <xsl:value-of select="string-length($x)"/>
  </xsl:template>
</xsl:stylesheet>

It produces:

4

with the corrected version of your xml source (it was not well-formed):

<groups>
  <group>
    <tables>
      <table index="1" />
      <table index="2" />
    </tables>
    <views>
      <view index="3" />
      <view index="4" />
    </views>
  </group>
  <group>
    <tables>
      <table index="1" />
    </tables>
    <views>
      <view index="1" />
    </views>
  </group>
</groups>

Hope this helped.

Cheers,
Dimitre Novatchev.


Darren Hayduk <dhayduk at nauticusnet dot com> wrote:

I'm trying to take the XPath expression "*/*/@index" and determine how many
unique vales there are - within my current context.
I've tried various axis expressions and can't seem to figure it out... I'd
be happy with either: 
A. the ability to count the unique nodes (and I'll compare to count of all
nodes)
B. just knowing there are duplicates.

Example: Within each group, the table and view indexes need to be unique.
Data in first group is OK, the 'view' in the second group is a duplicate...

<group>
	<tables>
		<table index="1"/>
		<table index="2"/>
	</tables/>		
	<views>
		<view index="3"/>
		<view index="4"/>
	</views/>		
</group>
<group>
	<tables>
		<table index="1"/>
	</tables/>		
	<views>
		<view index="1"/>
	</views/>		
</group>




__________________________________________________
Do You Yahoo!?
NEW from Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.