cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsex...@odshp.com
Subject DOM Output?
Date Tue, 16 Oct 2001 22:36:17 GMT

I'm using Tomcat and Cocoon together, and I have the xerces jar file
in tomcat/lib.  The following fragment works great in a servlet...

public void output() {
  try {
    DOMImplementation imp = new DOMImplementationImpl();
    Document doc = imp.createDocument(null, "page", null);

    Element root = doc.getDocumentElement();
    Element title = doc.createElement("title");
    root.appendChild(title);
  }
  catch(Exception e) {
    out.print(e.toString());
  }
}


Once my document is build, how do I output formatted XML?  For the
life of me I can't find an example of building and XML doc with xerces
and outputting the formated XML.

One example I found uses this:

XmlDocument doc = new XmlDocument();
.... Build doc....
doc.write(out);

where "out" is a OutputStreamWriter.  This would be great!  Except
that I get a class def not found for XmlDocument (I guess it's in
tomcat's xml.jar?)

I'm doing all this so that cocoon can receive XML from a servlet and
format it.  And I'm doing that because JConnect (Sybase JDBC) doesn't
want to work from a Cocoon XML page (although it works fine in my
servlets).

Everything else works.  If I simply print out the XML "by hand" in the
servlet, Cocoon applies my style sheet perfectly!  All I need to know
is how to output the XML.

PS - the XmlDocument method works fine in my Visual Age environment
where I have Tomcat source loaded and running.  I thought I had my
solution until I found that that class can't be found in the
production install.

--
Jeff Sexton
ODS Health Plans
jsexton@odshp.com

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message