Subject: Another problem with visibility of params in templates From: Wolfgang May <may@xxxxxxxxxxxxxxxxxxxxxxxxxx> Date: Fri, 26 Nov 1999 11:44:29 +0100 (MET) |
Hi, I have also a problem with passing a non-constant parameter to xsl:apply-templates (using xt): When apply-templates is applied to more than one elements, the passed parameter binding holds only for the first application. For the second, it is empty. When the parameter is a constant (e.g., select="2") instead, it is passed correctly to all applications. The effect is illustrated in the below example (the same happens also when select="current()" is used). ============== mondial-test.xsl =================================== <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xt="http://www.jclark.com/xt" version="1.0" extension-element-prefixes="xt"> <xsl:output indent="yes"/> <xsl:template match="mondial"> <xt:document href="mondial-test.htm"> <xsl:apply-templates select="country"/> </xt:document> </xsl:template> <xsl:template match="country"> <country> <xsl:copy-of select="name|capital|population"/> with computed parameter: <xsl:apply-templates select="adm_div"> <xsl:with-param name="countrycap" select="./capital/@ref"/> </xsl:apply-templates> with fixed parameter: <xsl:apply-templates select="adm_div"> <xsl:with-param name="countrycap" select="2"/> </xsl:apply-templates> </country> </xsl:template> <xsl:template match="adm_div"> <xsl:param name="countrycap" ></xsl:param> country's capital should go here: <xsl:value-of select="$countrycap"/> </xsl:template> </xsl:stylesheet> ============== mondial-test.xml =================================== <mondial> <country id="cid-cia-Greece"> <name>Greece</name> <car_code>GR</car_code> <total_area>131940</total_area> <population>10538594</population> <capital ref="cty-Greece-Athens"/> <adm_div ref="prov-cid-cia-Greece-2"/> <adm_div ref="prov-cid-cia-Greece-3"/> <adm_div ref="prov-cid-cia-Greece-4"/> </country> <city id="cty-Greece-Athens"> <name>Athens</name> <country>cid-cia-Greece</country> <theProvince>prov-cid-cia-Greece-3</theProvince> <longitude>23.7167</longitude> <latitude>37.9667</latitude> <population year="81">885737</population> <located at="sea" ref="sea-Mittelmeer"/> </city> <prov id="prov-cid-cia-Greece-2"> <name>Anatoliki Makedhonia kai Thraki</name> <country>cid-cia-Greece</country> <population>574308</population> <area>14157</area> </prov> <prov id="prov-cid-cia-Greece-3"> <name>Attiki</name> <country>cid-cia-Greece</country> <population>3522769</population> <area>3808</area> </prov> <!-- and so on ... --> </mondial> ========= Output: mondial-test.htm =================================== <country> <name>Greece</name> <population>10538594</population> <capital ref="cty-Greece-Athens"/> with computed parameter: country's capital should go here: cty-Greece-Athens country's capital should go here: country's capital should go here: with fixed parameter: country's capital should go here: 2 country's capital should go here: 2 country's capital should go here: 2</country> ========= so "cty-Greece-Athens" is only passed to the first application, whereas the constant "2" is passes to all applications :( Wolfgang -- ----------------------------------------------------------------- Dr. Wolfgang May E-mail: may@xxxxxxxxxxxxxxxxxxxxxxxxxx Universitaet Freiburg http://www.informatik.uni-freiburg.de/~may/ Institut fuer Informatik D-79110 Freiburg / Germany Lehrstuhl fuer Datenbanken und Informationssysteme Tel ++49 761 203-8131 Fax ++49 761 203-8122 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Strings and apostrophies, David Carlisle | Thread | Re: Another problem with visibility, David Carlisle |
Strings and apostrophies, Beat . Schaller | Date | Re: Strings and apostrophies, David Carlisle |
Month |