Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Transformation of DOM

0 views
Skip to first unread message

Hans Lund

unread,
Nov 20, 2003, 10:42:44 AM11/20/03
to
I have a server app, which delivers data in a predefined xml format. The
data are build in a Dom document, which I serialize to a socketStream
using the org.apache.xml.serialize.XMLSerializer - no problems.

Now I want to extend to model, by allowing the client to specify a XSTL
, and transform the document server side. This should be a simple
extension - and I have made the following method.


---
private void output(Document reply, OutputStream socketStream, String
transformUrl) throws IOException,
javax.xml.transform.TransformerException,
javax.xml.transform.TransformerConfigurationException{
TransformerFactory tFactory = TransformerFactory.newInstance();
Source so = new DOMSource(reply);
Transformer transformer;
StreamResult re = new
javax.xml.transform.stream.StreamResult(socketStream);
if (transformUrl != null){
transformer = tFactory.newTransformer(new
javax.xml.transform.stream.StreamSource(new
URL(transformUrl).openStream()));
} else {
transformer = tFactory.newTransformer();
}

transformer.setOutputProperty(javax.xml.transform.OutputKeys.ENCODING,("UTF-8"));
transformer.transform(so,re);
}
----

But the problem is that the transformer.transform call throws a
NullPointerException - somewhere in the transformation (some output are
written to the result stream)

Here's a dump of the stack trace.

java.lang.NullPointerException
at org.apache.xml.utils.TreeWalker.dispatachChars(TreeWalker.java:259)
at org.apache.xml.utils.TreeWalker.startNode(TreeWalker.java:403)
at org.apache.xml.utils.TreeWalker.traverse(TreeWalker.java:167)
at
org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:325)
....


To me it looks like a bug in TreeWaker , but has anyone had the same
problem - and have a solution???

Hans Lund

unread,
Nov 21, 2003, 4:15:03 AM11/21/03
to
> To me it looks like a bug in TreeWaker , but has anyone had the same
> problem - and have a solution???

was a bug - xalan could'nt handle a DOMSource ( serializing the dom
first made it work ) though the easiest solution was updating the
xalan.... :-)


0 new messages