[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] Re: Merging attribute values to unique list
Subject: [xsl] Re: Merging attribute values to unique list From: James Cummings <James.Cummings@xxxxxxxxx> Date: Tue, 5 Aug 2003 12:07:18 +0100 (BST) |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Sorting Upper-Case first., David Carlisle | Thread | Re: [xsl] Re: Merging attribute val, David Carlisle |
[xsl] Sorting Upper-Case first. Mic, Yago Alvarado | Date | Re: [xsl] Re: Merging attribute val, David Carlisle |
Month |