xsl-list
[Top] [All Lists]

[xsl] Sorting things on two levels

2015-04-14 09:49:44
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
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>