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

Sorting using more than value

Subject: Sorting using more than value
From: Susan Bodnik <aquasue@xxxxxxxxx>
Date: Thu, 11 Nov 2010 12:46:07 -0800 (PST)
 Sorting using more than value
I am having problems in sorting using one of two possible values.I have a
template that creates an index using the indexterm element. 

Here is a
snippet of XML:

<p>Here is an <indexterm>index entry</indexterm> without an
attribute, and the 
contents of the element will display in the index. This
<indexterm 
term.entry="Alternate text">index entry</indexterm> does have an
attribute, and 
the contents of the attribute will display in the index rather
than the content 
of the indexterm element. </p>

I need to be able to sort
the index using one of two possible values. If the 
indexterm doesn't contain
a term.entry attribute, it should sort using the 
content of the indexterm
element. If the indexterm element contains a term.entry 
attribute, then it
should sort using the value of the term.entry attribute.
I have the following
that sorts the index. The template outputs the value of the 
term.entry
attribute if present, but it sorts only using the content of the 
indexterm
element:

   <xsl:for-each-group select="//indexterm"  group-by="."> 
   
<xsl:sort
select="translate(text(),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUV
WXYZ')"/>

  
    <div class="index">  
    <xsl:choose>
    <xsl:when
test="@term.entry"><span><xsl:value-of 
select="@term.entry"/><xsl:text> -
</xsl:text></span></xsl:when> 

    <xsl:otherwise><span><xsl:value-of
select="."/><xsl:text> - 
</xsl:text></span></xsl:otherwise>
       
 </xsl:choose>    
        </div> 
</xsl:for-each-group>

How would I be able
to sort the index entries using the content of the indexterm 
element (when
there is no term.entry element) or the term.entry attribute for 
the indexterm
element (if present)?

Thanks for any assistance with this.
Susan

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.