Subject: RE: [xsl] Grouping into duplicates and non duplicate lists From: "Cavanagh, Tim (DFEEST)" <Tim.Cavanagh@xxxxxxxxx> Date: Sat, 14 Nov 2009 13:14:02 +1030 |
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: [xsl] 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Grouping into duplicates , David Carlisle | Thread | [xsl] Unknown system function escap, Tim Lebo |
Re: [xsl] Grouping into duplicates , David Carlisle | Date | [xsl] Do xsl processors contain opt, cert21 |
Month |