Simon Kitching <[EMAIL PROTECTED]> wrote on 03/30/2004 07:23:40 PM:

> On Wed, 2004-03-31 at 01:10, Michael Glavassevich wrote:
> > On Tue, 30 Mar 2004, Simon Kitching wrote:
> >
> > > Hi,
> > >
> > > I see the org.apache.xml.serialize.HTMLSerializer class is deprecated in
> > > release 2.6.2.
> > >
> > > Can anyone tell me what the recommended replacement is?
> >
> > We recommend you use JAXP for HTML serialization [1] instead of using
> > HTMLSerializer.
> >
> > > [NB: Perhaps it would be nice to add this info to class description
> > > javadoc when the class is deprecated?].
> >
> > Before the last release it was decided that Xerces will be moving towards
> > a common serialization codebase with Xalan [2]. Deprecating HTMLSerializer
> > and XHTMLSerializer was the first step in that direction. Over time the
> > HTML serializer code in Xerces has become orphaned, while on the Xalan
> > side there have been bug fixes and performance improvements.
> >
> > > The current situation (2.6.2) appears to be:
> > >   HTMLSerialized: deprecated
> > >   XHTMLSerializer: deprecated
> > >   XMLSerializer:  NOT deprecated
> > >   TextSerializer: NOT deprecated
> > >   BaseMarkupSerializer: NOT deprecated
> >
> > The XMLSerializer will probably be deprecated in a future release. Once
> > DOM Level 3 Load and Save is finalized we'll have a standard serialization
> > mechanism. Users should be using org.w3c.dom.ls.LSSerializer to serialize
> > a DOM instead of using Xerces' serialization code directly.
>
> Thanks for your reply, Michael.
>
> So in order to serialize my dom object to HTML, I can either:
> (a) bundle the whole of Xalan with my app, or
> (b) require java1.4 (to get xslt serialization), or
> (c) use the DOM3 load/save API, which is not yet approved, or
> (d) use the deprecated HtmlSerializer?
>
> None of the above seems particularly appealing. I guess that (c) is
> meant to be the future solution to this issue, right?


(c) would be a standard solution for serializing a DOM into XML once DOM Level 3 Load and Save is finalized.

> Can anyone tell me how in DOM3 LS you specify that the output is to be
> HTML? I can't see any flag anywhere that controls that. There's nothing
> on the LSSerializer class, nor on the DOMConfiguration class that can
> set the output format as far as I can see..

LSSerializer is an XML serializer. It provides no method for serializing a DOM to HTML. The only standard way I'm aware of for serializing HTML is to use JAXP.

> And is there an equivalent to the existing "indentation-level" setting,
> where the depth of pretty-printing indentation can be set?

The only DOMConfiguration parameter for pretty printing defined in the spec is "format-pretty-print". Setting it to true (if supported) will cause LSSerializer to pretty print the document, though the spec doesn't specify exactly what this does.

> It also appears that the org.apache.xerces.dom3.DOMConfiguration must be
> accessed directly at the moment in order to use DOM3 LS, as follows. All
> the other necessary classes are present in the org.w3c.dom namespace,
> but not that class. I presume that when DOM3 core becomes "approved",
> this will be fixed but until now all DOM3 LS users must directly depend
> on org.apache.xerces.dom3.DOMConfiguration? Note that I'm not terribly
> worried by this (I was using org.apache.xml.serialize.HtmlSerializer
> after all :-), just would appreciate confirmation that I'm not missing
> something obvious.

Someone asked about the org.apache.xerces.dom3 [1] package just yesterday. It is a hack that allows DOM Level 2 Core (which we distribute in the standard distribution) to coexist with DOM Level 3 Core. You will find org.w3c.dom.DOMConfiguration in the DOM Level 3 Core API which we currently include in the DOM Level 3 beta distribution (beta2-dom3-Xerces-J-bin.2.6.2.zip) [2].

[1] http://marc.theaimsgroup.com/?l=xerces-j-user&m=108056734231057&w=2
[2] http://www.apache.org/dist/xml/xerces-j/
 
> Here's my current (partial) solution:
>    // example of serializing via DOM3 LS
>    ByteArrayOutputStream baos = new ByteArrayOutputStream();
>
>         DOMImplementation domImpl = doc.getImplementation();
>         DOMImplementationLS factory = (DOMImplementationLS) domImpl;
>        
>         LSOutput output = factory.createLSOutput();
>         output.setByteStream(baos);
>        
>         LSSerializer serializer = factory.createLSSerializer();
>         DOMConfiguration config = serializer.getDomConfig();
>         config.setParameter("format-pretty-print", Boolean.TRUE);
>         // set indentation depth???
>    // somehow set output to HTML format???
>        
>         serializer.write(doc, output);
>
> Thanks for the information.
>
> Regards,
>
> Simon
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]

E-mail: [EMAIL PROTECTED]

Reply via email to