Re: [xsl] dynamically applying templates

Subject: Re: [xsl] dynamically applying templates
From: Bruce D'Arcus <bdarcus@xxxxxxxxxxxxx>
Date: Tue, 14 Sep 2004 13:51:00 -0400
On Sep 14, 2004, at 12:37 PM, Wendell Piez wrote:

So perhaps your calling template would select the appropriate cs:reftype element in the config file to process:

<xsl:apply-templates name="style-biblio" select="$styles/cs:citationstyle/cs:content/cs:bibliography[@author- as-sort-order='yes']/cs:entry/cs:reftype[@name='book']">
<xsl:with-param name="source" select="."/>
</xsl:apply-templates>

The "calling template" in this case being the mods namespaced stuff? E.g.:


<xsl:template match="mods:mods">
<xsl:apply-templates select="$styles/cs:citationstyle/cs:content/cs:bibliography[@author-as- sort-order='yes']/cs:entry/cs:reftype">
<xsl:with-param name="source" select="."/>
</xsl:apply-templates>
</xsl:template>


Note also that the name attribute on the apply-templates element is invalid.

OK, so with respect both of your comments below (as well as the above), I'm still a bit fuzzy on how to use parameters -- how you're using them in this context -- and about tunneling ...

And then

<xsl:template match="cs:reftype">
  <xsl:param name="source"/>
  <xsl:apply-templates>
    <xsl:with-param name="source" select="."/>

In this case, what exactly is the parameter doing? Are you using this precisely to do the, as you later say, "jumping back and forth between the trees"? So here you're apply-templates to the cs:* elements, and elsewhere to mods:*?


    <!-- the parameter passing shouldn't be necessary w/ XSLT 2.0
         'tunneling parameters' -->

So are you saying here I should be defining a "source" param at the top of my stylesheet using tunneling='yes", without a select statement?


  </xsl:apply-templates>
</xsl:template>

<xsl:template match="cs:title">
  <xsl:param name="source"/>
  <!-- do your title thing here, grabbing data from
       $source (the mods source) as necessary -->
</xsl:template>

Here's I'm confused on the $source reference. Does this suggest I am using the source param and doing something like so?


<xsl:template match="cs:title">
  <xsl:param name="source"/>
  <!-- do your title thing here, grabbing data from
       $source (the mods source) as necessary -->
  <xsl:apply-templates select="mods:titleInfo">
    <xsl:with-param name="source" select="mods:mods"/>
  </xsl:apply-templates>
</xsl:template>

Sorry, but I feel like a blind man here, and I need to understand it better before I get farther. The output I'm currently getting is just:

<html xmlns="http://www.w3.org/1999/xhtml";><span class="creator"></span><span class="creator"></span><span class="creator"></span><span class="creator"></span></html>

.... which is a big mess! Probably means beyond the basic problem of how to select the right template, I also need to use modes (there's only one "creator" in this file).

Bruce

Current Thread