You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by "Eric J. Schwarzenbach" <Er...@wrycan.com> on 2005/10/25 23:24:36 UTC

document(x) vs document(x)/* and parameters

Can anyone explain why calling 

<xsl:apply-templates select="document(@filename)">

as opposed to

<xsl:apply-templates select="document(@filename)/*">

Should cause parameter values (even unrelated literal ones) not to get passed? 

If I have 	
		<xsl:apply-templates select="document(@filename)">
			<xsl:with-param name="xpath" select="@xpathRef"/>
			<xsl:with-param name="p2" select="45"/>
			<xsl:with-param name="p3" select="'wtf'"/>
		</xsl:apply-templates>

and

	<xsl:template match="chapter">
		<xsl:param name="xpath" />
		<xsl:param name="p2" />
		<xsl:param name="p3" />
		<xsl:variable name="xyz" select="'section'"></xsl:variable>
<MESSAGE>XPATH = !<xsl:value-of select="$xpath"/>!</MESSAGE>
<MESSAGE>X2 = !<xsl:value-of select="$p2"/>!</MESSAGE>
<MESSAGE>X3 = !<xsl:value-of select="$p3"/>!</MESSAGE>
<MESSAGE>XYZ = !<xsl:value-of select="$xyz"/>!</MESSAGE>
	</xsl:template>

I get, in my output document

<MESSAGE xmlns:xalan="http://xml.apache.org/xalan" xmlns:dyn="http://exslt.org/dynamic">XPATH = !!</MESSAGE>
<MESSAGE xmlns:xalan="http://xml.apache.org/xalan" xmlns:dyn="http://exslt.org/dynamic">X2 = !!</MESSAGE>
<MESSAGE xmlns:xalan="http://xml.apache.org/xalan" xmlns:dyn="http://exslt.org/dynamic">X3 = !!</MESSAGE>
<MESSAGE xmlns:xalan="http://xml.apache.org/xalan" xmlns:dyn="http://exslt.org/dynamic">XYZ = !section!</MESSAGE>

However the minute I add /* after the document function, 

as in

		<xsl:apply-templates select="document(@filename)">
			<xsl:with-param name="xpath" select="@xpathRef"/>
			<xsl:with-param name="p2" select="45"/>
			<xsl:with-param name="p3" select="'wtf'"/>
		</xsl:apply-templates>

I get, as expected

<MESSAGE xmlns:xalan="http://xml.apache.org/xalan" xmlns:dyn="http://exslt.org/dynamic">XPATH = !/chapter!</MESSAGE>
<MESSAGE xmlns:xalan="http://xml.apache.org/xalan" xmlns:dyn="http://exslt.org/dynamic">X2 = !45!</MESSAGE>
<MESSAGE xmlns:xalan="http://xml.apache.org/xalan" xmlns:dyn="http://exslt.org/dynamic">X3 = !wtf!</MESSAGE>
<MESSAGE xmlns:xalan="http://xml.apache.org/xalan" xmlns:dyn="http://exslt.org/dynamic">XYZ = !section!</MESSAGE>


The root of the document being passed to the document function is "chapter", and I've tried this with modes, so I know for sure there is no way the second template could be getting called from elsewhere. This is Xalan 2.7.0 and jdk 1.5.0. 

I am baffled at how this can make sense and would love for someone to either enlighten me or confirm that this is a bug.

Thanks,

Eric

-- 
Eric Schwarzenbach
Principal Content Architect
Wrycan, Inc
617-684-0182


---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org