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 "Theis, Karsten" <Ka...@PROSTEP.com> on 2005/07/05 15:34:51 UTC

Bugs using 'key' and 'tokeinze' with XSLTC

Hi,

I tried to speed up my mappings by using XSLTC, but I found the two
following bugs:

--- 1. Bug: ---
If I use a key like with a node set as parameter like this:
  <xsl:variable name="elements2" select="key('ElementIndex',
$elements1/@id)"/>
the result is invalid. 

Results of "test_key.xsl" with "test_key.xml" as input:
--------- With XSLTC: ---------
Elements1:
id_10019_2382
id_10019_2383
Elements2:

id_10019_2382

------ Without XSLTC (correct): ---------
Elements1:
id_10019_2382
id_10019_2383
Elements2:
id_10019_2382
id_10019_2382



----------------------------------------------

--- 2. Bug ---
Result of xalan:tokenize in invalid
          str:tokenize is valid

Results of "test_tokenize.xsl" (any input):

------ xalan:tokenize: --------
1
2
1234

------ str:tokenize: (correct) --------
1
2
1
2


I'm using xalan 2.6.0, java 1.4.2 with all xalan and xerces jars in the
bootclasspath

Thanks for any ideas!

Ciao,
Karsten


test_tokenize.xsl:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xalan="http://xml.apache.org/xalan"
xmlns:str="http://exslt.org/strings"  exclude-result-prefixes="str
xalan">

    <!-- root template -->
    <xsl:template match="/">
        <xsl:element name="test">
            <xsl:variable name="s">1 2 3 4</xsl:variable>
            <xsl:variable name="t1" select="str:tokenize($s, ' ')"/>
            <xsl:message>
                <xsl:value-of select="$t1[1]"/>
            </xsl:message>
            <xsl:message>
                <xsl:value-of select="$t1[2]"/>
            </xsl:message>
            <xsl:variable name="t2" select="xalan:tokenize($s, ' ')"/>
            <xsl:message>
                <xsl:value-of select="$t2[1]"/>
            </xsl:message>
            <xsl:message>
                <xsl:value-of select="$t2[2]"/>
            </xsl:message>
        </xsl:element>
    </xsl:template>
</xsl:transform>

test_key.xsl:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xalan="http://xml.apache.org/xalan"
xmlns:str="http://exslt.org/strings"  exclude-result-prefixes="str
xalan">

    <xsl:key name="ElementIndex" match="*" use="@id"/>
    <!-- root template -->
    <xsl:template match="/">
        <xsl:element name="test">
            <xsl:variable name="s">id_10019_2382
id_10019_2383</xsl:variable>
            <xsl:variable name="nodes" select="str:tokenize($s, ' ')"/>
            <xsl:variable name="elements1" select="key('ElementIndex',
$nodes)"/>
            <xsl:message>Elements1:</xsl:message>
            <xsl:message>
                <xsl:value-of select="$elements1[1]/@id"/>
            </xsl:message>
            <xsl:message>
                <xsl:value-of select="$elements1[2]/@id"/>
            </xsl:message>
            <xsl:variable name="elements2" select="key('ElementIndex',
$elements1/@id)"/>
            <xsl:message>Elements2:</xsl:message>
            <xsl:message>
                <xsl:value-of select="$elements2[1]/@id"/>
            </xsl:message>
            <xsl:message>
                <xsl:value-of select="$elements2[2]/@id"/>
            </xsl:message>
        </xsl:element>
    </xsl:template>
</xsl:transform>


test_key.xml:

<?xml version="1.0" encoding="UTF-8"?>
<test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Item id="id_10019_2382">
        <Name>Hugo</Name>
    </Item>
    <Item id="id_10019_2383">
        <Name>Emil</Name>
    </Item>
</test>






Re: Bugs using 'key' and 'tokeinze' with XSLTC

Posted by Henry Zongaro <zo...@ca.ibm.com>.
Hi, Karsten.

> --- 1. Bug: ---
> If I use a key like with a node set as parameter like this:
>   <xsl:variable name="elements2" select="key('ElementIndex',
> $elements1/@id)"/>
> the result is invalid. 

     This appears to be the same as the bug reported in Jira issue 
XALANJ-1938.[1]  The fix for that problem is available in the CVS or you 
can wait for the upcoming Xalan-J 2.7.0 release.

> --- 2. Bug ---
> Result of xalan:tokenize in invalid
>           str:tokenize is valid

     Please open a Jira issue for this problem,[2] and somebody will 
investigate.

Thanks,

Henry
[1] http://issues.apache.org/jira/browse/XALANJ-1938
[2] http://issues.apache.org/jira/
------------------------------------------------------------------
Henry Zongaro      Xalan development
IBM SWS Toronto Lab   T/L 969-6044;  Phone +1 905 413-6044
mailto:zongaro@ca.ibm.com