xsl-list
[Top] [All Lists]

RE: Recursion and for-each-group (XSLT 2.0)

2005-04-06 10:52:17
Yup. That works.

Thanks much, Mike.

Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)




"Michael Kay" <mike(_at_)saxonica(_dot_)com> 
04/06/2005 09:41 AM
Please respond to
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com


To
<xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
cc

Subject
RE: [xsl] Recursion and for-each-group (XSLT 2.0)






I suspect what you want is something like this:

<xsl:template name="index-level">
  <xsl:param name="entries" as="element(indexentry)*"/>
  <xsl:for-each-group select="$entries" group-by="@term">
    <xsl:sort select="current-grouping-key()"/>
    <indexentry term="{(_at_)term}"
target="{generate-id(ancestor::*[indexentries][1]}">
      <xsl:call-template name="index-level">
        <xsl:with-param name="entries" 
select="current-group()/indexentry"/>
      </xsl:call-template>
    </indexentry>
  </xsl:for-each-group>
</xsl:template>

<xsl:template match="/">
  <xsl:call-template name="index-level">
    <xsl:with-param name="entries" select="//indexentries/indexentry"/>
  </xsl:call-template>
</xsl:template>

Michael Kay
http://www.saxonica.com/
 

-----Original Message-----
From: JBryant(_at_)s-s-t(_dot_)com [mailto:JBryant(_at_)s-s-t(_dot_)com] 
Sent: 06 April 2005 15:24
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] Recursion and for-each-group (XSLT 2.0)

One question about the structure of your data: is it possible to
encounter

<indexentry term="dog">
  <indexentry term="leg">
</indexentry>
<indexentry term="table">
  <indexentry term="leg">
</indexentry>

and if so, are the two references to "leg" to be combined, or not?
This doesn't arise in your sample, so I can't tell.

Yes, that can happen. No, they shouldn't be combined.

If it helps any, this is the index for a book. The larger 
stylesheet of 
which this solution will eventually be a part is for software 
user guides. 
Ideally, it should support anything you might see in the 
average index.

I have a working solution for three levels of index entries, because 
that's all I ever use. However, the problem of arbitrarily 
deep nested 
grouping interests me in its own right.

Thanks for the help.

Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)

--~------------------------------------------------------------------
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>
--~--





--~------------------------------------------------------------------
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>
--~--




--~------------------------------------------------------------------
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>