|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: grouping + global variable (?) (was re: regexs, g
On Aug 12, 2004, at 6:13 PM, Michael Kay wrote:
How am I generating this "copy", in other words? Should I, for example, be using the new temporary tree functionality? Within the context of a variable? Something else?
<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><xsl:template match="mods:mods" mode="phase-1">
<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" />
<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 form: <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. 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








