Uploaded image for project: 'XalanJ2'
  1. XalanJ2
  2. XALANJ-1139

XPathAPI throws NPE If Any Extension Function Used

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.4
    • None
    • XPath
    • None
    • Operating System: All
      Platform: All
    • 11792

    Description

      XPathAPI constructs an XPathContext using the
      default ctor (i.e. not supplying an ExtensionProvider).

      Thus, when any attempt is made to call an
      extension function, a null ExtensionProvider pointer
      is retrieved and dereferenced resulting in NPE at FuncExtFunction.java:196.

      XPathContext is constructed in XPathAPI.java or
      CachedXPathAPI.java (e.g. xpathSupport = new XPathContext().

      XPath used: /ico/keywords/keyword[regexp:containsMatch('ll*', 'llal')]

      containsMatch is defined in the PatternMatcher class (no package).

      PatternMatcher source and instructions are available at:

      http://www-106.ibm.com/developerworks/library/x-callbk/?open&l=976,t=gr

      Tested using ApplyXPath sample.

      Test Document used was:

      <ico xmlns:regexp="xalan://PatternMatcher">
      <id>423234</id>
      <keywords>
      <keyword>Haus</keyword>
      <keyword>Baum</keyword>
      <keyword>Auto</keyword>
      <keyword>Boot</keyword>
      <keyword>Sonne</keyword>
      </keywords>
      <faws>
      <faw>Meier</faw>
      <faw>Muller</faw>
      <faw>Bremen</faw>
      <faw>Winter</faw>
      <faw>Boot</faw>
      <faw>PC</faw>
      </faws>
      <author>Heiner Meier</author>
      <words>502</words>
      <date>19082002</date>
      </ico>

      Stack trace wass:

      Exception in thread "main" java.lang.NullPointerException
      at org.apache.xpath.functions.FuncExtFunction.execute
      (FuncExtFunction.java:196)
      at org.apache.xpath.axes.PredicatedNodeTest.executePredicates
      (PredicatedNodeTest.java:326)
      at org.apache.xpath.axes.PredicatedNodeTest.acceptNode
      (PredicatedNodeTest.java:458)
      at org.apache.xpath.axes.AxesWalker.nextNode(AxesWalker.java:406)
      at org.apache.xpath.axes.WalkingIterator.nextNode
      (WalkingIterator.java:176)
      at org.apache.xpath.axes.NodeSequence.nextNode(NodeSequence.java:320)
      at org.apache.xml.dtm.ref.DTMNodeIterator.nextNode
      (DTMNodeIterator.java:195)
      at ApplyXPath.doMain(ApplyXPath.java:134)
      at ApplyXPath.main(ApplyXPath.java:183)

      Have seen similar results attempting to use EXSLT functions via XPathAPI.

      The implication, planned or not, is that XPathAPI and CachedXPathAPI
      currently do not support the use of extension functions.

      Attachments

        Activity

          People

            mkwan@ca.ibm.com Morris Kwan
            terry@amicas.com Terry Rosenbaum
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: