Saxon's DocumentBuilder.build throws a NullPointer when passing a stream source

Please support our XML, XSLT and XPATH advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Nov 2008
Posts: 3
Reputation: michux is an unknown quantity at this point 
Solved Threads: 0
michux michux is offline Offline
Newbie Poster

Saxon's DocumentBuilder.build throws a NullPointer when passing a stream source

 
0
  #1
Nov 14th, 2008
In thread http://www.daniweb.com/forums/thread157149.html I was asking for different alternatives for passing a node as a parameter to an XSL stylesheet called from Java using saxon.

I set up on using the XdmNode object as a parameter for passing the parameter and here is a code extract:

  1.  
  2. // create a XSLT transformer
  3. XsltTransformer trans = comp.compile(new StreamSource(MyClass.getResourceAsStream(XSLT_FILE))).load();
  4.  
  5. // [...]
  6.  
  7. // sample XML to pass as parameter
  8. String str = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n" +
  9. "<opsys:operatingSystems xmlns:opsys=\"http://osnews.pl/operating-systems\">\n" +
  10. " <opsys:operatingSystem id=\"1\">\n" +
  11. " <opsys:name>GNU/Linux</opsys:name>\n" +
  12. " <opsys:code>GNU</opsys:code>\n" +
  13. " </opsys:operatingSystem>\n" +
  14. " <opsys:operatingSystem id=\"2\">\n" +
  15. " <opsys:name>Microsoft</opsys:name>\n" +
  16. " <opsys:code>MSFT</opsys:code>\n" +
  17. " </opsys:operatingSystem>\n" +
  18. "</opsys:operatingSystems>";
  19.  
  20. ByteArrayInputStream byteStream = new ByteArrayInputStream(str.getBytes());
  21. StringReader reader = new StringReader(str);
  22.  
  23. SAXSource source = new SAXSource(new XMLFilterImpl(), new InputSource(reader));
  24.  
  25. // this throws a null pointer exception in build method
  26. XdmNode node = db.build(source);
  27.  
  28. // this works as intended
  29. // XdmNode node = db.build(
  30. // new File("test.xml"));
  31.  
  32. trans.setParameter(new QName("operatingSystems"), node);

Now as you can see in the above example, when I use a file as an input, the node is created fine and I can access the node with custom XML from the operatingSystems parameter in my XSLT (cool).
For some reason, when using a Source as an input for DocumentBuilder's build method, a NullPointerException is called.
The docs for DocumentBuilder: http://www.saxonica.com/documentatio...ansform.Source) claim that I should be using either SAXSource or JAXP source or DOMSource or PullSource. I tried a few but they all cause this exception to be thrown.

Any ideas before I start debugging saxon libraries?
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 3
Reputation: michux is an unknown quantity at this point 
Solved Threads: 0
michux michux is offline Offline
Newbie Poster

Re: Saxon's DocumentBuilder.build throws a NullPointer when passing a stream source

 
0
  #2
Nov 17th, 2008
OK, it was indeed a bug in saxon, I guess, solved in the latest release of Saxon: 9.1.0.3
Sorry for bugging anyone.
Borys
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the XML, XSLT and XPATH Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC