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

Re: grouping and context (?)

Subject: Re: grouping and context (?)
From: Bruce D'Arcus <bdarcus@xxxxxxxxxxxxx>
Date: Fri, 27 Aug 2004 20:52:13 -0400
arcus 28
On Aug 27, 2004, at 10:52 AM, David Carlisle wrote:

key() (as in xslt1) returns nodes only from the current document (where
temporary trees generated in xsl:variable count as new documents)
the solution is as in xslt1

save a variable holding a node in teh original document before you go
off somewhere else

<xsl:variable name="orig" select="/"/>

So where exactly am I putting this variable? At the top-level of my current stylesheet? Within the template?


then when you need to go back there use (in xslt2)

select="$orig/key('citekey', current()/@ID)"

I've tried a couple of variations on this, but I still get the same behavior, where:


<citation><biblioref linkend="doe99a"/></citation>
<citation><biblioref linkend="doe99a" begin="1" end="2"/></citation>

Yields:

(Doe, 1999: 1-2)
(Doe, 1999: 1-2)

Template as it exists now (the top-level element for the bib record would be <mods ID="doe99a">):

<xsl:variable name="orig" select="/"/>

<!-- begin citation processing -->
<xsl:key name="citekey" match="db:biblioref" use="@linkend" />
<!-- author-year class processing -->
<xsl:template match="db:citation[$citation-class='author-year']">
  <xsl:variable name="idref" select="db:biblioref/@linkend"/>
<!-- use a key to access mods records based on lindend value -->
  <xsl:variable name="bibref" select="key('bibref', $idref)" />
  <xsl:value-of select="$citation-before"/>
<!-- group and sort by authors-string -->
  <xsl:for-each-group select="$bibref" group-by="bib:grouping-key(.)">
    <xsl:sort select="current-grouping-key()"/>
<!-- within an authors group, sort by year -->
    <xsl:for-each-group select="current-group()"
			group-by="mods:year">
      <xsl:sort select="current-grouping-key()"/>
      <xsl:for-each select="current-group()">
<!-- since we're now working with the mods source, the only way
I can see to get back to the biblioref code is to use a key again;
unfortunately doesn't work correctly ** -->
	<xsl:variable name="citekey" select="key('citekey', @ID)" />
	<a href="#{@ID}">
	  <xsl:if test="position() = 1">
	    <xsl:choose>
	      <xsl:when test="mods:name">
		<xsl:apply-templates select="mods:name" mode="citation"/>
	      </xsl:when>
	      <xsl:otherwise>
		<xsl:value-of select="mods:noname-substitute"/>
	      </xsl:otherwise>
	    </xsl:choose>
	    <xsl:text>, </xsl:text>
	    <xsl:value-of select="mods:year"/>
	  </xsl:if>
<!-- apply suffix if applicable -->
	  <xsl:apply-templates select="mods:key"/>
<!-- render point citation details if present -->
          <xsl:for-each select="$orig/key('citekey', current()/@ID)">
          <xsl:if test="@begin">
	    <xsl:value-of select="$point-cite-before"/>
	    <xsl:value-of select="@begin" />
	    <xsl:text>-</xsl:text>
	    <xsl:choose>
	      <xsl:when test="string-length(@begin) = 1">
		<xsl:value-of select="@end" />
	      </xsl:when>
	      <xsl:when test="string-length(@begin) = 2">
		<xsl:value-of select="substring(@end, 2, 1)" />
	      </xsl:when>
	      <xsl:otherwise>
		<xsl:value-of select="substring(@end, last() - 1)" />
	      </xsl:otherwise>
	    </xsl:choose>
	  </xsl:if>
	  </xsl:for-each>
	  <xsl:if test="position() != last()">, </xsl:if>
	</a>
      </xsl:for-each>
    </xsl:for-each-group>
    <xsl:if test="position() != last()">; </xsl:if>
  </xsl:for-each-group>
  <xsl:value-of select="$citation-after"/>
</xsl:template>

Bruce

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.