RE: [xsl] sorting union results

Subject: RE: [xsl] sorting union results
From: Jeff Beadle <Jbeadle@xxxxxxxx>
Date: Thu, 15 Aug 2002 13:40:38 -0400
Hey Doug,

It sorted for me, if I understood the intent correctly.

Here was my xml:
<glossary>
    <entry>
        <term>A term</term>
        <acronym>A acronym</acronym>
        <definition></definition>
    </entry>
    <entry>
        <term>C term</term>
        <acronym>C acronym</acronym>
        <definition></definition>
    </entry>
    <entry>
        <term>B term</term>
        <acronym>B acronym</acronym>
        <definition></definition>
    </entry>
</glossary>

Here was the output:
  <p>A acronym:</p> 
  <p>A term:</p> 
  <p>B acronym:</p> 
  <p>B term:</p> 
  <p>C acronym:</p> 
  <p>C term:</p> 

Is that not what you wanted?

If so, then maybe your problem is elsewhere in your stylesheet.  Is this RTF
being directly output'ed? Or, are you capturing this in an xsl:variable?

-Jeff

-----Original Message-----
From: Doug Howell [mailto:doug@xxxxxxxxxxxxxxxxxxxx]
Sent: Thursday, August 15, 2002 1:10 PM
To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] sorting union results


Hi, all, Given a structure like this:

<glossary>
    <entry>
        <term></term>
        <acronym></acronym>
        <definition></definition>
    </entry>
</glossary>

I'd like my stylesheet to create a list of glossary terms, inserting the
acronyms (as if they were terms) where they fit alphabetically in the list.
I'd like to avoid having to create another entry for each acronym and keep
the XML document smaller.)

I tried this:

<xsl:for-each select="//term|//acronym">
    <xsl:sort select="." order="ascending"/>
        <p><xsl:value-of select="."/>:</p>
</xsl:for-each>

This lists the terms and acronyms together, but doesn't sort them (they come
out in document order). I think I've read that the union operator can only
deliver the selected nodes in document order.

Is there any workaround to do what I want to do without creating an
intermediary document?

Thanks!

Doug Howell
Information Architect
Borders Group Inc.



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread