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




Reply via email to