On Aug 10, 2004, at 9:25 AM, Jeni Tennison wrote:
Contrast this with avoiding the datatyping all together:
<xsl:function name="mods:year" as="xs:integer">
<xsl:param name="mods" as="element(mods:mods)" />
<xsl:sequence
select="xs:integer(substring($mods/mods:originInfo/mods:dateIssued, 1,
4))" />
</xsl:function>
This function is so simple, you don't even need it to be a function;
you can just put the value of the select attribute of the above
<xsl:sequence> into the group-by attribute and be done.
Right.
I had hoped to be able to rely on the format-date function for stuff
like a magazine article, where you might have:
Time (1999) Title, Oct. 12.
I guess that's not that big a deal though, and I can just use the
approach I was using with XSLT 1.
In case anyone's interested, I posted an archive with the stylesheet,
the example doc, and an output example at:
http://www.users.muohio.edu/darcusb/files/db-mods-xsl2.zip
I'd really like to make the stylesheet configurable via an XML style
file. The style file would basically define variables, lay them out in
the appropriate order, and give instructions on surrounding
punctuation. Think BibTeX .bst files, but in XML.
So a layout for a book might look like (there'd also be other stuff
that defines how to format names, lists of terms to use for thing like
editors, and media, etc.):
<reftype name="book">
<creator/>
<date before=" (" after=") ">
<year/>
</date>
<title font-shape="italic" after=", "/>
<origin before="(" after="), ">
<place after=":"/>
<publisher/>
</origin>
<genre after=", "/>
<medium before="(" after="), "/>
<physical-location before=", "/>
<url before=", "/>
</reftype>
And that would get translated by the stylesheet into the appropriate
ordering and such; in this case something like:
<xsl:choose>
<xsl:when test="cs:reftype[@name='book']>
<xsl:apply-templates select="mods:name"/>
<xsl:apply-templates select="$year"/>
<xsl:apply-templates select="mods:titleInfo"/>
<xsl:apply-templates select="mods:originInfo"/>
<xsl:apply-templates select="mods:genre"/>
...
</xsl:when>
...
<xsl:choose>
This is the idea behind Peter Flynn's BiblioX project:
http://silmaril.ie/bibliox/
Unfortunately, Peter has been too busy to finish it, and the code is
beyond my comprehension. I'm just wondering if there's a simpler way
to do the same thing using the features of XSLT 2, so that I can get
something working properly. Indeed, there are a variety of projects
interested in XLT-based bibliographic and citation formatting (among
them the OpenOffice bib project).
BiblioX relies on keys to define the mappings between the instances and
the variables. While I don't really fully understand keys, I get the
sense I might want to think about something like:
<xsl:key name="bibref" match="mods:mods" use="@ID" />
<xsl:key name="creator" match="mods:mods" use="mods:name"/>
<xsl:key name="title" match="mods:mods" use="mods:titleInfo"/>
<xsl:key name="location" match="mods:mods" use="mods:location"/>
... and then somehow define variables that get the processor to use the
right elements in the right order (so the xpath expressions for the
apply-templates above would be variables), and to apply the
punctuation*.
Bruce
PS - Technically punctuation could be handled with a template that
spits out CSS code to do all the rendering, using stuff like
span.title:after definitions, but that's not likely to work except in
the most modern of browsers. I'd like the HTML code to be readable in
applications like Word.