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

rephrased: passing parameters to generic templates

Subject: rephrased: passing parameters to generic templates
From: Robert Frank <robert.frank@xxxxxxxxx>
Date: Wed, 12 Apr 2006 08:41:37 +0200
rephrased
Hi,

I noticed I didn't phrase my problem carefully enough (and the example
wasn't correct either - thank's David) - probably too late at night:

I want to convert only certain (html) nodes using a generic template,
but have to pass a parameter to these templates. As the nodes may be
nested within othernodes, I am using the generic copy 'function'

<xsl:template match="@*|node()|text()" priority="-1">
   <xsl:param name="path" select="'zz'"/>
   <xsl:copy>
     <xsl:apply-templates select="@*|node()|text()">
       <xsl:with-param name="path" select="$path"/>
     </xsl:apply-templates>
   </xsl:copy>
</xsl:template>

The more specific template is:

<xsl:template match="/content">
   <test>
     <xsl:apply-templates select="para">
       <xsl:with_param name="path" select="docBase"/>
     </xsl:apply-templates>
   </test>
</xsl:template>

and the element I want to change:

<xsl:template match="a/@href">
   <xsl:param name="path" select="'xx'"/>
   <xsl:attribute name="href"><xsl:value-of select="$path"/>
      <xsl:value-of select="."/></xsl:attribute>
</xsl:template>

A sample xml file could be:
<content>
   <para>
     <docBase>full_path_to_some_directory</docBase>
     This is a test <b>text</b> which should be copied 1:1.
     <a href=3D"local_ref">A reference</a>
     <center><a href=3D"local_ref">A nested reference</a></center>
   </para>
   <para>
     <docBase>next_full_path_to_some_directory</docBase>
     This is a test <b>text</b> which should be copied 1:1.
     <a href=3D"local_ref">A reference</a>
     <center><a href=3D"local_ref">A nested reference</a></center>
   </para>
</content>

I want to use the <docBase> in every <para> to modify the href
of each anhor element.
How can I propagate the parameter's value in the more specific
template into the generic template? The only parameter that is
propagated is the one in the generic template, so all references have
a value of zz...

Thanks in advance, Robert

Departement Informatik   FGB   tel   +41 (0)61 267 14 66
Universitdt Basel                          fax. +41 (0)61 267 14 61
Robert Frank
Klingelbergstrasse 50                 Robert.Frank@xxxxxxxxx
CH-4056 Basel
Switzerland                                   http://
www.informatik.unibas.ch/personen/frank_r.html

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.