Next in thread → Next in month →

Re: [xml-dev] Transmitting XML between different applications

From
Mukul Gandhi <>
To
Chris Burdess <>
Date
2005-02-21T11:21:41Z
ID
<>
Thread
Re: [xml-dev] Transmitting XML between different applications
Thanks a lot for valuable information!

Regards,
Mukul

--- Chris Burdess <> wrote:

> Mukul Gandhi wrote:
> > I want to understand the below statement, you have
> > written.. "not if you serialize it using the
> default
> > Java object serialization". Is it possible to
> > serialize Java DOM objects by some other methods
> than
> > default Java serialization method? How is it
> > implemented, and would it make Java DOM objects
> parser
> > neutral?
> 
> Mukul,
> 
> There are two standard ways to serialise a Java DOM
> Document.
> 
> 1. Use the DOM Load & Save facility if your DOM
> implementation supports 
> it, as this is likely to be more efficient:
> 
>       http://www.w3.org/TR/DOM-Level-3-LS/
> 
> Check whether the implementation supports it as
> follows:
> 
>    Document doc = ...;
>    DOMImplementation impl = doc.getImplementation();
>    if (impl.hasFeature("LS", "3.0")) {
>      DOMImplementationLS ls = (DOMImplementation)
> impl.getFeature("LS", 
> "3.0");
>      LSSerializer serializer =
> ls.createLSSerializer();
>      LSOutput output = ls.createLSOutput();
>      // configure output ...
>      serializer.write(doc, output);
>    }
> 
> GNU JAXP and Apache Xerces support DOM Load & Save.
> 
> 2. Use a JAXP identity transformer to serialise to a
> StreamResult.
> 
>    Document doc = ...;
>    Transformer identityTransformer = 
> TransformerFactory.getInstance().newTransformer();
>    DOMSource source = new DOMSource(doc);
>    StreamResult result = new StreamResult(...);
>    identityTransformer.transform(source, result);
> 
> Both these methods serialise to an OutputStream. The
> resulting stream 
> of characters is an XML document. It is as "parser
> neutral" as any XML 
> document - any XML parser parses XML. A DOM Document
> is not an XML 
> document, and is not XML. It is an
> application-internal representation 
> of an XML document in memory. The XML document is
> the sequence of bytes 
> beginning e.g. '<', '?', 'x', 'm', 'l', etc. Use XML
> as the transfer 
> format between different applications.
> -- 
> Chris Burdess



		
__________________________________ 
Do you Yahoo!? 
Take Yahoo! Mail with you! Get it on your mobile phone. 
http://mobile.yahoo.com/maildemo
Next in thread → Next in month →