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

Re: Merging attribute values to unique list

Subject: Re: Merging attribute values to unique list
From: James Cummings <James.Cummings@xxxxxxxxx>
Date: Tue, 5 Aug 2003 12:07:18 +0100 (BST)
xsl sort unique
Many thanks to Jeff Beadle, Americo Albuquerque, and Dimitre Novatchev
for their different solutions.

I've used one similar to Jeff's customised just to use xalan:nodeset.
And it works in cocoon. ;-)  Which is good.

Now, I replace each of these wits with a value found in another file as such:
----
<xsl:variable name="id"><xsl:value-of select="//ant/@id|//res/@id|//prayer/@id"/></xsl:variable>
<xsl:variable name="mss" select="document('../../mss/mss.xml')"/>
<xsl:variable name="unique-wit-list">
<xsl:call-template name="unique-token-list">
  <xsl:with-param name="str">
    <xsl:for-each select="//aBody|//rBody|//pBody">
    <xsl:text> </xsl:text> <xsl:value-of select="@wit"/><xsl:text> </xsl:text>
   </xsl:for-each>
  </xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:for-each select="xalan:nodeset($unique-wit-list)/*">
   <xsl:sort select="name()"/>
   <xsl:variable name="sigil" select="name()"/>
   <xsl:variable name="shortname" select="$mss//witness[@sigil=$sigil]/@shortname"/>
  <a href="{concat('/test/ind/', $id, '?wit=', name())}">
   <xsl:value-of select="$shortname"/></a><xsl:text>  </xsl:text>
 </xsl:for-each>
----

Which, as you can see, calls unique-token-list to tokenize the string (I
suppose I could use xalan:tokenize instead?) and for each of these
creates a link like <a href="/test/ind/a1?wit=WitA">Witness A</a>  with
the link text coming from @shortname in another file.

This works, and produces a nice list, sorted by the witness sigil....
<xsl:sort select="name()"/> ... the question is how to sort it by
the resulting $shortname instead.  <xsl:sort> needs to be the
first thing inside the <xsl:for-each> (right?) so the $shortname
variable isn't made yet.

I've tried to do something like:
<xsl:sort select="$mss//witness[@sigil=name()]/@shortname"/>
but this fails.

Basically, I want the list of links then sorted by the @shortname
that is going to be the link's text.  Possible?

-James

-- 
Dr James Cummings, James.Cummings@xxxxxxxxx, http://www.uea.ac.uk/~q503
Cursus Project, School of Music, University of East Anglia,
Norwich, Norfolk, NR4 7TJ, UK  Tel:(01603)593-595



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


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.