XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 5th, 2011, 03:39 PM
JimOfSac JimOfSac is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2011
Posts: 8 JimOfSac User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 6 m 44 sec
Reputation Power: 0
Muenchian Method sorting by attribute

Hey all,
I've used the Muenchian Method for sorting and grouping but I've not had any success in using it to group by an attribute. I'm hoping someone here has had this experience and made it work.

Here's a node example from the xml...
Code:
<Products>
    <itm num="123456">
        <properties oid="3897936" cat="8" type="Stuff" series="My Series"/>
        <legacy brand="MyOldBrand" oldNum="654321"/>
    </itm>
</Products>


I'm needing to get a list of all the legacy/@brands that are in the data file

Here's the portion of xslt I've been attempting to do this with...
Code:
<xsl:key name="kProdByBrand" match="itm" use="legacy/@brand"/>

  <xsl:template match="Products">
<xsl:for-each select="itm/legacy[generate-id() = generate-id(key('kProdByBrand', /@brand)[1])]"><xsl:sort select="/@brand" /><xsl:value-of select="/@brand" />|</xsl:for-each>
</xsl:template>


Any help would be appreciated.
Thanks!

Reply With Quote
  #2  
Old August 5th, 2011, 06:18 PM
JimOfSac JimOfSac is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2011
Posts: 8 JimOfSac User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 6 m 44 sec
Reputation Power: 0
Thumbs up

I found a solution. I knew it was just a matter of getting the code just right.

So here it is...

Code:
<xsl:key name="ProdByBrand"  match="//legacy" use="@brand" />
  <xsl:template match="Products"><xsl:for-each select="itm/legacy[generate-id() = generate-id(key('ProdByBrand', @brand)[1])]"><xsl:value-of select="@brand" />|</xsl:for-each>
</xsl:template>

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Muenchian Method sorting by attribute

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap