|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: followup on multi-level grouping/sorting/position
OK, I JUST realized I wasn't very careful in transferring the example I
had working to the new template (based on Mike's suggestion), and
missed a crucial bit. I can only chalk it up to deadline-induced
psychosis.
Anyway, in case anyone else stumbles on this issue passing parameters across multi-grouping-levels, my problem was that inner group needs to switch context to the variable constructed in the outer group before proceeding, and I was missing that. I do have a couple of further questions on this below that in part relate to performance: <xsl:template match="db:citation" mode="sort_citation_author-year"> <!-- store citation for future use --> <xsl:variable name="citation" select="."/> <xsl:variable name="local-cite-style" select="db:biblioref/@xrefstyle"/> <xsl:variable name="idref" select="db:biblioref/@linkend, course:reading/@refid"/> <xsl:variable name="bibref" select="$enhanced-biblist/mods:modsCollection/mods:mods[@ID=$idref]"/> <bib:span class="citation"> <xsl:for-each-group select="$bibref" group-by="@bib:sort-on"> <xsl:sort select="current-grouping-key()"/> <xsl:variable name="refs-for-author-sorted-by-year" as="element(mods:mods)*"> <xsl:perform-sort select="current-group()"> <xsl:sort select="bib:year"/> </xsl:perform-sort> </xsl:variable> <xsl:variable name="first-ref-for-author" as="element(mods:mods)" select="$refs-for-author-sorted-by-year[1]"/> <xsl:variable name="last-ref-for-author" as="element(mods:mods)" select="$refs-for-author-sorted-by-year[position() = last()]"/> <xsl:for-each-group select="$refs-for-author-sorted-by-year" group-adjacent="bib:year"> <!-- the above and below - first a for-each-group selecting the variable from the outer group, and then the for-each selecting the current-group() - were the crucial bits I had wrong--> <xsl:for-each select="current-group()"> <xsl:variable name="first-in-author-group" select=". is $first-ref-for-author" as="xs:boolean"/> <xsl:variable name="last-in-author-group" select=". is $last-ref-for-author" as="xs:boolean"/> <xsl:apply-templates select="." mode="citation_author-year"> <xsl:with-param name="first-in-author-group" select="$first-in-author-group"/> <xsl:with-param name="last-in-author-group" select="$last-in-author-group"/> <xsl:with-param name="local-cite-style" select="$local-cite-style"/> <xsl:with-param name="cite-ref" select="$citation/db:biblioref[@linkend='{@ID}']" as="element()"/> </xsl:apply-templates> </xsl:for-each> </xsl:for-each-group> <xsl:if test="position() != last()">; </xsl:if> </xsl:for-each-group> </bib:span> </xsl:template> OK, so I apply the above template within this template, which in turn is called from the main document stylesheet: <xsl:template name="bib:format-citation"> <xsl:param name="output-format" as="xs:string"/> <!-- hold an intermediate citation in a temporary tree, to then run output stylesheets on --> <xsl:variable name="intermediate-citation"> <xsl:value-of select="$style-citation/cs:prefix"/> <xsl:choose> <xsl:when test="$citeclass='author-year'"> <xsl:apply-templates select="." mode="sort_citation_author-year"> <xsl:with-param name="output-format" select="$output-format" as="xs:string" tunnel="yes"/> </xsl:apply-templates> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="db:biblioref" mode="otherwise"/> </xsl:otherwise> </xsl:choose> <xsl:value-of select="$style-citation/cs:suffix"/> </xsl:variable> <xsl:choose> <xsl:when test="$output-format='latex'"> <xsl:apply-templates select="$intermediate-citation" mode="output-latex"/> </xsl:when> <xsl:when test="$output-format='xhtml'"> <xsl:apply-templates select="$intermediate-citation" mode="output-xhtml"/> </xsl:when> </xsl:choose> </xsl:template> I don't really understand some of the nuances here (was reading about sequences, but not sure I fully understand the implications). Is there a way to make this more efficient, but keep it nicely modularized (as it is now)? Also, there are two bits of formatting: that related to the bibliographic input data, and that related to the specific citation. So, (Doe 2000, page 23): the "Doe 2000" is drawn from the mods:mods element that is pointed to by the db:biblioref/@linkend value, while the "page 23" is drawn from db:citation/db:biblioref; e.g.: <db:biblioref linkend="doe99" unit="page" begin="23"/> So after reworking the code radically, I now get the first part working nicely, but am not sure the best way to access the second, given I'm now working in a different tree. Above I'm trying to pass a parameter that is the original db:biblioref element. Does that seem sensible? Bruce
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








