Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Can't write XML to stream outside of NetBeans

Reply
Thread Tools

Can't write XML to stream outside of NetBeans

 
 
mark@kitfox.com
Guest
Posts: n/a
 
      12-17-2004
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

 
Reply With Quote
 
 
 
 
hilz
Guest
Posts: n/a
 
      12-17-2004

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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.*;


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
help with pix inside->outside + dmz->outside + inside->outside->dmz Jack Cisco 0 09-19-2007 01:57 AM
Eclipse vs. Netbeans. Netbeans is winning me over almost at first glance. Thomas G. Marshall Java 2 10-16-2006 02:54 AM
[NETBEANS] [EVALUATION] - E12 - The NetBeans Open Source Lie Ilias Lazaridis Java 0 12-12-2004 02:41 PM
Function not visible outside the NetBeans IDE Rick T. Java 1 11-30-2004 03:31 PM
Building a GUI using NetBeans platform (not Netbeans IDE !) Pimousse Java 2 04-21-2004 07:22 AM



Advertisments