Re: [xsl] dynamically applying templates

Subject: Re: [xsl] dynamically applying templates
From: Bruce D'Arcus <bdarcus@xxxxxxxxxxxxx>
Date: Thu, 16 Sep 2004 01:22:16 -0400
On Sep 15, 2004, at 2:05 PM, Wendell Piez wrote:

.... and add a template to match mods:mods (but notice I pulled the mode, imagining that the "bibliography" mode is to handle nodes in the config document.

That's the template where we'll jump trees, so --

<xsl:template match="mods:mods">
<xsl:apply-templates select="$style-biblio/cs:entry/cs:reftype[@name='book']"
mode="bibliography">
<!-- of course the value 'book' should probably be parameterized -->
<xsl:with-param name="source" select="."/>
<!-- this is where we jump to the other tree, carrying the original
context with us as the $source -->
</xsl:apply-templates>
</xsl:template>


.... see where that gets you ...

OK, this works fine when I am matching a cs:* template and then from there applying to mods:*.


However, it doesn't work when I need to apply templates to a cs: child. For example, the cs:origin element here:

	<reftype name="book">
	  <title font-style="italic" after=", "/>
	  <creator>
	    <names form="full"/>
	  </creator>
	  <origin before="(" after="), ">
	    <place after=":"/>
	    <publisher/>
	  </origin>

With this template ...

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

.... am I right that I am passing cs:origin as the source to the children, where I really need to be passing the original mods:mods source. A child looks like:

<xsl:template match="cs:place">
  <xsl:param name="source"/>
  <xsl:apply-templates select="$source/mods:originInfo/mods:place"/>
</xsl:template>

I'm not sure, but is this where tunneling should come in? And if yes, how do I actually use it in this context?

Bruce

Current Thread