[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: dynamically applying templates

Subject: Re: dynamically applying templates
From: Bruce D'Arcus <bdarcus@xxxxxxxxxxxxx>
Date: Mon, 13 Sep 2004 16:44:40 -0400
xsl dynamic template
On Sep 13, 2004, at 2:16 PM, Wendell Piez wrote:

I'm saying, in effect, there's nothing preventing you from selecting nodes in your config file, and matching them with templates, to achieve "dynamic template selection" if you want.

So you're saying match the config template and apply to mods with something like the following?


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

I'm really not getting how to put this all together. For example, if I try to experiment with this approach, I get nowhere because the following code (the template at the bottom) is invalid:

<!-- read the external citation style file -->
<xsl:param name="citation-style" required="yes" as="xs:string" />
<xsl:variable name="styles" as="document-node()"
select="doc(concat($citation-style, '.csl'))" />
<!-- set the citation class parameter (e.g. author-year) as specified in the style file -->
<xsl:param name="citation-class" select="$styles/cs:citationstyle/@class"/>
<xsl:variable name="style-citation" select="$styles/cs:citationstyle/cs:content/cs:citation"/>
<xsl:variable name="style-biblio" select="$styles/cs:citationstyle/cs:content/cs:bibliography"/>


<xsl:template match="$style-biblio">
  <xsl:apply-templates select="cs:*"/>
</xsl:template>

If I try something like this instead, I don't seem to be matching templates:

<xsl:template match="//cs:bibliography">
  <test>
    <xsl:apply-templates select="cs:*"/>
  </test>
</xsl:template>

<xsl:template match="cs:title">
  <xsl:apply-templates select="//mods:titleInfo" mode="bib"/>
</xsl:template>

<xsl:template match="cs:creator">
  <xsl:apply-templates select="//mods:name" mode="bib"/>
</xsl:template>

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

<xsl:template match="mods:name" mode="bib">
  <span class="name">
    <xsl:apply-templates/>
  </span>
</xsl:template>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.