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

Re: Merging atribute values and sorting...

Subject: Re: Merging atribute values and sorting...
From: James Cummings <James.Cummings@xxxxxxxxx>
Date: Sat, 9 Aug 2003 02:03:16 +0100 (BST)
xsl atribute
Just to make sure I'm not just doing something else which causes
Xalan (under cocoon 2.1) to mess up when <xsl:sort select="name()" />
is switched to the promising sounding xpath suggested by David Carlisle...
here is the stylesheet in (abbreviated) full.  Any suggestions for
acheiving the same result appreciated.  (or pointing out if I'm just
missing something completely obvious!) The document in question will
always have ant|res|prayer as its root element.

---------
<?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')"/>
    <!-- file containing manuscript //witness/@shortname -->

<!-- just 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>
    <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//witness[@sigil=name(current())]/@shortname" /> -->
<!-- if the above two xsl:sorts are swapped, it dies, if not it sorts by the $token which
     is the same as sorting by $sigil -->
   <xsl:variable name="sigil" select="name()"/>
   <xsl:variable name="shortname" select="$mss//witness[@sigil=$sigil]/@shortname"/>
  <option value="{name()}"><xsl:value-of select="$shortname"/></option>
 </xsl:for-each>

</select>
<input type="submit" value=" Change"/>
</form>
<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>



<!-- And then a whole bunch of templates just to match elements
     and replace with classed spans or divs styled in the CSS -->

</xsl:stylesheet>
---------

Suggestions?

-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.