>Xerces still provide an XML Serializer, two actually

they all do, it is part of the standard Java XML API
see below, this way you don't have to import any outside libraries of the JDK

Filip

public static void writeXmlToFile(java.io.File f, Document d) {
            Transformer transformer =
                TransformerFactory.newInstance().newTransformer();
            java.io.FileOutputStream out = new java.io.FileOutputStream(f);
            StreamResult result = new StreamResult(out);
            DOMSource source = new DOMSource(d);
            transformer.setOutputProperty(OutputKeys.INDENT,"yes");
            //depending on which library you have
            
transformer.setOutputProperty("{http://xml.apache.org/xalan%7dindent-amount","4";);
            
transformer.setOutputProperty("{http://xml.apache.org/xslt%7dindent-amount","4";);
            transformer.setOutputProperty(OutputKeys.METHOD,"xml");
            transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,"yes");
            transformer.transform(source, result);


----- Original Message -----
From: "Remy Maucherat" <[EMAIL PROTECTED]>
To: "Tomcat Developers List" <[EMAIL PROTECTED]>
Sent: Friday, July 30, 2004 11:57 AM
Subject: Re: [5.next] Refactoring save-to-XML


Shapira, Yoav wrote:

>Hi,
>I think a gradual transition might be OK.  Server.xml, as Remy said, nicely conveys 
>the structure of the server's configuration.
That's possible to replicate in a JMX- or JBoss-style configuration file, but it tends 
to look uglier and more verbose IMHO.
However, your desired a good long-term goal also, I think.
>
>So for now I like the DOM + PropertyChangeEvent model that Remy has proposed.  
>Especially combined with the increased use of
setAllProperties, the configuration will be both less verbose and easier to 
save/restore.
>
>Xerces still provide an XML Serializer, two actually.  One is what I think we should 
>use, the DOM Level 3 Standard (meaning there's
a shot this thing is portable ;)): 
http://xml.apache.org/xerces2-j/javadocs/api/org/w3c/dom/ls/LSSerializer.html, 
specified in
http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407/.  But as you see these things 
are fairly new, and as such might be buggy:
http://xml.apache.org/xerces2-j/dom3.html.  There's also at least one unimplemented 
method of the LSSerializer
(normalize-characters) but we might not need that one.
>
>
This is a big plus in favor of DOM 3. +1 for using it.

I see this stuff is available bundled on JDK 1.5 (like JMX and JMX
remote), so if we choose to use this, I think I'll advocate having the
default download for JDK 1.5, and a download for JDK 1.4 compatibility.

Rémy


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to