You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Th...@bgs-ag.de on 2001/02/22 09:06:42 UTC
Re: Xalan-j 2 BUG (setParameter)
Hi Gary,
how do you would define the working of the "setParameter(java.lang.String
name, java.lang.Object value)" method.
I have expected that this method works like "<xsl:with-param
name = qname
select = expression>
<!-- Content: template -->
</xsl:with-param>" (citation out of the spec) but only on stylesheet
level.
And for templates you implement this citation:
"xsl:with-param is allowed within both xsl:call-template and
xsl:apply-templates.
The value of the parameter is specified in the same way as for xsl:variable
and xsl:param."
For example this stylesheet works fine with Xalan-j_2_0_0:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="no" />
<xsl:template match="text()"/>
<xsl:template match="/">
<result>
<xsl:call-template name="path">
<xsl:with-param name="xpath" select="//applic"/>
</xsl:call-template>
</result>
</xsl:template>
<xsl:template name="path">
<xsl:param name="xpath" select="/"/>
<xsl:copy-of select="$xpath"/>
</xsl:template>
</xsl:stylesheet>
So why should the "setParameter(java.lang.String name, java.lang.Object value)" method not override the
"Category: top-level-element" Parameters like "<xsl:with-param..." does for "Category: instruction " Parameters?
May be that I am still absolutely wrong, but than please explain the new interpretation which differs from Xalan-j1.
Regards
Thomas
Gary L Peskin <ga...@firstech.com> am 21.02.2001 02:49:19
Bitte antworten an xalan-dev@xml.apache.org
An: xalan-dev@xml.apache.org
Kopie:
Thema: Re: Xalan-j 2 BUG
Thomas2.Maesing@bgs-ag.de wrote:
>
> Hi,
> the following may be is a bug:
>
> This is the stylesheet I have used to build the transformer:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version
="1.0">
> <xsl:output method="xml" indent="no" />
> <xsl:param name="xpath" select="/"/>
> <xsl:template match="text()"/>
> <xsl:template match="/">
> <result>
> <xsl:copy-of select="$xpath"/>
> </result>
> </xsl:template>
> </xsl:stylesheet>
>
> I want to use <xsl:param name="xpath" select="//idstatus"/>
> by
> transformer.setParameter("xpath", request.getParameter("xpath"));
> with the URL .../servlet/X2Path?xpath=//idstatus&xml=...
>
> Xalan-j2 uses it as
>
> <xsl:param name="xpath" select="'//idstatus'"/>
>
> May be that this is the correct way but then different XSLT-Processors
are not compatible.
Myriam was correct when she stated that it is no longer possible to pass
XPaths as parameters. In XalanJ2, use the following stylesheet with
your existing java code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:xalan="http://xml.apache.org/xalan"
exclude-result-prefixes="xalan">
<xsl:output method="xml" indent="no" />
<xsl:param name="xpath" select="/"/>
<xsl:template match="text()"/>
<xsl:template match="/">
<result>
<xsl:copy-of select="xalan:evaluate($xpath)"/>
</result>
</xsl:template>
</xsl:stylesheet>
I realize this uses an extension function but I can't find anything in
the XSLT 1.0 Spec that requires that you be able to pass an XPath as a
parameter.
HTH,
Gary
Re: Xalan-j 2 BUG (setParameter)
Posted by Gary L Peskin <ga...@firstech.com>.
Thomas2.Maesing@bgs-ag.de wrote:
>
> Hi Gary,
> how do you would define the working of the "setParameter(java.lang.String
> name, java.lang.Object value)" method.
> ...
>
> So why should the "setParameter(java.lang.String name, java.lang.Object value)" method not override the
> "Category: top-level-element" Parameters like "<xsl:with-param..." does for "Category: instruction " Parameters?
>
> May be that I am still absolutely wrong, but than please explain the new interpretation which differs from Xalan-j1.
Thomas --
I XalanJ1, if the second parameter to setParameter was a String, it was
interpreted as an XPath. In XalanJ2, it's interpreted as a string.
Gary