You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Simon Kitching <si...@ecnetwork.co.nz> on 2004/03/30 05:51:15 UTC

HTMLSerializer deprecated - what is the replacement?

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?

[NB: Perhaps it would be nice to add this info to class description
javadoc when the class is deprecated?].

The current situation (2.6.2) appears to be:
  HTMLSerialized: deprecated
  XHTMLSerializer: deprecated
  XMLSerializer:  NOT deprecated
  TextSerializer: NOT deprecated
  BaseMarkupSerializer: NOT deprecated

The class was deprecated by "mrglavas" on Feb 16, 2004, with the
comment:
<begin cvs comment>
Deprecating HTML/XHTML serializers. Also, fixing long standing Bug
#2248. Have had this fixed locally for almost a year, might as well
apply it.
<end cvs comment>

Thanks,

Simon


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: HTMLSerializer deprecated - what is the replacement?

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Simon Kitching <si...@ecnetwork.co.nz> wrote on 03/30/2004 11:53:06 PM:

> > On Wed, 2004-03-31 at 01:10, Michael Glavassevich wrote:
> > > On Tue, 30 Mar 2004, Simon Kitching wrote:
> > > 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.
> > 
> 
> [snip]
> 
> > 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.
> 
> By "JAXP", I presume you mean instantiating an "identity"
> javax.xml.transform.Transformer object, and executing its transform
> method with a StreamResult object as the target?

Yes, I meant using the identity transformer.
 
> If this is indeed the case, then could I please make an explicit request
> to undeprecate the org.apache.xml.serializer.HTMLSerializer class?

The deprecation of this class is meant to be a warning for new developers, 
so that they look for alternatives if they're able to use something else. 
Also, for those who care about interoperability it's an encouragement not 
to use this Xerces specific class. Undeprecating it will give people a 
false sense that we are still working on this code (fixing bugs, making 
performance fixes, adding new functionality). The plan is to share 
serialization code with Xalan; getting it into xml-commons where both 
projects can pick it up.

> I don't think I will be alone in being unhappy about being forced to
> distribute the whole of Xalan with my app, just in order to be able to
> serialize Document objects to HTML on pre-java-1.4 environments.

Potentially you could get this from xml-commons in the future, though we 
haven't hammered out the details.

> I would point out that over in jakarta-commons, we recently had a
> discussion on what JVMs we had to support, and the answer was that
> *lots* of people still need java1.2 support, with a reasonable number
> still stuck with 1.1. I have quite a few customers who are running
> java1.3 myself. Essentially deprecating a feature for which the only
> replacement is java1.4 or the whole Xalan lib seems a bit tough. And of
> course the jaxp transform package implementation in 1.4 (a rather buggy
> version of Xalan) wasn't that hot anyway.

You can still use HTMLSerializer. We just recommend you don't if you have 
a choice.

> What is the best way to raise this issue properly? I could raise a
> bugzilla entry, but am afraid it won't be noticed.
> 
> Regards,
> 
> Simon
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org


Re: HTMLSerializer deprecated - what is the replacement?

Posted by Simon Kitching <si...@ecnetwork.co.nz>.
> On Wed, 2004-03-31 at 01:10, Michael Glavassevich wrote:
> > On Tue, 30 Mar 2004, Simon Kitching wrote:
> > 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.
> 

[snip]

> 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.

By "JAXP", I presume you mean instantiating an "identity"
javax.xml.transform.Transformer object, and executing its transform
method with a StreamResult object as the target?

If this is indeed the case, then could I please make an explicit request
to undeprecate the org.apache.xml.serializer.HTMLSerializer class?

I don't think I will be alone in being unhappy about being forced to
distribute the whole of Xalan with my app, just in order to be able to
serialize Document objects to HTML on pre-java-1.4 environments.

I would point out that over in jakarta-commons, we recently had a
discussion on what JVMs we had to support, and the answer was that
*lots* of people still need java1.2 support, with a reasonable number
still stuck with 1.1. I have quite a few customers who are running
java1.3 myself. Essentially deprecating a feature for which the only
replacement is java1.4 or the whole Xalan lib seems a bit tough. And of
course the jaxp transform package implementation in 1.4 (a rather buggy
version of Xalan) wasn't that hot anyway.

What is the best way to raise this issue properly? I could raise a
bugzilla entry, but am afraid it won't be noticed.

Regards,

Simon


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: HTMLSerializer deprecated - what is the replacement?

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Simon Kitching <si...@ecnetwork.co.nz> 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: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Re: HTMLSerializer deprecated - what is the replacement?

Posted by Simon Kitching <si...@ecnetwork.co.nz>.
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?

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..

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

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.

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: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: HTMLSerializer deprecated - what is the replacement?

Posted by Michael Glavassevich <mr...@apache.org>.
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.

> The class was deprecated by "mrglavas" on Feb 16, 2004, with the
> comment:
> <begin cvs comment>
> Deprecating HTML/XHTML serializers. Also, fixing long standing Bug
> #2248. Have had this fixed locally for almost a year, might as well
> apply it.
> <end cvs comment>
>
> Thanks,
>
> Simon
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org

[1] http://xml.apache.org/xerces2-j/faq-general.html#faq-5
[2] http://marc.theaimsgroup.com/?l=xalan-dev&m=107593381313807&w=2

---------------------------
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org