Right, well that's a standard grouping problem then:
<xsl:for-each select="Entry" group-by="Subject">
<Subject>
<xsl:value-of select="current-grouping-key()"/>
<xsl:copy-of select="current-group()/Title">
</Subject>
</xsl:for-each>
It won't replicate your indentation but should be otherwise OK.
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Mark Wilson [mailto:drmark(_at_)tlcdelivers(_dot_)com]
Sent: 12 January 2006 14:45
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Collecting sibling nodes under groupings
Hello Michael,
Using real data in an XML fragment, my output would look like:
<SubjectList>
<Subject>Cats
<Title>All about Cats</Title>
<Title>Wildcats I have known</Title>
</Subject>
<Subject>Dogs
<Title>The Dog Lovers handbook</Title>
<Title>Dogs of the American West</Title>
</Subject>
</SubjectList>
from the original XML:
<EntryList>
<Entry>
<Subject>Cats</Subject>
<Title>All about Cats>
</Entry>
<Entry>
<Subject>Cats</Subject>
<Title>Wildcats I have known</Title>
</Entry>
<Entry>
<Subject>Dogs</Subject>
<Title>The Dog Lovers handbook</Title>
</Entry>
<Entry>
<Subject>Dogs</Subject>
<Title>Dogs of the American West</Title>
</Entry>
</EntryList>
I hope this is clearer.
Mark
----- Original Message -----
From: "Michael Kay" <mike(_at_)saxonica(_dot_)com>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Thursday, January 12, 2006 9:17 AM
Subject: RE: [xsl] Collecting sibling nodes under groupings
It's not clear to me what "Some subjects" is. Is this a
list of subjects,
if
so what form does it take? Are you trying to get a single
entry grouped
under more than one subject?
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Mark Wilson [mailto:drmark(_at_)tlcdelivers(_dot_)com]
Sent: 12 January 2006 13:17
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Collecting sibling nodes under groupings
It was suggested that I resubmit my question with a more
specific subject
line.
I am building a library catalog for my club. I put each
book's description
in an XML sequence like (but simplified)
<List>
<Entry>
<Subject>Some Subjects</Subject>
<Title>Some Title</Title>
<Publisher>Some Publisher</Publisher>
</Entry>
.......
</List>
Using Saxon 8, I then did a grouping using XSLT 2.0's new
grouping element
so that I get a list of all the subjects, but only a single
entry for each.
Now I want to create:
<List>
<Subject>First Subject
<Title> First title associated with this subject</Title>
<Publisher>Publisher associated with this
title</Publisher>
<Title> Next title associated with this subject</Title>
<Publisher>Publisher associated with this
title</Publisher>
</Subject>
.....
</List>
More to the point, I want to collect all of the sibling nodes
from an entry
with all of the sibling nodes from other entries that share
the same subject
value. I have really looked and just failed to understand
what I am looking
at. The examples appear to show how to collect attributes,
but not how to
collect sibling nodes. My attemps have all failed.
Thanks,
Mark
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--