Re: regexs, grouping (?) and XSLT2?
Contrast this with avoiding the datatyping all together:
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:
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:
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*.
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.
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