XSL formatting sorting issues

Aidan Wilson a.wilson at pgrad.unimelb.edu.au
Mon Feb 28 04:30:16 UTC 2011


Hi RNLDers (I still prefer "Ronaldos")

Does anyone have fairly good XSL skills and could guide me through a 
particularly nasty dictionary formatting issue?

The problem is that I have a reverse word finder which is built by extracting 
an element from each headword ('Reverse' which was originally put in for 
exactly this purpose). Here's an example of a word's XML (totally made up
example to demonstrate the point):

<Words>
   <Headword>elevate</Headword>
   <Category>verb</Category>
   <Meanings>
     <Definition>to raise, to lift</Definition>
     <Reverse>raise</Reverse>
     <Reverse>lift</Reverse>
     <Examples>
       <Example>You need to elevate your blood pressure</Example>
       <Translation>You need to raise your blood pressure</Translation>
     </Examples>
   </Meanings>
</Words>

The difficulty is that some words will have more than one Reverse element (as 
above). At the moment I can either:
a) Extract only the first reverse element from each entry, display it next to 
the headword, and all will be in alphabetical order by the Reverse element, or
b) Extract all reverse elements from all headwords, and display each one next 
to its headword, but they will be ordered *within the set of reverse elements 
of that word.

What I mean by that, is that I can get it working so I can produce:

Lift:
   elevate

Raise:
   elevate

But the Reverse elements from any other words will be sorted amongst 
themselves, but independently of any other word. So what I get in my English to 
Wagiman section is essentially ordered by the Wagiman word, but each word's
English glosses sorted among themselves.

What I would like is to pair each reverse element with its headword and then 
sort the whole list for the whole dictionary at once.

Ideally, actually, I'd like to group together identical Reverse elements so 
that I could have something like:

Lift:
   boost
   elevate
   heighten
   raise

Instead of listing them separately.

Here's the relevant section of my xsl stylesheet:

<xsl:for-each select="Words[Status!='Exclude']">
         <xsl:sort select="Meanings/Reverse"/>
         <xsl:for-each select="Meanings/Reverse">
                 <p><strong><xsl:value-of select="."/></strong><br/>
                 <xsl:value-of select="../../Headword"/></p>
         </xsl:for-each>
</xsl:for-each>

Hopefully this isn't an impossible task. And hopefully someone knows more than 
my week's worth of xsl and can point me in the right direction!

-- 
Aidan Wilson

PhD Candidate
Dept of Linguistics and Applied Linguistics
The University of Melbourne

+61428 458 969
a.wilson at pgrad.unimelb.edu.au



More information about the Resource-network-linguistic-diversity mailing list