This isn't a known bug and there's nothing obviously wrong with the code here; it seems the DOM implementation is (rightly or wrongly) returning some result that Saxon isn't expecting (on the surface, it looks as if NodeList.item(x) is returning null when x is within the range of values for the NodeList.)
 
It's not going to be possible to get to the bottom of this without reproducing it in a debugger, I fear - which could be a bit tricky because of the complexity (and for me, unfamiliarity) of the environment. If you can possibly find a way to reproduce it in as simple an environment as possible, I would be very grateful.
 
On useful thing would be to know what is the implementation class of the DOM node that Saxon is accessing. Many problems with DOM access arise because of minor differences between one DOM implementation and another.
 

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay



From: David.Gagnon@worldcolor.com [mailto:David.Gagnon@worldcolor.com]
Sent: 29 March 2010 16:04
To: saxon-help@lists.sourceforge.net
Subject: [saxon] NullPointerException in Saxon 9.2...


Hi All,

  I using xmlbeans 2.5.0 with saxon 9.2 to do XPATH query like:

XmlObject[] elementAr = vpioDocument.getVpio().getPromotion().getBaseLayout().selectPath(PromoDocumentRepository.VP_NAMESPACE + "$this/vp:page/vp:block[@id='" + blockId + "']/vp:regionBlock[not(@regionId) or @regionId = '" + regionId + "']");

that gives the following string:
-declare namespace vp='http://vocio.qmi.com/vp/xml' $this/vp:page/vp:block[@id='2']/vp:regionBlock[not(@regionId) or @regionId = '1']


I got the following NullPointerException is the exception:

ERROR ExceptionHandlingServiceAbstractImpl - Exception logged: null
java.lang.NullPointerException
        at net.sf.saxon.dom.NodeWrapper$ChildEnumeration.skipFollowingTextNodes(NodeWrapper.java:1161)
        at net.sf.saxon.dom.NodeWrapper$ChildEnumeration.next(NodeWrapper.java:1188)
        at net.sf.saxon.om.Navigator$AxisFilter.next(Navigator.java:867)
        at net.sf.saxon.expr.ContextMappingIterator.next(ContextMappingIterator.java:54)
        at net.sf.saxon.expr.FilterIterator.getNextMatchingItem(FilterIterator.java:61)
        at net.sf.saxon.expr.FilterIterator.next(FilterIterator.java:44)
        at net.sf.saxon.expr.ContextMappingIterator.next(ContextMappingIterator.java:51)
        at net.sf.saxon.expr.FilterIterator.getNextMatchingItem(FilterIterator.java:61)
        at net.sf.saxon.expr.FilterIterator.next(FilterIterator.java:44)
        at net.sf.saxon.value.SequenceExtent.<init>(SequenceExtent.java:98)
        at net.sf.saxon.sort.DocumentOrderIterator.<init>(DocumentOrderIterator.java:30)
        at net.sf.saxon.sort.DocumentSorter.iterate(DocumentSorter.java:85)
        at net.sf.saxon.sxpath.XPathExpression.evaluate(XPathExpression.java:128)
        at org.apache.xmlbeans.impl.xpath.saxon.XBeansXPath.selectNodes(XBeansXPath.java:119)
        at org.apache.xmlbeans.impl.xpath.saxon.XBeansXPath.selectPath(XBeansXPath.java:148)
        at org.apache.xmlbeans.impl.store.Path$DelegatePathImpl$DelegatePathEngine.next(Path.java:544)
        at org.apache.xmlbeans.impl.store.Cursor._toSelection(Cursor.java:931)
        at org.apache.xmlbeans.impl.store.Cursor._toNextSelection(Cursor.java:920)
        at org.apache.xmlbeans.impl.store.Cursor._hasNextSelection(Cursor.java:912)
        at org.apache.xmlbeans.impl.store.Cursor.hasNextSelection(Cursor.java:2652)
        at org.apache.xmlbeans.impl.values.XmlObjectBase.selectPath(XmlObjectBase.java:467)
        at org.apache.xmlbeans.impl.values.XmlObjectBase.selectPath(XmlObjectBase.java:449)
        at com.qwi.coficio.vp.repository.PageRepositoryImpl.getRegionBlocksForRegion(PageRepositoryImpl.java:153)
        at com.qwi.coficio.vp.service.PageServiceImpl.getRegionBlocksForRegion(PageServiceImpl.java:500)
        at com.qwi.coficio.vp.service.PageServiceImpl.computePageCategoryList(PageServiceImpl.java:722)
        at com.qwi.coficio.vp.service.PageServiceImpl.moveBlocksFromCategory(PageServiceImpl.java:316)
        at com.qwi.coficio.vp.facade.ModifyingPromotionLayoutFacadeImpl.assignAvailableCategory(ModifyingPromotionLayoutFacadeImpl.java:487)
        at com.qwi.coficio.vp.engine.components.ComponentsEngine.assignBlockFromCategoryInternal(ComponentsEngine.java:758)
        at com.qwi.coficio.vp.engine.components.PageCategoryListModificationCommand.redoIt(PageCategoryListModificationCommand.java:50)
        at com.qwi.coficio.engine.AbstractBaseCommand.doIt(AbstractBaseCommand.java:79)
        at com.qwi.coficio.engine.AbstractCommand.doIt(AbstractCommand.java:53)
        at com.qwi.coficio.vp.engine.components.ComponentsEngine.assignBlockFromCategory(ComponentsEngine.java:726)
        at com.qwi.coficio.vp.view.editor.PromotionPlanEditor$PromoPlanTransferHandler.processDropForCategory(PromotionPlanEditor.java:1319)
        at com.qwi.coficio.vp.view.editor.PromotionPlanEditor$PromoPlanTransferHandler.importData(PromotionPlanEditor.java:1186)
        at javax.swing.TransferHandler$DropHandler.drop(TransferHandler.java:1468)
        at java.awt.dnd.DropTarget.drop(DropTarget.java:434)
        at javax.swing.TransferHandler$SwingDropTarget.drop(TransferHandler.java:1193)
        at sun.awt.dnd.SunDropTargetContextPeer.processDropMessage(SunDropTargetContextPeer.java:500)
        at sun.awt.dnd.SunDropTargetContextPeer$EventDispatcher.dispatchDropEvent(SunDropTargetContextPeer.java:812)
        at sun.awt.dnd.SunDropTargetContextPeer$EventDispatcher.dispatchEvent(SunDropTargetContextPeer.java:736)
        at sun.awt.dnd.SunDropTargetEvent.dispatch(SunDropTargetEvent.java:30)
        at java.awt.Component.dispatchEventImpl(Component.java:4358)
        at java.awt.Container.dispatchEventImpl(Container.java:2081)
        at java.awt.Component.dispatchEvent(Component.java:4331)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4301)
        at java.awt.LightweightDispatcher.processDropTargetEvent(Container.java:4036)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3890)
        at java.awt.Container.dispatchEventImpl(Container.java:2067)
        at java.awt.Window.dispatchEventImpl(Window.java:2458)
        at java.awt.Component.dispatchEvent(Component.java:4331)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Any Idea what wrong ?

Thanks for your help!

I got the same exception with 9.0...

Regard
David