[XSLTalk] Grouping in a more efficient manner?

I have an XML document which has the following structure:

<Venue state="NSW">
	<CuisineType name="Italian"/>
	<CuisineType name="Australian"/>
</Venue>
<Venue state="NSW">
	<CuisineType name="Italian"/>
</Venue>
<Venue state="QLD">
	<CuisineType name="Italian"/>
</Venue>
<Venue state="QLD">
	<CuisineType name="Mexican"/>
</Venue>
<Venue state="WA">
	<CuisineType name="Chinese"/>
</Venue>

The document currently contains 2171 Venue's and is just over 3MB.

I'm trying to Identify, in the most efficient way possible, each 
unique "Venue/CuisineType/@name" per "Venue/@state". Each Venue 
element can contain more than one CuisineType element.

I've been able to use the following XSLT:
=========================================
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
version="1.1" >
 <xsl:output encoding="UTF-8" cdata-section-elements="script" omit-
xml-declaration="yes" indent="yes" method="xml"/>

 <xsl:key name="cuisineNSW" match="Venue[@state = 'NSW']/CuisineType" 
use="@name"/>
 <xsl:key name="cuisineVIC" match="Venue[@state = 'VIC']/CuisineType" 
use="@name"/>
 <xsl:key name="cuisineQLD" match="Venue[@state = 'QLD']/CuisineType" 
use="@name"/>
 <xsl:key name="cuisineSA" match="Venue[@state = 'SA']/CuisineType" 
use="@name"/>
 <xsl:key name="cuisineWA" match="Venue[@state = 'WA']/CuisineType" 
use="@name"/>

 <xsl:template match="Root">
  <Root>
   <xsl:call-template name="generateUniqueCuisineTypesPerCity">
	<xsl:with-param name="state" select="'NSW'"/>
	<xsl:with-param name="key" select="'cuisineNSW'"/>
   </xsl:call-template>
   <xsl:call-template name="generateUniqueCuisineTypesPerCity">
	<xsl:with-param name="state" select="'VIC'"/>
	<xsl:with-param name="key" select="'cuisineVIC'"/>
   </xsl:call-template>
   <xsl:call-template name="generateUniqueCuisineTypesPerCity">
	<xsl:with-param name="state" select="'QLD'"/>
	<xsl:with-param name="key" select="'cuisineQLD'"/>
   </xsl:call-template>
   <xsl:call-template name="generateUniqueCuisineTypesPerCity">
	<xsl:with-param name="state" select="'SA'"/>
	<xsl:with-param name="key" select="'cuisineSA'"/>
   </xsl:call-template>
   <xsl:call-template name="generateUniqueCuisineTypesPerCity">
	<xsl:with-param name="state" select="'WA'"/>
	<xsl:with-param name="key" select="'cuisineWA'"/>
   </xsl:call-template>
  </Root>
 </xsl:template>
	
 <xsl:template name="generateUniqueCuisineTypesPerCity">
   <xsl:param name="state"/>
   <xsl:param name="key"/>		
   <xsl:for-each select="Venue[@state=$state]/CuisineType[count(. | 
key($key, @name)[1]) = 1]">
	<xsl:sort select="@name"/>
	  <document>			
		<UniqueIdentifier><xsl:value-of 
select="@name"/>_<xsl:value-of select="../@state"/></UniqueIdentifier>
		<state><xsl:value-of select="../@state"/></state>
		<cuisineName><xsl:value-of 
select="@name"/></cuisineName>
	  </document>
   </xsl:for-each>
 </xsl:template>	
</xsl:stylesheet>


However, this seems to take forever to process the huge XML document. 
I'm sure there must be a simpler more efficient solution perhaps 
using just a single key?

Any help/suggestion/ideas would be greatly appreciated!!!

Thanks,
Scott.


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark
Printer at Myinks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/l.m7sD/LIdGAA/qnsNAA/2U_rlB/TM
---------------------------------------------------------------------~->

This discussion list is hosted at TopXML (topxml.com).  If you like what we're doing, please show your support by posting your small code snippets there!  Also, post your tech announcements and news on our new site, Markup World (markupworld.com)

To unsubscribe from this group, send an email to:
XSLTalk-unsubscribe@egroups.com
 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 

Received on Monday, 1 September 2003 03:48:27 UTC