[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Sorting things on two levels

Subject: Sorting things on two levels
From: "Michele R Combs mrrothen@xxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 14 Apr 2015 14:49:31 -0000
 Sorting things on two levels
Apologies if this is a stupidly easy question, but I haven't done a lot with
this particular aspect of XSL, so please be kind!

I'm writing a simple style sheet for DocBook and I need to be able to sort the
index tags twice, once by the first term and once by the second term, so that
main headings and subheadings come out in the correct order.  Not everything
has a subheading.  If a main heading or subheading occurs twice, I need it to
output only once followed by IDs for all the occurrences.

Right now I'm doing the first sort and outputting a document, then processing
that second document to do the second sort.  I need to do it all in one pass.
I'm sure it's possible, I just don't know how to get started.

For those not familiar with DocBook, the tags look like this (ignore the
periods, they're there so that my email doesn't strip out the line breaks):

<indexterm id="{ID}">.
     <primary>bears</primary>.
     <secondary>feeding</secondary>.
</indexterm>.

<indexterm id="{ID}">.
     <primary>bears</primary>.
     <secondary>breeding</secondary>.
</indexterm>.

<indexterm id="{ID}">.
  <primary>bears</primary>.
  <secondary>hunting</secondary>.
</indexterm>.

<indexterm id="{ID}">.
  <primary>aardvarks</primary>.
</indexterm>.

<indexterm id="{ID}">.
     <primary>bears</primary>.
     <secondary>hunting</secondary>.
</indexterm>.


The output from the above should be as follows (I'm wrapping it in HTML list
tags but have omitted them here for clarity -- I assume if I can get the sort
working I can wrap the output without much effort):

Aardvarks, {ID}.
Bears.
   breeding, {ID}.
   feeding, {ID}.
   hunting, {ID}, {ID}.


Is there an easy way to do this?  Or is there a stylesheet out there that
already does this and I can just copy it into mine?  I've already looked at
the official docbook to html style sheet but the indexterm processing is
spread across a ton of little module files and I can't follow the logic at
all.  I just want something really simple.

Thanks --

Michele

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.