xsl-list
[Top] [All Lists]

Re: [xsl] Generating a unique listing of elements from multiple sets

2007-01-25 06:42:06
It works!  Thanks David!  

Glen

--- David Carlisle <davidc(_at_)nag(_dot_)co(_dot_)uk> wrote:


Your input wasn't well formed but after fixing that,
i think this does
what you want. Th e"uniqueness" aspect is automatic
given xpath1's node
set semantics as sets never have repeated values.


<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  
<xsl:key name="c" match="country" use="@id"/>
<xsl:key name="cg" match="countryGroup"
use="@groupID"/>

 <xsl:template match="data">
   <xsl:apply-templates
select="businesses/business"/>
 </xsl:template>

 <xsl:template match="business">
   <xsl:text>
</xsl:text>
   <xsl:value-of select="name"/>
   <xsl:text>: </xsl:text>
   <xsl:for-each

select="key('c',key('cg',countryGroup/@included)/country/@included)">
     <xsl:value-of select="."/>
     <xsl:text> </xsl:text>
   </xsl:for-each>
 </xsl:template>

</xsl:stylesheet>

$ saxon gm.xml gm.xsl
<?xml version="1.0" encoding="utf-8"?>
Acme: United States Mexico 
Another Acme: Canada Mexico 


David

oops I just use saxon on the command line, silly
me:-)



--~------------------------------------------------------------------
XSL-List info and archive: 
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





 
____________________________________________________________________________________
It's here! Your new message!  
Get new email alerts with the free Yahoo! Toolbar.
http://tools.search.yahoo.com/toolbar/features/mail/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>