This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Assistance with the Muenchian method


Hi Garrel,

> <xsl:template match="userData">
>   <xsl:for-each
> select="publish/website[generate-id()=generate-id(key('groups-by-wid',
> @wid)[1])]">
>     <xsl:sort select="@path"/>
>     <xsl:variable name="wid" select="@wid"/>
>     <xsl:for-each select="key('groups-by-wid', $wid)">
>       <xsl:variable name="path" select="@path"/>
>       <xsl:variable name="wid" select="@wid"/>
>       <option value="{$wid}"><xsl:value-of select="$path"/></option>
>     </xsl:for-each>
>   </xsl:for-each>
> </xsl:template>

In the above, you select the websites with unique wids absolutely
correctly. Then you sort them, and then you collect together all the
websites with the same wid and create an option for each of them. The
above code is equivalent to selecting all the websites at once and
sorting them by wid:

  <xsl:for-each select="publish/website">
    <xsl:sort select="@path" />
    <option value="{@wid}"><xsl:value-of select="@path" /></option>
  </xsl:for-each>

Instead, you only want to create the option for the unique websites,
so scrap the inner xsl:for-each and just do:

  <xsl:for-each select="publish/website
                          [generate-id()=
                           generate-id(key('groups-by-wid', @wid)[1])]">
    <xsl:sort select="@path"/>
    <option value="{@wid}"><xsl:value-of select="@path"/></option>
  </xsl:for-each>

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]