here's what I'm thinking (exploiting variables)

cc-ing in case you’re not on the list yet David …

OK, I was just experimenting with the approach that I think may make
more sense, which is to use variables apart from the main document
rather than passing around everything from tree to tree over multiple
passes (as I do in the current version).

Here’s a simple example:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0"
xmlns:mods="http://www.loc.gov/mods/v3"
xmlns:db="http://docbook.org/docbook-ng"
xmlns:exist="http://exist.sourceforge.net/NS/exist"
exclude-result-prefixes=“db mods exist”>

<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:variable name="citerefs" select="//db:biblioref/@linkend"/>
<xsl:variable name="citekeys">
  <xsl:text>(</xsl:text>
    <xsl:for-each-group select="$citerefs" group-by=".">
      <xsl:if test="position() &gt; 1">,%20</xsl:if>
      <xsl:text>'</xsl:text>
      <xsl:value-of select="."/>
      <xsl:text>'</xsl:text>
    </xsl:for-each-group>
  <xsl:text>)</xsl:text>
</xsl:variable>
<xsl:variable name="bibrecord"
select='doc(concat("http://localhost:8080/exist/servlet/db/biblio?",
	"_query=declare%20namespace%20mods=%22http://www.loc.gov/mods/v3%22;",
	"%20for%20$citekey%20in%20",
     		$citekeys,
	"%20return%20/mods:modsCollection/mods:mods[@ID=$citekey]"))' />
<xsl:variable name="raw-biblist">
  <mods:modsCollection>
    <xsl:copy-of select="$bibrecord/exist:result/mods:mods" />
  </mods:modsCollection>
</xsl:variable>
<xsl:variable name="formatted-biblist">
  <xsl:for-each select="$raw-biblist/mods:modsCollection/mods:mods">
    <p id="{@ID}">
      <xsl:apply-templates select="mods:titleInfo"/>
    </p>
  </xsl:for-each>
</xsl:variable>

<xsl:template match="/">
  <div id="bibliography">
    <xsl:copy-of select="$formatted-biblist"/>
 </div>
</xsl:template>

<xsl:template match="mods:titleInfo">
  <span class="title">
    <xsl:apply-templates select="mods:title"/>
    <xsl:apply-templates select="mods:subTitle"/>
  </span>
</xsl:template>

<xsl:template match="mods:title">
  <xsl:value-of select="."/>
</xsl:template>

<xsl:template match="mods:subTitle">
  <xsl:text>: </xsl:text>
  <xsl:value-of select="."/>
</xsl:template>

</xsl:stylesheet>

Result:

<?xml version="1.0" encoding="UTF-8"?>

For a New Regional Geography 1

Review of Moral Economy and Popular Protest

Senators Stamp OK on Anti-Terrorism Laws

Riots and Rituals: The Construction of Violence and Public Space in Hindu Nationalism

So my thought is that somehow we create the following variables (which
are, of course, temporary trees):

-	citekeys (the ids for the references in the document)
-	raw-biblist (raw mods content constructed based on $citekeys)
-	intermediate-biblist (intermediate bibliography created from 

$raw-biblist)
- rendered-biblist (formatted bibliography created from
$intermediate-biblist, using a simple output driver)
- intermediate-citations (intermediate citations, created from
$raw-biblist; can include first and subsequent, etc.)
- rendered-citations (rendered citations, created from
$intermediate-citations, using a simple output driver)

It certainly seems cleaner. Am hoping it’s also at least as fast; if
not faster (though this stylesheet is seeming slow on my iBook right
now). Features are essential, but performance is nice too!

This would involve simplifying the driver structure I have now, and
probably moving the current class-parameter-conditioned mods:mods
templates into variables.

BTW, I’m also hoping this approach makes more sense in the context of
apps like Word and OOo.

What do you think? Would this actually work?

Bruce

Bruce D’Arcus wrote:

So my thought is that somehow we create the following variables (which
are, of course, temporary trees):

-    citekeys (the ids for the references in the document)
-    raw-biblist (raw mods content constructed based on $citekeys)
-    intermediate-biblist (intermediate bibliography created from 

$raw-biblist)
- rendered-biblist (formatted bibliography created from
$intermediate-biblist, using a simple output driver)
- intermediate-citations (intermediate citations, created from
$raw-biblist; can include first and subsequent, etc.)
- rendered-citations (rendered citations, created from
$intermediate-citations, using a simple output driver)

It certainly seems cleaner. Am hoping it’s also at least as fast; if
not faster (though this stylesheet is seeming slow on my iBook right
now). Features are essential, but performance is nice too!

This would involve simplifying the driver structure I have now, and
probably moving the current class-parameter-conditioned mods:mods
templates into variables.

BTW, I’m also hoping this approach makes more sense in the context of
apps like Word and OOo.

What do you think? Would this actually work?

Looks good to me. As soon as things clear out a bit more I will start
at the beginning and run through all of this and see if there are any
additional comments I have in concern to the architecture. At that
point then we can better understand what needs to happen next. My guess
is between 3-4 hour, possibly sooner before I respond back with my comments.

Cheers!

<M:D/>>

Minor correction: I mean the mods:modsCollection templates; those that
begin with stuff like:

<xsl:template match="mods:modsCollection[$citation-class='author-year’
or $citation-class=‘note-bib’]"
mode=“enhanced-bib”>

So there I’m using a template in another mode/pass, which is
conditioned on the citation-class parameter. In this approach, either
the variables would have a similar conditional statement (if that’s
even possible), or there just be a (rather long and hairy) choose
statement.

Bruce