Martin Honnen created XALANJ-2800:
-------------------------------------

             Summary: NullPointerException when using XSLT key function call on 
right side of XPath 3.1 map ! operator
                 Key: XALANJ-2800
                 URL: https://issues.apache.org/jira/browse/XALANJ-2800
             Project: XalanJ2
          Issue Type: Bug
      Security Level: No security risk; visible to anyone (Ordinary problems in 
Xalan projects.  Anybody can view the issue.)
          Components: transformation, Xalan-CmdLine
    Affects Versions: The Latest Development Code
         Environment: Java 8, Windows 11
            Reporter: Martin Honnen
         Attachments: cars.xml, key-fn-call-in-map-exp-test2.xsl

Using the latest Xalan XSLT 3.0 development branch, I get a 
NullPointerException when trying to use an XSLT key function call on the right 
side of the XPath 3.1 map operator "!".

 

Expected result: the code should not give any errors but output e.g.

{code:xml}
<?xml version="1.0" encoding="UTF-8"?>
<set>
   <problem>
      <question>Which lots have red cars?</question>
      <answer>
         <lot id="L"/>
         <lot id="L"/>
         <lot id="N"/>
      </answer>
   </problem>
</set>
{code}
The XSLT code:
{code:xml}
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  version="3.0"
  xmlns:xs="http://www.w3.org/2001/XMLSchema";
  exclude-result-prefixes="xs">

  <xsl:output method="xml" indent="yes"/>

  <xsl:key name="car-by-color" match="cars/car" use="@color"/>
     
  <xsl:key name="lot-for-car" match="lot" use="car/@vin"/>
   
  <xsl:template match="lot">
      <lot id="{@id}"/>
  </xsl:template>
  
  <xsl:template match="/">
      <set>
          <problem>
              <question>Which lots have red cars?</question>
              <answer>
                  <xsl:apply-templates select="(key('car-by-color', 'red') ! 
key('lot-for-car', @vin))"/>
              </answer>
          </problem>
      </set>
  </xsl:template>

</xsl:stylesheet>
{code}
XML input:
{code:xml}
<dir>
    <cars>
        <car vin="101" color="red"/>
        <car vin="102" color="green"/>
        <car vin="103" color="red"/>
        <car vin="104" color="red"/>
    </cars>
    <lots>
        <lot id="L">
            <car vin="101"/>
            <car vin="103"/>
        </lot>
        <lot id="M">
            <car vin="102"/>
        </lot>
        <lot id="N">
            <car vin="104"/>
        </lot>
    </lots>
</dir>
{code}
Full error output:
{code:java}
<?xml version="1.0" encoding="UTF-8"?><set>
  <problem>
    <question>Which lots have red 
cars?</question>file:///C:/Users/marti/IdeaProjects/xalan-java/../../OneDrive/Documents/xslt/blog-xslt-3-by-example/xalan-xslt3-tests/key-fn-call-in-map-exp-test2.xsl;
 Zeilennummer22; Spaltennummer106; java.lang.NullPointerException
{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to