[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

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


Subject: Re: [xsl] regexs, grouping (?) and XSLT2?
From: Bruce D'Arcus <bdarcus@xxxxxxxxxxxxx>
Date: Wed, 11 Aug 2004 10:11:02 -0400

OK, going back to this:

On Aug 10, 2004, at 11:10 AM, Bruce D'Arcus wrote:

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=", "/>

I decided to make things simpler and just make the stylesheet configurable internally, and then maybe later I can worry about reading an external (XML) configuration file.

Does the below seem like the right approach?  And conceptually how do I
think about reading a non-xsl file and getting the xslt to apply the
below logic?

<!-- begin configuration options -->

<!--
biborder template called by main bib template to determine order of
processing
Note: this of course leaves the author-year ordering fixed; not a
problem now, but would be
if I want to allow greater configuration options.
-->

<xsl:template name="biborder">
  <xsl:apply-templates select="mods:titleInfo"/>
  <xsl:apply-templates select="mods:originInfo"/>
  <xsl:apply-templates select="mods:relatedItem"/>
  <xsl:apply-templates select="mods:location"/>
</xsl:template>

<!-- punctuation variables -->

<xsl:variable name="title-before">
  <xsl:text></xsl:text>
</xsl:variable>

<xsl:variable name="title-after">
  <xsl:text> </xsl:text>
</xsl:variable>

<xsl:variable name="year-before">
  <xsl:text>(</xsl:text>
</xsl:variable>

<xsl:variable name="year-after">
  <xsl:text>) </xsl:text>
</xsl:variable>
<xsl:variable name="creator-before">
  <xsl:text></xsl:text>
</xsl:variable>

<xsl:variable name="creator-after">
  <xsl:text> </xsl:text>
</xsl:variable>

.... etc.

Bruce

PS - I get the same weird virus warning as Mike.


Current Thread
Keywords