Subject: Re: [xsl] grouping + global variable (?) (was re: regexs, grouping (?) and XSLT2?) From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Fri, 13 Aug 2004 14:58:06 -0400 |
Since the bibliography is only part of the document, and in a separate namespace, I decided to create a virtual copy of the mods:modsCollection element in the phase-1 mode, and then to apply-templates on that in the default mode; like so:
<xsl:template match="mods:modsCollection"> <xsl:variable name="temp"> <xsl:apply-templates select="." mode="phase-1"/> </xsl:variable> <xsl:apply-templates select="$temp"/> </xsl:template>
<xsl:template match="mods:modsCollection"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates mode="phase-1"/> </xsl:copy> </xsl:template>
Okay, but why are both these templates matching the same elements with the same priority, in no mode? They are in conflict and your processor will only use one of them (or throw an error).
<xsl:template match="mods:mods" mode="phase-1">
I'm not familiar with the mods tagset, but if mods:mods is not a descendant of mods:modsCollection, this template will never get matched.
/><xsl:copy> <xsl:copy-of select="*|@*"/> <xsl:variable name="bibref" select="mods:mods" /> <xsl:for-each-group select="$bibref" group-by="mods:grouping-key(.)"> <xsl:sort select="current-grouping-key()"/> <xsl:for-each-group select="current-group()"
group-by="xs:integer(substring(mods:originInfo/mods:dateIssued,1,4))"> <xsl:sort select="current-grouping-key()" /> <xsl:variable name="year" as="xs:integer" select="current-grouping-key()"/> <xsl:variable name="first" as="xs:boolean" select="position() = 1"
form:<xsl:for-each select="current-group()"> <xsl:attribute name="id"> <xsl:value-of select="@ID"/> </xsl:attribute> <key type="creator"> <xsl:value-of select="$creator-before"/> <xsl:choose> <xsl:when test="$first and position()=1"> <xsl:apply-templates select="." mode="names"/> <xsl:text> </xsl:text> </xsl:when> <xsl:otherwise>.</xsl:otherwise> </xsl:choose> <xsl:value-of select="$creator-after"/> </key> <key type="year"> <xsl:value-of select="$year" /> <xsl:if test="last() > 1"> <xsl:number value="position()" format="a"/> </xsl:if> </key> </xsl:for-each> </xsl:for-each-group> </xsl:for-each-group> </xsl:copy> </xsl:template>
My problem is I can't access the generated year, which should be of the
<mods:key type="year">1999a</mods:key>.
I have a feeling this means something's gone wrong with this intermediate step, as if I apply-templates to "mods:key" within the default mode of mods:modsCollection, I get no output. Everything but the year gets rendered correctly.
Is there something obviously wrong with the above? Maybe the way I've generated the copy? I thought it might be a namespace problem, but that's not it.
Unless something I've said prompts you to discover the problem for yourself, this is one of those problems where we have to see input and desired output samples as well -- no way to debug the stylesheet on its own, I'm afraid.
Cheers, Wendell
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] grouping + global variabl, Bruce D'Arcus | Thread | Re: [xsl] grouping + global variabl, Bruce D'Arcus |
Re: [xsl] Can't get output from xml, Todd Alexander | Date | RE: [xsl] Grouping question, Nishma Jain |
Month |