[
Lists Home |
Date Index |
Thread Index
]
- To: Chris Burdess <dog@bluezoo.org>
- Subject: Re: [xml-dev] Transmitting XML between different applications
- From: Mukul Gandhi <mukul_gandhi@yahoo.com>
- Date: Mon, 21 Feb 2005 03:21:41 -0800 (PST)
- Cc: XML Developers List <xml-dev@lists.xml.org>
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=Qs8CNwKMrbgDKIDGKTaEpWTW2ThrMNjDZSmTvj1ITLKo3FDfyZw68/dX8ymeEBQ2Z3KW0gc2sAAv22XWgERFFEBRiPeSyyks9WElsKe+MFTr0VvOcImkdvNV1sr5Bvri1Cd0ba5eYEWhcxNJIpXhBLLkba5kIC3xBzlgqnug1v4= ;
- In-reply-to: <733b3863ad143b9d1eb67409061a5a41@bluezoo.org>
Thanks a lot for valuable information!
Regards,
Mukul
--- Chris Burdess <dog@bluezoo.org> 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
|