Hi there, I'm having a problem with Xalan in cocoon-2.1 in which I process an attribute containing whitespace separated manuscript sigla (IDREFS) and then make a drop down list based using corresponding text in another file.
The file(s) in question will look something like: <ant id="c666"> <aBody wit="Foo Blort-A Blort-B"> some other stuff </aBody> </ant> The mss.xml file contains some elements like: <witness sigil="Foo" shortname="A FOO Manuscript"> descriptive text</witness> <witness sigil="Blort-A" shortname="Blort in Version A"> descriptive text</witness> <witness sigil="Blort-B" shortname="Blort in Version B"> descriptive text</witness> The XSLT as it stands works fine: It goes, and makes (manually) a tokenized list of the whitespace separated witness in aBody/@wit, but instead uses the corresponding witness's @shortname instead of the abbreviation. The problem comes in sorting. If I use <xsl:sort select="name()"/> which bases it on the abbreviation separated off from the set of IDREFS then everything is sorted fine: "Blort-A, Blort-B, FOO" but using the @shortnames: "Blort in Version A, Blort in Version B, A Foo Manuscript" Obviously, this doesn't look alphabetically to the users, since A Foo should come before Blort. But, if I change it to: <xsl:sort select="$mss//[EMAIL PROTECTED](current())]/@shortname" /> which would do this, I get a NullPointerException from Xalan. Any suggestions? I looks really silly to not have this be sorted alphabetically. XSLT appended below. Many thanks, James ---------- <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xalan" exclude-result-prefixes="xalan" > <xsl:output method="html" /> <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')"/> <!-- Match root node --> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="/ant|/res|/prayer"> <html> <head> <title>Critical Edition <xsl:value-of select="$id"/></title> <link href="/styles/cursus.css" type="text/css" rel="stylesheet"> </link> </head> <body> <h1>Critical Edition of <xsl:value-of select="$id"/></h1> <div class="readingbuttons"> <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> <form action="{concat('/cursus/test/ind/', $id)}"> See just the reading for: <select name="wit" onchange="this.form.submit()" > <xsl:for-each select="xalan:nodeset($unique-wit-list)/*"> <xsl:sort select="name()"/> <!-- <xsl:sort select="$mss//[EMAIL PROTECTED](current())]/@shortname" /> --> <!-- If the above two xsl:sorts are swapped, Xalan dies, if not sorts by the $token which is the same as sorting by $sigil --> <xsl:variable name="sigil" select="name()"/> <xsl:variable name="shortname" select="$mss//[EMAIL PROTECTED]/@shortname"/> <option value="{name()}"><xsl:value-of select="$shortname"/></option> </xsl:for-each> </select> <input type="submit" value=" Change"/> </form> </div> <hr /> <xsl:apply-templates/> <hr /> Orthogonal views: <a href="{concat($id,'?cocoon-view=content')}">Content</a><xsl:text> </xsl:text> <a href="{concat($id,'?cocoon-view=pretty-content')}">Pretty content</a><xsl:text> </xsl:text> </body> </html> </xsl:template> <xsl:template name="unique-token-list"> <xsl:param name="str"/> <xsl:param name="nl"/> <xsl:variable name="token" select="substring-before(concat(normalize-space($str), ' '), ' ')"/> <xsl:choose> <xsl:when test="string-length($token) > 0"> <xsl:call-template name="unique-token-list"> <xsl:with-param name="str" select="substring-after($str, $token)"/> <xsl:with-param name="nl"> <xsl:copy-of select="xalan:nodeset($nl)/*"/> <xsl:if test="count(xalan:nodeset($nl)/*[name()=$token]) = 0"> <xsl:element name="{$token}"/> </xsl:if> </xsl:with-param> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:copy-of select="xalan:nodeset($nl)"/> </xsl:otherwise> </xsl:choose> </xsl:template> <!-- A whole bunch of other basic template matches omitted --> </xsl:stylesheet> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
