Project

Profile

Help

Bug #2102

closed

Saxon should support an empty DOMSource(). As-is, NPE in net.sf.saxon.dom.DOMObjectModel.unravel.

Added by Mark Ziesemer almost 10 years ago. Updated almost 10 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
JAXP Java API
Sprint/Milestone:
-
Start date:
2014-07-09
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

Description

Nearly identical to http://saxon-xslt-and-xquery-processor.13853.n7.nabble.com/empty-DOMSource-td3046.html :

When we create an empty DOMSource with new DOMSource() and use it as the input of transform(), we get:

java.lang.NullPointerException
	at net.sf.saxon.dom.DOMObjectModel.unravel(DOMObjectModel.java:297)
	at net.sf.saxon.Configuration.unravel(Configuration.java:3077)
	at net.sf.saxon.Controller.prepareInputTree(Controller.java:1955)
	at net.sf.saxon.Controller.transform(Controller.java:1846)

The Javadoc for the empty DOMSource constructor says:

If this constructor is used, and no DOM source is set, then the Transformer will create an empty source Document using DocumentBuilder.newDocument().

As-is, this code throws the exception:

transformer.transform(new DOMSource(), new StreamResult(System.out));

This can be used as a work-around:

transformer.transform(new DOMSource(DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument()), new StreamResult(System.out));

IBM previously fixed a similar issue in WebSphere 2008 (http://blogger.ziesemer.com/2008/11/ibm-pk70653-websphere-xslt-empty-dom.html) - and am hoping this will be as easy as a fix here. :-) Christopher Sahnwaldt already provided a patch for review in the above mailing list archive link.

Thanks!

Please register to edit this issue

Also available in: Atom PDF