Subject: Re: parameter concatinating From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Tue, 10 Aug 1999 16:39:35 +0200 |
I am having trouble using parameters, using the July 09 draft. I'd like to use parameters to pass patterns to named templates, then add to those patterns in particular situations. For example, I've defined the path parameter for this purpose. In the following XSLT fragment , I'm trying to add '/@id' to the pattern in the path parameter.
<xsl:when test="$path/@id">
<xsl:call-template name="idcatcher_path"> <xsl:with-param name="catch">url</xsl:with-param> <xsl:with-param name="path">child::SECTION[1]</xsl:with-param> </xsl:call-template>
<xsl:call-template name="idcatcher_path"> <xsl:with-param name="catch">url</xsl:with-param> <xsl:with-param name="path" select="child::SECTION[1]"/> </xsl:call-template>
T:\FTEMP>type test.xml <?xml version="1.0"?> <MAIN> <SECTION id="instance-id"/> <SECTION/> </MAIN> T:\FTEMP>type test.xsl <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">
<xsl:template match="MAIN"> <first> <xsl:call-template name="idcatcher_path"> <xsl:with-param name="catch">url</xsl:with-param> <xsl:with-param name="path" select="child::SECTION[1]"/> </xsl:call-template> </first> <second> <xsl:call-template name="idcatcher_path"> <xsl:with-param name="catch">url</xsl:with-param> <xsl:with-param name="path" select="child::SECTION[2]"/> </xsl:call-template> </second> <xsl:text>
</xsl:text> </xsl:template>
<xsl:template name="idcatcher_path"> <xsl:param name="catch"/> <xsl:param name="path"/> <xsl:choose> <xsl:when test="$path/@id"> <xsl:attribute name="{$catch}"><xsl:value-of select="$path/@id"/></xsl:attribute> </xsl:when> <xsl:otherwise> <xsl:attribute name="{$catch}"><xsl:value-of select="generate-id($path)"/></xsl:attribute> </xsl:otherwise> </xsl:choose> </xsl:template>
T:\FTEMP>call xsl test.xml test.xsl testout.xml T:\FTEMP>type testout.xml <first url="instance-id"/><second url="N6"/>
-- G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995) Website: XSL/XML/DSSSL/SGML services, training, libraries, products. Practical Transformation Using XSLT and XPath ISBN 1-894049-01-2 Next instructor-led training: MS'99 1999-08-16 MT'99 1999-12-05/06
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
parameter concatinating, Richard Lander | Thread | Re: parameter concatinating, Scott Boag/CAM/Lotus |
Re: applying all rules in a mode, Miloslav Nic | Date | Re: applying all rules in a mode, Richard Lander |
Month |