XalanJ2
  1. XalanJ2
  2. XALANJ-1447

NullPointerException while using key() function

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: 2.5, 2.4, 2.4Dx
    • Fix Version/s: None
    • Component/s: XPath
    • Security Level: No security risk; visible to anyone (Ordinary problems in Xalan projects. Anybody can view the issue.)
    • Labels:
      None
    • Environment:
      Operating System: Windows NT/2K
      Platform: PC

      Description

      I have the stylesheet containing:
      <xsl:key name="bt-data" match="//bt:data" use="@id" />
      <xsl:key name="uc-attribute" match="//uc:attribute" use="@name" />

      If I use this keys this way:
      <xsl:value-of select="key('bt-data', key('uc-
      attribute', 'list1.0.A003')/@data)" />

      NullPointerException is thrown. If an element is found by key uc-attribute, the
      exception is thrown. If no element is found by key uc-attribute, no exception
      is thrown. This problem occurs in Xalan version 2.4.0, 2.4.1 and 2.5.D1.
      Versions 2.2.0 and 2.3.1 works fine.

      1. Bug1447FuncKey.txt
        0.5 kB
        Christine Li
      2. ASF.LICENSE.NOT.GRANTED--FuncKeyPatch.txt
        2 kB
        Christine Li
      3. ASF.LICENSE.NOT.GRANTED--FuncKeyPatch.txt
        2 kB
        Christine Li
      4. ASF.LICENSE.NOT.GRANTED--FuncKeyIDPatch.txt
        4 kB
        Christine Li
      5. ASF.LICENSE.NOT.GRANTED--out.zip
        0.9 kB
        Christine Li
      6. ASF.LICENSE.NOT.GRANTED--idkey68.xsl
        0.7 kB
        Christine Li
      7. ASF.LICENSE.NOT.GRANTED--idkey68.xml
        0.3 kB
        Christine Li
      8. ASF.LICENSE.NOT.GRANTED--idkey67.xsl
        0.7 kB
        Christine Li
      9. ASF.LICENSE.NOT.GRANTED--idkey67.xml
        0.3 kB
        Christine Li
      10. ASF.LICENSE.NOT.GRANTED--idkey66.xsl
        0.6 kB
        Christine Li
      11. ASF.LICENSE.NOT.GRANTED--idkey66.xml
        0.3 kB
        Christine Li
      12. ASF.LICENSE.NOT.GRANTED--idkey65.xsl
        0.7 kB
        Christine Li
      13. ASF.LICENSE.NOT.GRANTED--idkey65.xml
        0.3 kB
        Christine Li
      14. ASF.LICENSE.NOT.GRANTED--idkey64.xsl
        0.7 kB
        Christine Li
      15. ASF.LICENSE.NOT.GRANTED--idkey64.xml
        0.7 kB
        Christine Li
      16. ASF.LICENSE.NOT.GRANTED--tst.xsl
        2 kB
        Luboš Hartman
      17. ASF.LICENSE.NOT.GRANTED--tst.xml
        5 kB
        Luboš Hartman
      18. ASF.LICENSE.NOT.GRANTED--UCXMLTest.xml
        4 kB
        Luboš Hartman

        Activity

        Hide
        Luboš Hartman added a comment -

        Exception for Xalan version 2.5.D1:
        cz.unicorn.afu_v1.af_v1.util_v1.xml_v1.XMLDocumentException(XMLDocument.E003):
        afu_v1.af_v1.util_v1.xml_v1.XXMLDocument: Transform exception.
        Inner Exception is:
        javax.xml.transform.TransformerException: java.lang.NullPointerException
        at cz.unicorn.afu_v1.af_v1.util_v1.xml_v1.XMLDocumentImpl.transform
        (XMLDocumentImpl.java:546)
        at cz.unicorn.test.xalan.TestXSLJava.run(TestXSLJava.java:90)
        *
        ; SystemID: file:/C:/Temp/UCXMLTest3.xsl; Line#: 23; Column#: 91
        javax.xml.transform.TransformerException: java.lang.NullPointerException
        at org.apache.xalan.templates.ElemValueOf.execute
        (ElemValueOf.java:330)
        at
        org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes
        (ElemApplyTemplates.java:425)
        at org.apache.xalan.templates.ElemApplyTemplates.execute
        (ElemApplyTemplates.java:216)
        at
        org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes
        (ElemApplyTemplates.java:425)
        at org.apache.xalan.templates.ElemApplyTemplates.execute
        (ElemApplyTemplates.java:216)
        at
        org.apache.xalan.transformer.TransformerImpl.executeChildTemplates
        (TransformerImpl.java:2336)
        at
        org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode
        (TransformerImpl.java:2157)
        at org.apache.xalan.transformer.TransformerImpl.transformNode
        (TransformerImpl.java:1210)
        at org.apache.xalan.transformer.TransformerImpl.transform
        (TransformerImpl.java:665)
        at org.apache.xalan.transformer.TransformerImpl.transform
        (TransformerImpl.java:1126)
        at org.apache.xalan.transformer.TransformerImpl.transform
        (TransformerImpl.java:1104)
        at
        cz.unicorn.afu_v1.af_v1.util_v1.xml_v1.XMLDocumentImpl.transform
        (XMLDocumentImpl.java:539)
        at cz.unicorn.test.xalan.TestXSLJava.run(TestXSLJava.java:90)
        ---------
        java.lang.NullPointerException
        at org.apache.xpath.objects.XNodeSet.dispatchCharactersEvents
        (XNodeSet.java:273)
        at org.apache.xpath.Expression.executeCharsToContentHandler
        (Expression.java:351)
        at org.apache.xalan.templates.ElemValueOf.execute
        (ElemValueOf.java:311)
        at
        org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes
        (ElemApplyTemplates.java:425)
        at org.apache.xalan.templates.ElemApplyTemplates.execute
        (ElemApplyTemplates.java:216)
        at
        org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes
        (ElemApplyTemplates.java:425)
        at org.apache.xalan.templates.ElemApplyTemplates.execute
        (ElemApplyTemplates.java:216)
        at
        org.apache.xalan.transformer.TransformerImpl.executeChildTemplates
        (TransformerImpl.java:2336)
        at
        org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode
        (TransformerImpl.java:2157)
        at org.apache.xalan.transformer.TransformerImpl.transformNode
        (TransformerImpl.java:1210)
        at org.apache.xalan.transformer.TransformerImpl.transform
        (TransformerImpl.java:665)
        at org.apache.xalan.transformer.TransformerImpl.transform
        (TransformerImpl.java:1126)
        at org.apache.xalan.transformer.TransformerImpl.transform
        (TransformerImpl.java:1104)
        at
        cz.unicorn.afu_v1.af_v1.util_v1.xml_v1.XMLDocumentImpl.transform
        (XMLDocumentImpl.java:539)
        at cz.unicorn.test.xalan.TestXSLJava.run(TestXSLJava.java:90)

        Show
        Luboš Hartman added a comment - Exception for Xalan version 2.5.D1: cz.unicorn.afu_v1.af_v1.util_v1.xml_v1.XMLDocumentException(XMLDocument.E003): afu_v1.af_v1.util_v1.xml_v1.XXMLDocument: Transform exception. Inner Exception is: javax.xml.transform.TransformerException: java.lang.NullPointerException at cz.unicorn.afu_v1.af_v1.util_v1.xml_v1.XMLDocumentImpl.transform (XMLDocumentImpl.java:546) at cz.unicorn.test.xalan.TestXSLJava.run(TestXSLJava.java:90) * ; SystemID: file:/C:/Temp/UCXMLTest3.xsl ; Line#: 23; Column#: 91 javax.xml.transform.TransformerException: java.lang.NullPointerException at org.apache.xalan.templates.ElemValueOf.execute (ElemValueOf.java:330) at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes (ElemApplyTemplates.java:425) at org.apache.xalan.templates.ElemApplyTemplates.execute (ElemApplyTemplates.java:216) at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes (ElemApplyTemplates.java:425) at org.apache.xalan.templates.ElemApplyTemplates.execute (ElemApplyTemplates.java:216) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates (TransformerImpl.java:2336) at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode (TransformerImpl.java:2157) at org.apache.xalan.transformer.TransformerImpl.transformNode (TransformerImpl.java:1210) at org.apache.xalan.transformer.TransformerImpl.transform (TransformerImpl.java:665) at org.apache.xalan.transformer.TransformerImpl.transform (TransformerImpl.java:1126) at org.apache.xalan.transformer.TransformerImpl.transform (TransformerImpl.java:1104) at cz.unicorn.afu_v1.af_v1.util_v1.xml_v1.XMLDocumentImpl.transform (XMLDocumentImpl.java:539) at cz.unicorn.test.xalan.TestXSLJava.run(TestXSLJava.java:90) --------- java.lang.NullPointerException at org.apache.xpath.objects.XNodeSet.dispatchCharactersEvents (XNodeSet.java:273) at org.apache.xpath.Expression.executeCharsToContentHandler (Expression.java:351) at org.apache.xalan.templates.ElemValueOf.execute (ElemValueOf.java:311) at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes (ElemApplyTemplates.java:425) at org.apache.xalan.templates.ElemApplyTemplates.execute (ElemApplyTemplates.java:216) at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes (ElemApplyTemplates.java:425) at org.apache.xalan.templates.ElemApplyTemplates.execute (ElemApplyTemplates.java:216) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates (TransformerImpl.java:2336) at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode (TransformerImpl.java:2157) at org.apache.xalan.transformer.TransformerImpl.transformNode (TransformerImpl.java:1210) at org.apache.xalan.transformer.TransformerImpl.transform (TransformerImpl.java:665) at org.apache.xalan.transformer.TransformerImpl.transform (TransformerImpl.java:1126) at org.apache.xalan.transformer.TransformerImpl.transform (TransformerImpl.java:1104) at cz.unicorn.afu_v1.af_v1.util_v1.xml_v1.XMLDocumentImpl.transform (XMLDocumentImpl.java:539) at cz.unicorn.test.xalan.TestXSLJava.run(TestXSLJava.java:90)
        Hide
        Christine Li added a comment -

        Could you provide your xml? I am trying to reproduce the Exception.

        Show
        Christine Li added a comment - Could you provide your xml? I am trying to reproduce the Exception.
        Hide
        Luboš Hartman added a comment -

        <?xml version="1.0" encoding="UTF-8"?>
        <uc:document
        xmlns:uc="http://www.unicorn.cz/afu_v1/af_v1/appc_v1/ucm_v1/usecaseDocum
        ent.xsd"
        xmlns:bt="http://www.unicorn.cz/afu_v1/af_v1/busc_v2/bt_v1/businessType.
        xsd"
        xmlns:bdo="http://www.unicorn.cz/afu_v1/af_v1/busc_v2/bdo_v1/businessDat
        aObject.xsd">

        <uc:data>
        <bt:data id="bdo101"
        type="cz.unicorn.ues_v5.af_v1.core_v1.object_v1.BDO000001">
        <bdo:bdo>
        <bdo:attribute name="OID">
        <bt:data id="att1"
        type="cz.unicorn.afu_v1.af_v1.busc_v2.bt_v1.OID">101</bt:data>
        </bdo:attribute>
        <bdo:attribute name="A001">
        <bt:data id="att2"
        type="cz.unicorn.afu_v1.af_v1.busc_v2.bt_v1.BTName">BD1: Attr 1</bt:data>
        </bdo:attribute>
        <bdo:attribute name="A002">
        <bt:data id="att3"
        type="cz.unicorn.afu_v1.af_v1.busc_v2.bt_v1.BTName">BDO1: Attr 2</bt:data>
        </bdo:attribute>
        <bdo:attribute name="A003">
        <bt:data id="att4"
        type="cz.unicorn.afu_v1.af_v1.busc_v2.bt_v1.BTName">BDO1: Attr 3</bt:data>
        </bdo:attribute>
        <bdo:attribute name="A004">
        <bt:data id="att5"
        type="cz.unicorn.ues_v5.af_v1.core_v1.object_v1.BDO000001" ref="bdo102"/>
        </bdo:attribute>
        </bdo:bdo>
        </bt:data>
        <bt:data id="list101"
        type="cz.unicorn.ues_v5.af_v1.core_v1.object_v1.BDO000001">
        <bdo:list>
        <bt:data id="att6" ref="bdo101" />
        <bt:data id="att7" ref="bdo101" />
        <bt:data id="att8" ref="bdo101" />
        </bdo:list>
        </bt:data>
        <bt:data id="bdo102"
        type="cz.unicorn.ues_v5.af_v1.core_v1.object_v1.BDO000001">
        <bdo:bdo>
        <bdo:attribute name="OID">
        <bt:data
        type="cz.unicorn.afu_v1.af_v1.busc_v2.bt_v1.OID">102</bt:data>
        </bdo:attribute>
        <bdo:attribute name="A001">
        <bt:data
        type="cz.unicorn.afu_v1.af_v1.busc_v2.bt_v1.BTName">BD2: Attr 1</bt:data>
        </bdo:attribute>
        <bdo:attribute name="A002">
        <bt:data
        type="cz.unicorn.afu_v1.af_v1.busc_v2.bt_v1.BTName">BDO2: Attr 2</bt:data>
        </bdo:attribute>
        <bdo:attribute name="A003">
        <bt:data
        type="cz.unicorn.afu_v1.af_v1.busc_v2.bt_v1.BTName">BDO2: Attr 3</bt:data>
        </bdo:attribute>
        <bdo:attribute name="A004">
        <bt:data
        type="cz.unicorn.ues_v5.af_v1.core_v1.object_v1.BDO000001" ref="bdo101"/>
        </bdo:attribute>
        </bdo:bdo>
        </bt:data>
        </uc:data>

        <uc:usecase deployName="..." xslPath="..." contentType="...">
        <uc:attributes>
        <uc:attribute name="first" data="bdo101"/>
        <uc:attribute name="second" data="bdo102"/>
        <uc:attribute name="first.A001" data="att2"/>
        <uc:attribute name="first.A002" data="att3"/>
        <uc:attribute name="first.A003" data="att4"/>
        <uc:attribute name="first.A004" data="att5"/>
        <uc:attribute name="first.A004.A001" data="att5"/>
        <uc:attribute name="first.A004.A002" data="att5"/>
        <uc:attribute name="first.A004.A003" data="att5"/>
        <uc:attribute name="list1" data="list101"/>
        <uc:attribute name="list1.0" data="bdo101"/>
        <uc:attribute name="list1.0.A003" data="att4"/>
        <uc:attribute name="list1.0.A002" data="att3"/>
        <uc:attribute name="list1.1.A003" data="att4"/>
        <uc:attribute name="list1.1.A002" data="att3"/>
        <uc:attribute name="list1.2.A003" data="att4"/>
        <uc:attribute name="list1.2.A002" data="att3"/>
        </uc:attributes>
        <uc:component deployName="..." xslPath="..." contentType="...">
        <uc:attributes>
        <uc:attribute name="first" data="bdo101"/>
        <uc:attribute name="second" data="bdo102"/>
        <uc:attribute name="first.A001" data="att2"/>
        <uc:attribute name="first.A002" data="att3"/>
        <uc:attribute name="first.A003" data="att4"/>
        <uc:attribute name="first.A004" data="att5"/>
        <uc:attribute name="first.A004.A001"
        data="att5"/>
        <uc:attribute name="first.A004.A002"
        data="att5"/>
        <uc:attribute name="first.A004.A003"
        data="att5"/>
        <uc:attribute name="list1" data="list101"/>
        <uc:attribute name="list1.0" data="bdo101"/>
        <uc:attribute name="list1.0.A003" data="att4"/>
        <uc:attribute name="list1.0.A002" data="att3"/>
        <uc:attribute name="list1.1.A003" data="att4"/>
        <uc:attribute name="list1.1.A002" data="att3"/>
        <uc:attribute name="list1.2.A003" data="att4"/>
        <uc:attribute name="list1.2.A002" data="att3"/>
        </uc:attributes>
        <uc:component deployName="..." xslPath="..."
        contentType="...">
        <uc:attributes>
        <uc:attribute name="first"
        data="bdo101"/>
        <uc:attribute name="second"
        data="bdo102"/>
        <uc:attribute name="list1.2.A003"
        data="att4"/>
        <uc:attribute name="list1.2.A002"
        data="att3"/>
        </uc:attributes>
        </uc:component>
        </uc:component>
        </uc:usecase>

        </uc:document>

        Show
        Luboš Hartman added a comment - <?xml version="1.0" encoding="UTF-8"?> <uc:document xmlns:uc="http://www.unicorn.cz/afu_v1/af_v1/appc_v1/ucm_v1/usecaseDocum ent.xsd" xmlns:bt="http://www.unicorn.cz/afu_v1/af_v1/busc_v2/bt_v1/businessType. xsd" xmlns:bdo="http://www.unicorn.cz/afu_v1/af_v1/busc_v2/bdo_v1/businessDat aObject.xsd"> <uc:data> <bt:data id="bdo101" type="cz.unicorn.ues_v5.af_v1.core_v1.object_v1.BDO000001"> <bdo:bdo> <bdo:attribute name="OID"> <bt:data id="att1" type="cz.unicorn.afu_v1.af_v1.busc_v2.bt_v1.OID">101</bt:data> </bdo:attribute> <bdo:attribute name="A001"> <bt:data id="att2" type="cz.unicorn.afu_v1.af_v1.busc_v2.bt_v1.BTName">BD1: Attr 1</bt:data> </bdo:attribute> <bdo:attribute name="A002"> <bt:data id="att3" type="cz.unicorn.afu_v1.af_v1.busc_v2.bt_v1.BTName">BDO1: Attr 2</bt:data> </bdo:attribute> <bdo:attribute name="A003"> <bt:data id="att4" type="cz.unicorn.afu_v1.af_v1.busc_v2.bt_v1.BTName">BDO1: Attr 3</bt:data> </bdo:attribute> <bdo:attribute name="A004"> <bt:data id="att5" type="cz.unicorn.ues_v5.af_v1.core_v1.object_v1.BDO000001" ref="bdo102"/> </bdo:attribute> </bdo:bdo> </bt:data> <bt:data id="list101" type="cz.unicorn.ues_v5.af_v1.core_v1.object_v1.BDO000001"> <bdo:list> <bt:data id="att6" ref="bdo101" /> <bt:data id="att7" ref="bdo101" /> <bt:data id="att8" ref="bdo101" /> </bdo:list> </bt:data> <bt:data id="bdo102" type="cz.unicorn.ues_v5.af_v1.core_v1.object_v1.BDO000001"> <bdo:bdo> <bdo:attribute name="OID"> <bt:data type="cz.unicorn.afu_v1.af_v1.busc_v2.bt_v1.OID">102</bt:data> </bdo:attribute> <bdo:attribute name="A001"> <bt:data type="cz.unicorn.afu_v1.af_v1.busc_v2.bt_v1.BTName">BD2: Attr 1</bt:data> </bdo:attribute> <bdo:attribute name="A002"> <bt:data type="cz.unicorn.afu_v1.af_v1.busc_v2.bt_v1.BTName">BDO2: Attr 2</bt:data> </bdo:attribute> <bdo:attribute name="A003"> <bt:data type="cz.unicorn.afu_v1.af_v1.busc_v2.bt_v1.BTName">BDO2: Attr 3</bt:data> </bdo:attribute> <bdo:attribute name="A004"> <bt:data type="cz.unicorn.ues_v5.af_v1.core_v1.object_v1.BDO000001" ref="bdo101"/> </bdo:attribute> </bdo:bdo> </bt:data> </uc:data> <uc:usecase deployName="..." xslPath="..." contentType="..."> <uc:attributes> <uc:attribute name="first" data="bdo101"/> <uc:attribute name="second" data="bdo102"/> <uc:attribute name="first.A001" data="att2"/> <uc:attribute name="first.A002" data="att3"/> <uc:attribute name="first.A003" data="att4"/> <uc:attribute name="first.A004" data="att5"/> <uc:attribute name="first.A004.A001" data="att5"/> <uc:attribute name="first.A004.A002" data="att5"/> <uc:attribute name="first.A004.A003" data="att5"/> <uc:attribute name="list1" data="list101"/> <uc:attribute name="list1.0" data="bdo101"/> <uc:attribute name="list1.0.A003" data="att4"/> <uc:attribute name="list1.0.A002" data="att3"/> <uc:attribute name="list1.1.A003" data="att4"/> <uc:attribute name="list1.1.A002" data="att3"/> <uc:attribute name="list1.2.A003" data="att4"/> <uc:attribute name="list1.2.A002" data="att3"/> </uc:attributes> <uc:component deployName="..." xslPath="..." contentType="..."> <uc:attributes> <uc:attribute name="first" data="bdo101"/> <uc:attribute name="second" data="bdo102"/> <uc:attribute name="first.A001" data="att2"/> <uc:attribute name="first.A002" data="att3"/> <uc:attribute name="first.A003" data="att4"/> <uc:attribute name="first.A004" data="att5"/> <uc:attribute name="first.A004.A001" data="att5"/> <uc:attribute name="first.A004.A002" data="att5"/> <uc:attribute name="first.A004.A003" data="att5"/> <uc:attribute name="list1" data="list101"/> <uc:attribute name="list1.0" data="bdo101"/> <uc:attribute name="list1.0.A003" data="att4"/> <uc:attribute name="list1.0.A002" data="att3"/> <uc:attribute name="list1.1.A003" data="att4"/> <uc:attribute name="list1.1.A002" data="att3"/> <uc:attribute name="list1.2.A003" data="att4"/> <uc:attribute name="list1.2.A002" data="att3"/> </uc:attributes> <uc:component deployName="..." xslPath="..." contentType="..."> <uc:attributes> <uc:attribute name="first" data="bdo101"/> <uc:attribute name="second" data="bdo102"/> <uc:attribute name="list1.2.A003" data="att4"/> <uc:attribute name="list1.2.A002" data="att3"/> </uc:attributes> </uc:component> </uc:component> </uc:usecase> </uc:document>
        Hide
        Luboš Hartman added a comment -

        <?xml version="1.0"?>
        <xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

        xmlns:ext="http://xml.apache.org/xalan/cz.unicorn.afu_v1.af_v1.appc_v1.ucm_v1.tr
        ansform.DataSelector"

        xmlns:uc="http://www.unicorn.cz/afu_v1/af_v1/appc_v1/ucm_v1/usecaseDocument.xsd"
        xmlns:bt="http://www.unicorn.cz/afu_v1/af_v1/busc_v2/bt_v1/businessType.xsd"

        xmlns:bdo="http://www.unicorn.cz/afu_v1/af_v1/busc_v2/bdo_v1/businessDataObject.
        xsd"

        xmlns:vc="http://www.unicorn.cz/afu_v1/af_v1/appc_v1/ucm_v1/visualComponentDocum
        ent.xsd"
        >

        <xsl:key name="bt-data" match="//bt:data" use="@id" />
        <xsl:key name="uc-attribute" match="//uc:attribute" use="@name" />

        <xsl:template match="text()" />

        <xsl:template match="/">
        <xsl:text>BBB</xsl:text>
        <xsl:apply-templates />
        <xsl:text>CCC</xsl:text>
        </xsl:template>

        <xsl:template match="uc:data">
        <xsl:value-of select="key('bt-data', key('uc-
        attribute', 'list1.0.A001')/@data)" />
        <xsl:value-of select="key('bt-data', key('uc-
        attribute', 'list1.0.A002')/@data)" />
        <xsl:value-of select="key('bt-data', key('uc-
        attribute', 'list1.0.A003')/@data)" />
        <xsl:value-of select="key('bt-data', key('uc-
        attribute', 'list1.0.A004')/@data)" />
        <xsl:value-of select="key('bt-data', key('uc-
        attribute', 'list1.0.A005')/@data)" />
        <xsl:value-of select="key('bt-data', key('uc-
        attribute', 'list1.0.A004')/@data)" />
        <xsl:value-of select="key('bt-data', key('uc-
        attribute', 'list1.0.A005')/@data)" />
        <xsl:value-of select="key('bt-data', key('uc-
        attribute', 'list1.0.A006')/@data)" />
        <xsl:value-of select="key('bt-data', key('uc-
        attribute', 'list1.0.A007')/@data)" />
        <xsl:value-of select="key('bt-data', key('uc-
        attribute', 'list1.0.A008')/@data)" />
        <xsl:value-of select="key('bt-data', key('uc-
        attribute', 'list1.0.A009')/@data)" />
        <xsl:value-of select="key('bt-data', key('uc-
        attribute', 'list1.0.A000')/@data)" />
        <xsl:text>AAA</xsl:text>
        </xsl:template>

        </xsl:stylesheet>

        Show
        Luboš Hartman added a comment - <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ext="http://xml.apache.org/xalan/cz.unicorn.afu_v1.af_v1.appc_v1.ucm_v1.tr ansform.DataSelector" xmlns:uc="http://www.unicorn.cz/afu_v1/af_v1/appc_v1/ucm_v1/usecaseDocument.xsd" xmlns:bt="http://www.unicorn.cz/afu_v1/af_v1/busc_v2/bt_v1/businessType.xsd" xmlns:bdo="http://www.unicorn.cz/afu_v1/af_v1/busc_v2/bdo_v1/businessDataObject. xsd" xmlns:vc="http://www.unicorn.cz/afu_v1/af_v1/appc_v1/ucm_v1/visualComponentDocum ent.xsd" > <xsl:key name="bt-data" match="//bt:data" use="@id" /> <xsl:key name="uc-attribute" match="//uc:attribute" use="@name" /> <xsl:template match="text()" /> <xsl:template match="/"> <xsl:text>BBB</xsl:text> <xsl:apply-templates /> <xsl:text>CCC</xsl:text> </xsl:template> <xsl:template match="uc:data"> <xsl:value-of select="key('bt-data', key('uc- attribute', 'list1.0.A001')/@data)" /> <xsl:value-of select="key('bt-data', key('uc- attribute', 'list1.0.A002')/@data)" /> <xsl:value-of select="key('bt-data', key('uc- attribute', 'list1.0.A003')/@data)" /> <xsl:value-of select="key('bt-data', key('uc- attribute', 'list1.0.A004')/@data)" /> <xsl:value-of select="key('bt-data', key('uc- attribute', 'list1.0.A005')/@data)" /> <xsl:value-of select="key('bt-data', key('uc- attribute', 'list1.0.A004')/@data)" /> <xsl:value-of select="key('bt-data', key('uc- attribute', 'list1.0.A005')/@data)" /> <xsl:value-of select="key('bt-data', key('uc- attribute', 'list1.0.A006')/@data)" /> <xsl:value-of select="key('bt-data', key('uc- attribute', 'list1.0.A007')/@data)" /> <xsl:value-of select="key('bt-data', key('uc- attribute', 'list1.0.A008')/@data)" /> <xsl:value-of select="key('bt-data', key('uc- attribute', 'list1.0.A009')/@data)" /> <xsl:value-of select="key('bt-data', key('uc- attribute', 'list1.0.A000')/@data)" /> <xsl:text>AAA</xsl:text> </xsl:template> </xsl:stylesheet>
        Hide
        Luboš Hartman added a comment -

        The right output is:
        <?xml version="1.0" encoding="UTF-8"?>
        BBBBDO1: Attr 2BDO1: Attr 3AAACCC

        I use Java 1.3.1_03 and xerces for testing.

        Show
        Luboš Hartman added a comment - The right output is: <?xml version="1.0" encoding="UTF-8"?> BBBBDO1: Attr 2BDO1: Attr 3AAACCC I use Java 1.3.1_03 and xerces for testing.
        Hide
        Luboš Hartman added a comment -

        Created an attachment (id=5352)
        XML file for testing (input XML)

        Show
        Luboš Hartman added a comment - Created an attachment (id=5352) XML file for testing (input XML)
        Hide
        Christine Li added a comment -

        I used the sample code SimpleTransform.java with the attached XML and XSL
        files. It works fine with Xalan_2_5_D1. And I tested it by using both Sun JDK
        1.3.1_07 and 1.4.0_03. It will be easy to figure out the problem by using a
        simple transform program with your xml and xsl files.

        Show
        Christine Li added a comment - I used the sample code SimpleTransform.java with the attached XML and XSL files. It works fine with Xalan_2_5_D1. And I tested it by using both Sun JDK 1.3.1_07 and 1.4.0_03. It will be easy to figure out the problem by using a simple transform program with your xml and xsl files.
        Hide
        Luboš Hartman added a comment -

        Created an attachment (id=5399)
        Test XML file

        Show
        Luboš Hartman added a comment - Created an attachment (id=5399) Test XML file
        Hide
        Luboš Hartman added a comment -

        Created an attachment (id=5400)
        Test XSL file

        Show
        Luboš Hartman added a comment - Created an attachment (id=5400) Test XSL file
        Hide
        Luboš Hartman added a comment -

        Try to transform the XML file in attachment using XSL file in attachment. I
        tried:
        java -cp xml-apis.jar;xercesImpl.jar;xalan.jar org.apache.xalan.xslt.Process -
        IN tst.xml -XSL tst.xsl

        and the output is:
        <?xml version="1.0" encoding="UTF-8"?>

        file:///C:/Temp/xxx/tst.xsl; Line #24; Column #91; XSLT Error
        (javax.xml.transform.TransformerException): java.lang.NullPointerException

        All jars are taken from binary file distribution of Xalan 2.5.D1.

        Java:
        java version "1.3.1_03"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_03-b03)
        Java HotSpot(TM) Client VM (build 1.3.1_03-b03, mixed mode)

        Show
        Luboš Hartman added a comment - Try to transform the XML file in attachment using XSL file in attachment. I tried: java -cp xml-apis.jar;xercesImpl.jar;xalan.jar org.apache.xalan.xslt.Process - IN tst.xml -XSL tst.xsl and the output is: <?xml version="1.0" encoding="UTF-8"?> file:///C:/Temp/xxx/tst.xsl ; Line #24; Column #91; XSLT Error (javax.xml.transform.TransformerException): java.lang.NullPointerException All jars are taken from binary file distribution of Xalan 2.5.D1. Java: java version "1.3.1_03" Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_03-b03) Java HotSpot(TM) Client VM (build 1.3.1_03-b03, mixed mode)
        Hide
        Christine Li added a comment -

        The error is in your XSL file. Based on the XML file, there are more than one
        values returned by select="key('bt-data', key('uc-
        attribute', 'list1.0.A002')/@data)". In the xsl file, you should use:

        <xsl:for-each select="key('bt-data', key('uctribute', 'list1.0.A002')/@data)">
        <xsl:value-of select="."/>
        </xsl:for-each>

        Show
        Christine Li added a comment - The error is in your XSL file. Based on the XML file, there are more than one values returned by select="key('bt-data', key('uc- attribute', 'list1.0.A002')/@data)". In the xsl file, you should use: <xsl:for-each select="key('bt-data', key('uctribute', 'list1.0.A002')/@data)"> <xsl:value-of select="."/> </xsl:for-each>
        Hide
        Luboš Hartman added a comment -

        Ok. Thank you.

        Show
        Luboš Hartman added a comment - Ok. Thank you.
        Hide
        Christine Li added a comment -

        More investigation should be done for nested Key() function

        Show
        Christine Li added a comment - More investigation should be done for nested Key() function
        Hide
        david_marston added a comment -

        Test idkey21 already exists to cover nested key() functions in general.
        When investigating this situation, look for potential expansions of the
        test suite.

        Show
        david_marston added a comment - Test idkey21 already exists to cover nested key() functions in general. When investigating this situation, look for potential expansions of the test suite.
        Hide
        Christine Li added a comment -

        Created an attachment (id=5426)
        Test for nested key() with xsl:value-of element

        Show
        Christine Li added a comment - Created an attachment (id=5426) Test for nested key() with xsl:value-of element
        Hide
        Christine Li added a comment -

        Created an attachment (id=5427)
        Test for nested key() with xsl:value-of element - XSL File

        Show
        Christine Li added a comment - Created an attachment (id=5427) Test for nested key() with xsl:value-of element - XSL File
        Hide
        Christine Li added a comment -

        Created an attachment (id=5428)
        Test for key() with nested id() in xsl:value-of element - XML

        Show
        Christine Li added a comment - Created an attachment (id=5428) Test for key() with nested id() in xsl:value-of element - XML
        Hide
        Christine Li added a comment -

        Created an attachment (id=5429)
        Test for key() with nested id() in xsl:value-of element - XSL

        Show
        Christine Li added a comment - Created an attachment (id=5429) Test for key() with nested id() in xsl:value-of element - XSL
        Hide
        Christine Li added a comment -

        Created an attachment (id=5430)
        Test for id() with nested key() in xsl:value-of element - XML

        Show
        Christine Li added a comment - Created an attachment (id=5430) Test for id() with nested key() in xsl:value-of element - XML
        Hide
        Christine Li added a comment -

        Created an attachment (id=5431)
        Test for id() with nested key() in xsl:value-of element - XSL

        Show
        Christine Li added a comment - Created an attachment (id=5431) Test for id() with nested key() in xsl:value-of element - XSL
        Hide
        Christine Li added a comment -

        Created an attachment (id=5432)
        Test for id(node-set) with nested key() in xsl:value-of element - XML

        Show
        Christine Li added a comment - Created an attachment (id=5432) Test for id(node-set) with nested key() in xsl:value-of element - XML
        Hide
        Christine Li added a comment -

        Created an attachment (id=5433)
        Test for id(node-set) with nested key() in xsl:value-of element - XSL

        Show
        Christine Li added a comment - Created an attachment (id=5433) Test for id(node-set) with nested key() in xsl:value-of element - XSL
        Hide
        Christine Li added a comment -

        Created an attachment (id=5434)
        Test for id(node-set) with nested key() in xsl:for-each element - XML

        Show
        Christine Li added a comment - Created an attachment (id=5434) Test for id(node-set) with nested key() in xsl:for-each element - XML
        Hide
        Christine Li added a comment -

        Created an attachment (id=5435)
        Test for id(node-set) with nested key() in xsl:for-each element - XSL

        Show
        Christine Li added a comment - Created an attachment (id=5435) Test for id(node-set) with nested key() in xsl:for-each element - XSL
        Hide
        Christine Li added a comment -

        Created an attachment (id=5485)
        Expected output files for new test cases

        Show
        Christine Li added a comment - Created an attachment (id=5485) Expected output files for new test cases
        Hide
        Christine Li added a comment -

        Created an attachment (id=5486)
        Patch for ID() and Key() functions

        Show
        Christine Li added a comment - Created an attachment (id=5486) Patch for ID() and Key() functions
        Hide
        Christine Li added a comment -

        When nested id() or key() functions are used in select attribute of xsl:value-
        of element, if the result is a node-set. The node-set is converted to a string
        by returning the string-value of the node in the node-set that is first in
        document order.

        Show
        Christine Li added a comment - When nested id() or key() functions are used in select attribute of xsl:value- of element, if the result is a node-set. The node-set is converted to a string by returning the string-value of the node in the node-set that is first in document order.
        Hide
        Christine Li added a comment -

        Created an attachment (id=6164)
        A more general patch

        Show
        Christine Li added a comment - Created an attachment (id=6164) A more general patch
        Hide
        Christine Li added a comment -

        the Patch submitted on 03/24/03 doesn't fix all problems related to key()
        function. When key() is used as an argument and it returns a node-set with more
        than one node, the same problem happens for number(), sum(), string(), id() and
        key() functions. It is caused of when key() returns a node-set with more than
        one node, a XNodeSet object was created using XNodeSet(DTMIterator)
        constructor. The argument is UnionPathIterator in this case and the m_dtmMgr
        field of the XNodeSet is null. The following codes are asking for this
        XNodeSet's DTMManager, which returns null and a NullPointerException is thrown.
        The fix is to set m_dtmMgr with the value in UnionPathIterator or get
        DTMManager from XPathContext.

        Show
        Christine Li added a comment - the Patch submitted on 03/24/03 doesn't fix all problems related to key() function. When key() is used as an argument and it returns a node-set with more than one node, the same problem happens for number(), sum(), string(), id() and key() functions. It is caused of when key() returns a node-set with more than one node, a XNodeSet object was created using XNodeSet(DTMIterator) constructor. The argument is UnionPathIterator in this case and the m_dtmMgr field of the XNodeSet is null. The following codes are asking for this XNodeSet's DTMManager, which returns null and a NullPointerException is thrown. The fix is to set m_dtmMgr with the value in UnionPathIterator or get DTMManager from XPathContext.
        Hide
        Christine Li added a comment -

        Created an attachment (id=7018)
        A reasonable fix for this bug

        Show
        Christine Li added a comment - Created an attachment (id=7018) A reasonable fix for this bug
        Hide
        Christine Li added a comment -

        Please ignore the previous patch. The latest patch on 06/27/03 is a more
        reasonalbe fix. I would appreciate if any commiter with good knowledge of DTM
        to review the patch.

        Show
        Christine Li added a comment - Please ignore the previous patch. The latest patch on 06/27/03 is a more reasonalbe fix. I would appreciate if any commiter with good knowledge of DTM to review the patch.
        Hide
        Joe Kesselman added a comment -

        DTM philosophical review:

        The real problem here seems to be that "ni" and "nodes" aren't bound to the
        right evaluation context (specifically, they can't obtain the correct DTM
        Manager) and thus aren't able to use the DTM Node Handle ("pos") to look up the
        DTM object which contains that node. You're solving that by bypassing these node
        iterators, which sorta works as a patch... but my question is why the iterator
        wasn't configured properly in the first place. If this operation is supposed to
        work and doesn't, that's a problem waiting to bite our ankles later on.

        So I'd lean toward fixing the node-iterator objects rather than working around them.

        Having said that, if you're forced to do a work-around, asking the XPath Context
        for its DTM Manager is at least semantically reasonable...

        Show
        Joe Kesselman added a comment - DTM philosophical review: The real problem here seems to be that "ni" and "nodes" aren't bound to the right evaluation context (specifically, they can't obtain the correct DTM Manager) and thus aren't able to use the DTM Node Handle ("pos") to look up the DTM object which contains that node. You're solving that by bypassing these node iterators, which sorta works as a patch... but my question is why the iterator wasn't configured properly in the first place. If this operation is supposed to work and doesn't, that's a problem waiting to bite our ankles later on. So I'd lean toward fixing the node-iterator objects rather than working around them. Having said that, if you're forced to do a work-around, asking the XPath Context for its DTM Manager is at least semantically reasonable...
        Hide
        Christine Li added a comment -

        This bug has been reported long time ago. In the latest CVS, the configurations of those iterators have been fixed during some other bug fixes. The only place remaining incorrect is the construction of a new XNodeSet. After a construction of a new XNodeSet by passing an iterator, it should always call setRoot() method to set the correct DTM Manager. The attached cases idkey64 and idkey68 still don't work correctly. A new patch will be submitted.

        Show
        Christine Li added a comment - This bug has been reported long time ago. In the latest CVS, the configurations of those iterators have been fixed during some other bug fixes. The only place remaining incorrect is the construction of a new XNodeSet. After a construction of a new XNodeSet by passing an iterator, it should always call setRoot() method to set the correct DTM Manager. The attached cases idkey64 and idkey68 still don't work correctly. A new patch will be submitted.

          People

          • Assignee:
            Christine Li
            Reporter:
            Luboš Hartman
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Development