[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] passing parameters to generic templates
Hi,
I'm stuck with the following problem (which is version independent): 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="/"> <test> <xsl:apply-templates select="/content/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> <docBase>full_path_to_some_directory</docBase> <para> This is a test <b>text</b> which should be copied 1:1. <a href="local_ref">A reference</a> <center><a href="local_ref">A nested reference</a></center> </para> </content> I want everything between the <para> ... </para> to copied verbose, except for the href of the anchors, which should be prefixed by the value of <docBase>. 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... Yes, I tried the archives, got 0 responses (as usual, I probably didn't ask the right question ...) 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|