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

RE: Grouping into duplicates and non duplicate lists

Subject: RE: Grouping into duplicates and non duplicate lists
From: "Cavanagh, Tim (DFEEST)" <Tim.Cavanagh@xxxxxxxxx>
Date: Sat, 14 Nov 2009 13:14:02 +1030
RE:  Grouping into duplicates and non duplicate lists
Hi David,

Thanks for that. I have put it together and it works!! It does not look too
elegant and I need to use 2 keys to do what I want. Here is the template if
anyone has any suggestions for improving - happy to take on board... Thanks
again:

<xsl:template match="CourseNote">
		<xsl:variable name="sgcount" select="count(CourseNoteItem[count(. |
key('CN-SG', concat(Year, StudyGroupCode))[1]) = 1])" />
		<xsl:if test="CourseNoteItem[count(. | key('CN-T', concat(Year,
CourseNoteText))[1]) = 1][count(key('CN-T', concat(Year,
CourseNoteText)))=$sgcount]">
			<strong>Applies to all Study Groups</strong>
			<br />
			<ul>
				<xsl:for-each select="CourseNoteItem[count(. | key('CN-T', concat(Year,
CourseNoteText))[1]) = 1][count(key('CN-T', concat(Year,
CourseNoteText)))=$sgcount]">
					<xsl:sort select="DisplaySequence" />
					<li>
						<xsl:copy-of select="CourseNoteText/node()" />
					</li>
				</xsl:for-each>
			</ul>
		</xsl:if>
		<xsl:for-each select="CourseNoteItem[count(. | key('CN-SG', concat(Year,
StudyGroupCode))[1]) = 1]">
			<xsl:sort select="StudyGroupOrder" />
			<xsl:if test="key('CN-SG', concat(Year, StudyGroupCode))[count(key('CN-T',
concat(Year, CourseNoteText)))!=$sgcount]">
				<strong>
					<xsl:value-of select="StudyGroupName" /> - Only</strong>
				<br />
				<ul>
					<xsl:for-each select="key('CN-SG', concat(Year,
StudyGroupCode))[count(key('CN-T', concat(Year,
CourseNoteText)))!=$sgcount]">
						<li>
							<xsl:copy-of select="CourseNoteText/node()" />
						</li>
					</xsl:for-each>
				</ul>
			</xsl:if>
		</xsl:for-each>
	</xsl:template>


Tim Cavanagh
Senior Technical Architect
PH: 0434 079402   FAX:  8207 8554

-----Original Message-----
From: David Carlisle [mailto:davidc@xxxxxxxxx]
Sent: Saturday, 14 November 2009 10:09 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Grouping into duplicates and non duplicate lists


not looked in detail at your example, just perhaps just answering this
bit iis enough

>  I am familiar with keys and get get lists of unigue items and group
>  them but I cannot exclude the items that do not appear in all
>  StudyGroups...

one way

<xsl:key name="sg" match="studyroup" use="item"/>

then <xsl:variable name="n" select="count(studygroup)"/>

so to know if . the current item is in all groups you can test
count(key('sg',.))=$n
as if it is in all groups then the key will return them all

David


________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs.
________________________________________________________________________

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.