![]() |
Can't write XML to stream outside of NetBeans
I've been having a lot of trouble trying to create an XML file from a
DOM tree. My code works fine inside of netbeans, but I get lots of erros when I try to run it independantly. The error message I keep getting is [java] java.lang.RuntimeException: org.apache.xml.utils.WrappedRuntimeException: The output format must have a '{http://xml.apache.org/xalan}content-handler' property! Both Xerces and crimson are in my classpath, and I've tried using both Java 1.5 and 1.4.2. Any ideas what I'm doing wrong? This is the code I'm trying to write the file with: public void writeXML(Document doc, OutputStream ostream) { try { //Format & write output TransformerFactory tf = TransformerFactory.newInstance(); Transformer t = tf.newTransformer(); DOMSource ds = new DOMSource(doc); StreamResult sr = new StreamResult(ostream); t.transform(ds, sr); } catch (Exception e) { e.printStackTrace(); } } Mark McKay |
Re: Can't write XML to stream outside of NetBeans
<mark@kitfox.com> wrote in message news:1103303933.302424.169510@z14g2000cwz.googlegr oups.com... > I've been having a lot of trouble trying to create an XML file from a > DOM tree. My code works fine inside of netbeans, but I get lots of > erros when I try to run it independantly. > > The error message I keep getting is > > [java] java.lang.RuntimeException: > org.apache.xml.utils.WrappedRuntimeException: The output format must > have a '{http://xml.apache.org/xalan}content-handler' property! > > Both Xerces and crimson are in my classpath, and I've tried using both > Java 1.5 and 1.4.2. Any ideas what I'm doing wrong? > > This is the code I'm trying to write the file with: > > public void writeXML(Document doc, OutputStream ostream) > { > try > { > //Format & write output > TransformerFactory tf = TransformerFactory.newInstance(); > Transformer t = tf.newTransformer(); > > DOMSource ds = new DOMSource(doc); > StreamResult sr = new StreamResult(ostream); > t.transform(ds, sr); > } > catch (Exception e) > { > e.printStackTrace(); > } > } > > Mark McKay > I do the same and it works fine, in NetBeans and outside. do you have those imports(maybe you don't need all of them, but those are what i needed)? import java.io.*; import javax.xml.parsers.*; import javax.xml.transform.*; import javax.xml.transform.dom.*; import javax.xml.transform.stream.*; import org.w3c.dom.*; import org.xml.sax.*; |
| All times are GMT. The time now is 07:49 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.