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

dynamically applying templates

Subject: dynamically applying templates
From: Bruce D'Arcus <bdarcus@xxxxxxxxxxxxx>
Date: Sat, 11 Sep 2004 13:27:00 -0400
mods for cs
I'm still stuck on the remaining big problem in my stylesheets. I need to read an external file and use the structure of that file to determine processing. So, here's a fragment of the style file:

    <bibliography author-as-sort-order="yes">
      <entry>
	<reftype name="book">
	  <title font-style="italic" after=", "/>
	  <creator>
	    <names form="full"/>
	    <role/>
	  </creator>
	  <date before=" (" after=") ">
	    <year/>
	  </date>
	  <origin before="(" after="), ">
	    <place after=":"/>
	    <publisher/>
	  </origin>
	  <genre after=", "/>
	  <medium before="(" after="), "/>
	  <availability>
	    <physical-location before=", "/>
	    <url before=", "/>
	  </availability>
	</reftype>

What needs to happen, then, is that if the processor sees a "cs:creator" element (the style language is namespaced), it needs to map that to "mods:name."

Jeni was kind enough to help me figure out how to do this sort of thing to generate a css file to handle the formatting, but that's different because it's just taking the element names as strings to create the css class names and such.

She also suggested something like this awhile back:

<xsl:template match="cs:citationstyle/cs:content/cs:bibliography/cs:entry/cs:reftype/ cs:*">
<xsl:param name="style" as="element()" />
<xsl:variable name="source" as="element()" select="." />
<xsl:for-each select="$style/*">
<xsl:apply-templates select="$source/*[node-name(.) =
node-name(current())]">
<xsl:with-param name="style" select="." />
</xsl:apply-templates>
</xsl:for-each>
</xsl:template>


The problem is that the element name in the style file needs to be the same as the template I need to apply in the main document.

So is there some way to adapt this to do a mapping like:

	cs:creator = mods:name
	cs:title = mods:titleInfo
	cs:origin = mods:originInfo

.... and so forth?

I had thought it might be nice to able to name each template and somehow apply those in the above, but nothing I try seems to be valid (e.g. I can't get away with <xsl:apply-templates name="$source/*[node-name(.) = node-name(current())]">).

Bruce

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.