Re: grouping + global variable (?) (was re: regexs, grouping (?) and XSLT2?)
2004-08-13 11:58:06
Hi Bruce,
At 12:15 PM 8/13/2004, you wrote:
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" />
<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>.
Could you show us a small, relevant fragment of your input please?
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(_at_)mulberrytech(_dot_)com
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
======================================================================
<Prev in Thread] |
Current Thread |
[Next in Thread>
|
- Re: grouping + global variable (?) (was re: regexs,, (continued)
- Re: grouping + global variable (?) (was re: regexs,, Wendell Piez
- RE: grouping + global variable (?) (was re: regexs,, Michael Kay
- Re: grouping + global variable (?) (was re: regexs, grouping (?) and XSLT2?), Deirdre Saoirse Moen
- Message not available
- Re: grouping + global variable (?) (was re: regexs, grouping (?) and XSLT2?), Wendell Piez
- Re: grouping + global variable (?) (was re: regexs, grouping (?) and XSLT2?), Deirdre Saoirse Moen
- Message not available
- Re: grouping + global variable (?) (was re: regexs, grouping (?) and XSLT2?), Wendell Piez
- Re: grouping + global variable (?) (was re: regexs,, Bruce D'Arcus
- up conversion using regex (was something else), David Carlisle
- RE: grouping + global variable (?) (was re: regexs, grouping (?) and XSLT2?), Michael Kay
- Re: grouping + global variable (?) (was re: regexs, grouping (?) and XSLT2?), Bruce D'Arcus
- Re: grouping + global variable (?) (was re: regexs, grouping (?) and XSLT2?),
Wendell Piez <=
- Re: grouping + global variable (?) (was re: regexs,, Bruce D'Arcus
- Re: grouping + global variable (?) (was re: regexs,, Wendell Piez
- Re: grouping + global variable (?) (was re: regexs,, Bruce D'Arcus
- Re: grouping + global variable (?) (was re: regexs,, Wendell Piez
- Re: grouping + global variable (?) (was re: regexs,, Bruce D'Arcus
- modes and temp trees (was Re: [xsl] grouping + global variable (?)), Bruce D'Arcus
- namespace prefix weirdness, Bruce D'Arcus
- Re: namespace prefix weirdness, Jeni Tennison
- Re: namespace prefix weirdness, Bruce D'Arcus
- RE: namespace prefix weirdness, Michael Kay
|
|
|