You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Alex <az...@comcast.net> on 2004/11/05 00:41:07 UTC
Variables inside params issue
Given the following template:
<xsl:template match="/">
<xsl:param name="fred">
<xsl:variable name="anything" select="'WRONG'"/>
</xsl:param>
<xsl:param name="frank" select="'anywho'"/>
frank: <xsl:value-of select="$frank"/>
</xsl:template>
What should the value of $frank be? When I run this, I get 'WRONG'. If
I remove the variable declaration inside the param "fred", I get
'anywho'. Is this not legal XSLT, or a bug?
Here is the command line:
java org.apache.xalan.xslt.Process -IN test.xml -XSL test.xsl -OUT test.out
Also:
> java org.apache.xalan.xslt.EnvironmentCheck | grep version.xalan
version.xalan2_2=Xalan Java 2.6.0
Thanks,
Alex
Re: stumped by key not working
Posted by Christine Li <jy...@ca.ibm.com>.
Hi, Phil
I don't think it is a Xalan bug and you are right that the two variables
PREV_HISTORY and PREV_HISTORY_BYKEY should produce equivalent results. It
is better to provide a fully working stylesheet to identify the problem.
Thanks,
Christine Li
XSLT Development
IBM Toronto Lab
Tel: (905)413-2601
Email: jycli@ca.ibm.com
Phil Friedman <pf...@terralink.com>
11/10/2004 10:23 AM
Please respond to
pfriedma
To
cc
xalan-j-users <xa...@xml.apache.org>
Subject
stumped by key not working
I have a XML input file, like so:
<?xml version="1.0" encoding="UTF-8"?>
<ROOT ... >
<HISTORY ... HISTORY_ID="18291" PREV_HISTORY_ID="19072" ... >
...
</HISTORY>
<HISTORY ... HISTORY_ID="19073" PREV_HISTORY_ID="19071" ... >
...
</HISTORY>
<HISTORY ... HISTORY_ID="19072" PREV_HISTORY_ID="19036" ... >
...
</HISTORY>
<HISTORY ... HISTORY_ID="19071" PREV_HISTORY_ID="19023" ... >
...
</HISTORY>
...
</ROOT>
And a style sheet , like so:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns:sql="org.apache.xalan.lib.sql.XConnection"
extension-element-prefixes="sql" xmlns:xalan="http://xml.apache.org/xalan"
exclude-result-prefixes="xalan">
...
<xsl:variable name="ROOT" select="/"/>
<xsl:key name="HISTORY_HISTORY_ID" match="/ROOT/HISTORY"
use="@HISTORY_ID"/>
...
<xsl:variable name="PREV_HISTORY">
<xsl:copy-of
select="xalan:nodeset($ROOT)/ROOT/HISTORY[ current()/@PREV_HISTORY_ID=
@HISTORY_ID]"/>
</xsl:variable>
<xsl:variable name="PREV_HISTORY_BYKEY">
<xsl:copy-of select="key(
'HISTORY_HISTORY_ID', @PREV_HISTORY_ID)"/>
</xsl:variable>
...
</xsl:stylesheet>
My question: Why aren't the variables PREV_HISTORY and PREV_HISTORY_BYKEY
equivalent? PREV_HISTORY works as expected, but PREV_HISTORY_BYKEY usually
returns nothing. Is my code incorrect or might this be a Xalan bug?
Several other keys seem to be returning the expected results. Any ideas
would be appreciated. Thanks.
I'm using Xalan 2.6.0 like so:
C:\Xvsn\3X>"C:\Program Files\Java\j2re1.4.2_05\bin\java"
-Xbootclasspath/p:"C:\Shared\xalan-j_2_6_0.2-01-NNN\build\xalan.jar";"C:\Shared\xalan-j_2_6_0.2-01-NNN\bin\xercesImpl.jar";"C:\Shared\xalan-j_2_6_0.2-01-NNN\bin\xml-apis.jar"
-cp "C:\Program
Files\Sybase\Shared8.0.2.4398\jConnect-5_5\classes\jconn2.jar";"C:\Program
Files\NetDirect\JDataConnect2.21.004\JARs\JData2_0.jar" -Xmx512m
org.apache.xalan.xslt.Process -xsl TtyMap.xsl -in in.xml -out out.txi
Regards, Phil Friedman
stumped by key not working
Posted by Phil Friedman <pf...@terralink.com>.
I have a XML input file, like so:
<?xml version="1.0" encoding="UTF-8"?>
<ROOT ... >
<HISTORY ... HISTORY_ID="18291" PREV_HISTORY_ID="19072" ... >
...
</HISTORY>
<HISTORY ... HISTORY_ID="19073" PREV_HISTORY_ID="19071" ... >
...
</HISTORY>
<HISTORY ... HISTORY_ID="19072" PREV_HISTORY_ID="19036" ... >
...
</HISTORY>
<HISTORY ... HISTORY_ID="19071" PREV_HISTORY_ID="19023" ... >
...
</HISTORY>
...
</ROOT>
And a style sheet , like so:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:sql="org.apache.xalan.lib.sql.XConnection" extension-element-prefixes="sql" xmlns:xalan="http://xml.apache.org/xalan" exclude-result-prefixes="xalan">
...
<xsl:variable name="ROOT" select="/"/>
<xsl:key name="HISTORY_HISTORY_ID" match="/ROOT/HISTORY" use="@HISTORY_ID"/>
...
<xsl:variable name="PREV_HISTORY">
<xsl:copy-of select="xalan:nodeset($ROOT)/ROOT/HISTORY[ current()/@PREV_HISTORY_ID= @HISTORY_ID]"/>
</xsl:variable>
<xsl:variable name="PREV_HISTORY_BYKEY">
<xsl:copy-of select="key( 'HISTORY_HISTORY_ID', @PREV_HISTORY_ID)"/>
</xsl:variable>
...
</xsl:stylesheet>
My question: Why aren't the variables PREV_HISTORY and PREV_HISTORY_BYKEY equivalent? PREV_HISTORY works as expected, but PREV_HISTORY_BYKEY usually returns nothing. Is my code incorrect or might this be a Xalan bug? Several other keys seem to be returning the expected results. Any ideas would be appreciated. Thanks.
I'm using Xalan 2.6.0 like so:
C:\Xvsn\3X>"C:\Program Files\Java\j2re1.4.2_05\bin\java" -Xbootclasspath/p:"C:\Shared\xalan-j_2_6_0.2-01-NNN\build\xalan.jar";"C:\Shared\xalan-j_2_6_0.2-01-NNN\bin\xercesImpl.jar";"C:\Shared\xalan-j_2_6_0.2-01-NNN\bin\xml-apis.jar" -cp "C:\Program Files\Sybase\Shared8.0.2.4398\jConnect-5_5\classes\jconn2.jar";"C:\Program Files\NetDirect\JDataConnect2.21.004\JARs\JData2_0.jar" -Xmx512m org.apache.xalan.xslt.Process -xsl TtyMap.xsl -in in.xml -out out.txi
Regards, Phil Friedman
Re: Variables inside params issue
Posted by Morris Kwan <mk...@ca.ibm.com>.
It appears to be a bug for Xalan interpretive. XSLTC is OK with this test.
Can you enter a bug into the JIRA database (
http://nagoya.apache.org/jira/secure/Dashboard.jspa)?
Thanks.
Morris Kwan
XSLT Development
IBM Toronto Lab
Tel: (905)413-3729
Email: mkwan@ca.ibm.com
Alex
<azack@comcast.ne
t> To
xalan-j-users
11/04/2004 06:41 <xa...@xml.apache.org>
PM cc
Subject
Variables inside params issue
Given the following template:
<xsl:template match="/">
<xsl:param name="fred">
<xsl:variable name="anything" select="'WRONG'"/>
</xsl:param>
<xsl:param name="frank" select="'anywho'"/>
frank: <xsl:value-of select="$frank"/>
</xsl:template>
What should the value of $frank be? When I run this, I get 'WRONG'. If
I remove the variable declaration inside the param "fred", I get
'anywho'. Is this not legal XSLT, or a bug?
Here is the command line:
java org.apache.xalan.xslt.Process -IN test.xml -XSL test.xsl -OUT test.out
Also:
> java org.apache.xalan.xslt.EnvironmentCheck | grep version.xalan
version.xalan2_2=Xalan Java 2.6.0
Thanks,
Alex
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<xsl:param name="fred">
<xsl:variable name="anything" select="'WRONG'"/>
</xsl:param>
<xsl:param name="frank" select="'anywho'"/>
frank: <xsl:value-of select="$frank"/>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0"?>
<test>
<node>value_one</node>
<node>value_two</node>
</test><?xml version="1.0" encoding="UTF-8"?>
frank: WRONG