Re: [xsl] regexs, grouping (?) and XSLT2?

Subject: Re: [xsl] regexs, grouping (?) and XSLT2?
From: Bruce D'Arcus <bdarcus@xxxxxxxxxxxxx>
Date: Tue, 10 Aug 2004 08:08:25 -0400
On Aug 10, 2004, at 4:45 AM, Jeni Tennison wrote:

I've spent a bit of time on this since it uses some interesting XSLT
2.0 features.

Thanks Jeni!! I was hoping someone would see it as an interesting challenge. I'll spend some time studying it.


In the meantime, a couple of quick notes:

[Note that this shouldn't be allowed by a Basic XSLT 2.0 processor
because such processors shouldn't support the xs:gYear datatype. I've
tested this with Saxon 8.0B, and it works OK there, but that might
change when Mike makes it conformant. You could use xs:integer()
rather than xs:gYear() here to make it work with conformant Basic XSLT
2.0 processors.]

This is exactly the problem that prompted my other post on xs:date. I can't use either xs:gYear or xs;date because some dates are in the form YYYY and some are YYYY-MM, and still others YYYY-MM-DD. So, I had to change to substring(.,1,4) to get the stylesheet to compile.


I really wish xs:date would count all of these as valid.

My other issue is how to use your stylesheets to get each reference -- instead of each group -- wrapped in proper tags.

What I really need ultimately are:

1) Output like:

<p id="doesmith2000"><span class="creator">Doe, J and S. Smith</span> <span class="year"><(2000)</span> <span class="title">Some TItle</title>, <span class="container">In <span class="title">Some Book</span>, Edited by <span class="creator">J. Smith</span>, <span class="origin">Place:Publisher</span>.</p>

Likewise:

(<a href="doesmith2000">Doe and Smith, 2000a</a>, <a href="whatever">2000b</a>)

The details aren't important; I just need to be able to wrap each record in a p (or li) tag, stick a period on the end of it, etc., and to be able to do:

<xsl:apply-templates select="$title"/>
<xsl:apply-templates select="$origin"/>
<xsl:apply-templates select="$location"/>
<xsl:apply-templates select="$container"/>
etc.

... and within those templates to do some minimal processing.

So how would you modify your example? Would you rework the below template, for example, somehow into variables that get used in another template (matching mods:mods?)??

<xsl:template match="mods:modsCollection">
<xsl:variable name="mods" select="mods:mods" />
<xsl:for-each-group select="$mods" group-by="mods:grouping-key(.)">
<xsl:sort select="current-grouping-key()"/>
<xsl:apply-templates select="." mode="names" />
<xsl:text> </xsl:text>
<xsl:for-each-group select="current-group()"
group-by="substring(mods:originInfo/mods:dateIssued,1,4)">
<xsl:sort select="current-grouping-key()" />
<xsl:variable name="first" as="xs:boolean" select="position() = 1" />
<xsl:for-each select="current-group()">
<xsl:if test="not($first and position() = 1)">-----. </xsl:if>
<xsl:value-of select="substring(mods:originInfo/mods:dateIssued,1,4)" />
<xsl:if test="last() > 1">
<xsl:number value="position()" format="a" />
</xsl:if>
</xsl:for-each>
</xsl:for-each-group>
</xsl:for-each-group>
</xsl:template>


Bruce

Current Thread