Subject: [xsl] passing parameters to generic templates From: Robert Frank <robert.frank@xxxxxxxxx> Date: Mon, 10 Apr 2006 23:58:29 +0200 |
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>
<xsl:template match="/"> <test> <xsl:apply-templates select="/content/para"> <xsl:with_param name="path" select="docBase"/> </xsl:apply-templates> </test> </xsl:template>
<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 ...)
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] xsltproc and multiple inp, Jon Gorman | Thread | Re: [xsl] passing parameters to gen, David Carlisle |
RE: [xsl] Getting a specific elemen, Michael Kay | Date | Re: [xsl] passing parameters to gen, David Carlisle |
Month |