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>
test_tokenize.xsl
Description: test_tokenize.xsl
test_key.xsl
Description: test_key.xsl
<?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>
