xsl-list
[Top] [All Lists]

RE: Sorted headers of multiple occurance child nodes

2005-09-14 08:11:21
This looks like a standard grouping problem: use Muenchian grouping as per
http://www.jenitennison.com/xslt/grouping

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

-----Original Message-----
From: Brian Huntington [mailto:bhuntington(_at_)agu(_dot_)org] 
Sent: 14 September 2005 15:20
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Sorted headers of multiple occurance child nodes

Using Saxon 6.5.2 to process XSLT 1.1

I would like to write sorted headers of /record/node values 
whose values 
may occur more than once in a document. I'm having a pretty 
tough go of 
conceptualizing how to accomplish this. I've checked the xsl-list 
archives, and other online resources, but I haven't found anything 
usefull. Any advice would be much appreciated.

Here's dummy XML source, to demonstrate the challenge:

<tableOfContents>
<record>
      <author>Mr. Jones</author>
      <title>An article by Mr. Jones</title>
      <journalTitle>Journal of Oceanography</journalTitle>
      <subject>Oceanography</subject>
</record>
<record>
      <author>Ms. Smith</author>
      <title>An article by Ms. Smith</title>
      <journalTitle>Oceanic Reviews</journalTitle>
      <subject>Oceanography</subject>
</record>
<record>
      <author>Mr. Turner</author>
      <title>An article by Mr. Turner</title>
      <journalTitle>Journal of Volcanology</journalTitle>
      <subject>Volcanology</subject>
</record>
<record>
      <author>Dr. Love</author>
      <title>An article by Dr. Love</title>
      <journalTitle>Modern Psychology</journalTitle>
      <subject>Psychology</subject>
</record>
<record>
      <author>Ms. Walker</author>
      <title>An article by Ms. Walker</title>
      <journalTitle>Volcanos and Stuff</journalTitle>
      <subject>Volcanology</subject>
</record>
</tableOfContents>

The objective is to produce the following output. Markup and 
whitespace 
are incidental, I'm concerned with outputting headers and 
sorting on the 
subject node value, where the value may occur multiple times in the 
input XML.

<html>
<h1>Table of Contents</h1>
<h2>Oceanography</h2>
   <p>Mr. Jones, <b>An article by Mr. Jones</b>, <i>Journal of 
Oceanography</i></p>
   <p>Ms. Smith, <b>An article by Ms. Smith</b>, <i>Oceanic 
Reviews</i></p>
<h2>Psychology</h2>
   <p>Dr. Love, <b>An article by Dr. Love</b>, <i>Modern 
Psychology</i></p>
<h2>Volcanology</h2>
   <p>Mr. Turner, <b>An article by Mr. Turner</b>, <i>Journal of 
Volcanology</i></p>
   <p>Ms. Walker, <b>An article by Ms. Walker</b>, <i>Volcanos and 
Stuff</i></p>
</html>

Again, any help would be mucho appreciated.
Brian Huntington



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