Have we checked whether this is one of our past fixes, or at least whether it can be reproduced in the official Xalan?
If it can't, having the user switch to the Apache code will solve their problem (at the expense of having to do the endorsed-libraries dance) or patch their JRE). If it can, and hasn't already been logged as a known issue, we should add it to the backlog. -- /_ Joe Kesselman (he/him/his) -/ _) My Alexa skill for New Music/New Sounds fans: / https://www.amazon.com/dp/B09WJ3H657/ () Plaintext Ribbon Campaign /\ Stamp out HTML mail! ________________________________ From: Bederov, Sergey <[email protected]> Sent: Monday, February 27, 2023 12:03:23 PM To: [email protected] <[email protected]> Subject: Xalan bug: key( ) clears variable Hello, I am using the Xalan engine which is embedded into the OpenJDK. On versions JDK15 to JDK21 an incorrect behavior is observed, which looks like a bug in Xalan. XSLT: <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:str="http://exslt.org/strings" xmlns:exslt="http://exslt.org/common" exclude-result-prefixes="plmxml"> <xsl:template match="Root"> <xsl:variable name="created"> <Created/> </xsl:variable> <xsl:apply-templates select="exslt:node-set($created)"> <xsl:with-param name="prm" select="@attr"/> </xsl:apply-templates> </xsl:template> <xsl:template match="Created"> <xsl:param name="prm"/> <Output> <Display> <xsl:value-of select="$prm"/> </Display> <Usage> <xsl:value-of select="key('nonexistentkey',$prm)"/> </Usage> <Display> <xsl:value-of select="$prm"/> </Display> </Output> </xsl:template> </xsl:stylesheet> XML: <?xml version="1.0" encoding="utf-8"?> <Root attr="foo"/> The problem is that in the second template, when the “key” function is called, the “prm” variable is for some reason cleared. In the output file, the first “Display” element contains the correct value “foo”, but the second “Display” element is empty. Why does it happen? It’s a variable which should always have the same value. Yes, here the “key” function is called for a key which doesn’t exist, but it’s not the cause of the problem. If a key is present, and if it contains the required value, the bug is still there. Actually the “key” function doesn’t find anything anyway, as if the variable was already empty. I see that the Xalan development is ongoing, so I thought it would be useful to report this bug. Sergey Bederov Senior Developer Cortona3D www.cortona3D.com<http://www.cortona3D.com>
