I've been banging my head against a brick wall for a few days now. Having
seen the level of expertise here, and given my own preliminary stumblings
in xml and xslt, I feel a little foolish trying to poach some assistance
when I really ought to be studying more, but I don't seem to be able to
find any answers. I'd be very grateful for any assistance with the
following problem:
I have the following XML:
<newsbriefs>
<item>
<date>2001-02-08</date>
<title>Newsletter No. 14</title>
<category type="news"/>
<jurisdiction name="All"/>
<summary>The Regie des Rentes has released an English
version of La Lettre No. 14, which discusses the changes brought about by
Bill 102.</summary>
<source>
<link
href="http://www.rrq.gouv.qc.ca/an/prive/lettrercr/lettre14.htm">Newsletter</link>
</source>
<news/>
<backgrounders/>
<progress>
<first_reading/>
<second_reading/>
<third_reading/>
<royal_assent/>
<in_force/>
</progress>
<subjects>
<subject_ref reference="pensions"/>
<subject_ref reference="governance"/>
</subjects>
</item>
<item>
<date>2001-02-09</date>
<title>Labour Force statistics</title>
<category type="news"/>
<jurisdiction name="All"/>
<summary>Employment was virtually unchanged in January.
The unemployment rate edged up 0.1 percentage points to 6.9%.</summary>
<source>
<link
href="http://www.statcan.ca/Daily/English/010209/d010209a.htm">StatsCan
Daily</link>
</source>
<news/>
<backgrounders/>
<progress>
<first_reading/>
<second_reading/>
<third_reading/>
<royal_assent/>
<in_force/>
</progress>
<subjects>
<subject_ref reference="general"/>
</subjects>
</item>
Many of the <item>s in my file have multiple <subject_ref> tags. I'm trying
(with no success) to find a way to group them by subject_ref/@reference,
but with no luck. I've gone through the archives, and found reference to a
solution by Steve Muench involving the use of keys. I've (very
unsuccessfully) tried to make the following work:
<xsl:key name="group" match="subject_ref" use="@reference"/>
[...]
<xsl:for-each
select="//subject_ref[generate-id(.)=generate-id(key('group',
@reference)[1])]">
[...]
Do I have a problem because of the fact that I have more than one
<subject_ref > child for many of the <subjects> nodes in my xml?
I would really appreciate any pointers on how to make this work.
Chris D'Iorio
inRatio Inc.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list