You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Lars Martin <la...@smb-tec.com> on 2000/08/17 16:48:44 UTC

Bug in org.apache.xml.serialize.BaseMarkupSerializer.java

Hi all,

in my last email I've written that I have problems with the serializer package
that is coming with Xerces. Now I had the time to look at the corresponding code
and I presume that there is a bug in the XML serialization code.

The BaseMarkupSerializer comes with the method

	public setDoctype (string, string)

which allows to omit DTD serialization. I use this to set it to 'null' with

	setDoctype (null, null);

The internal method

	protected void serializeNode( Node node )

prints each different type of node. In the case of Node.DOCUMENT_NODE it calls

	startDTD( docType.getName(), docType.getPublicId(), docType.getSystemId() );

This resets the members _docTypePublicId and _docTypeSystemId to the values of
the document. If XMLSerializer.java now tries to write the document with

	protected void startDocument( String rootTagName )

the value of _docTypeSystemId is used to test if the DOCTYPE should be printed

	if ( _docTypeSystemId != null ) {
		... print DOCTYPE
	}

But this member is not 'null' because of the startDTD() call in
BaseMarkupSerializer.java.

Any help on this?

Lars
--
___________________________________________________________________
Lars Martin                                 mailto:lars@smb-tec.com
SMB GmbH                                     http://www.smb-tec.com


Re: Bug in org.apache.xml.serialize.BaseMarkupSerializer.java

Posted by Assaf Arkin <ar...@intalio.com>.
I've changed the comment and also added an omitDoctype() method to
OutputFormat.

I'm waiting to get other bugs reported on the list and will commit all
together to the CVS and let everyone know.

arkin

Lars Martin wrote:
> 
> Hi Arkin,
> 
> thanks for your answer.
> 
> On Son, 20 Aug 2000, Assaf Arkin wrote:
> > setDoctype() was designed to specify a DTD if one was not specified in
> > the Document object, not to override it.
> 
> If have DTD in my document but don't want to serialize it. I don't want to
> overwrite/delete the DTD in my in-memory document. Serialization should
> omit DTD printing.
> 
> > The serializer by default will take the DTD from Document or from the
> > SAX events. If a DTD was not specified in either one, it will take the
> > one supplied by calling setDocType().
> >
> > Calling setDoctype(null,null) doesn't override the DTD specified in the
> > Document object in the current implementation.
> 
> Yes, it doesn't overwrite the DTD in the document. This method specifies
> whether the DTD should be serialized or not. The javadoc of setDoctype()
> says:
> 
>         * No <tt>DOCTYPE</tt> will be serialized if both identifiers
>         * are null.
> 
> Will there be a correction in the next future? I fixed this in my local source
> tree, but it is a dirty fix IMO.
> 
> Regards,
> Lars
> --
> ___________________________________________________________________
> Lars Martin                                 mailto:lars@smb-tec.com
> SMB GmbH                                     http://www.smb-tec.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org

-- 
----------------------------------------------------------------------
Assaf Arkin                                            www.intalio.com
CTO, Intalio Inc.                                       www.exolab.org

Re: Bug in org.apache.xml.serialize.BaseMarkupSerializer.java

Posted by Lars Martin <la...@smb-tec.com>.
Hi Arkin,

thanks for your answer.

On Son, 20 Aug 2000, Assaf Arkin wrote:
> setDoctype() was designed to specify a DTD if one was not specified in
> the Document object, not to override it.

If have DTD in my document but don't want to serialize it. I don't want to
overwrite/delete the DTD in my in-memory document. Serialization should
omit DTD printing.

> The serializer by default will take the DTD from Document or from the
> SAX events. If a DTD was not specified in either one, it will take the
> one supplied by calling setDocType().
> 
> Calling setDoctype(null,null) doesn't override the DTD specified in the
> Document object in the current implementation.

Yes, it doesn't overwrite the DTD in the document. This method specifies
whether the DTD should be serialized or not. The javadoc of setDoctype()
says:

	* No <tt>DOCTYPE</tt> will be serialized if both identifiers
	* are null. 

Will there be a correction in the next future? I fixed this in my local source
tree, but it is a dirty fix IMO.

Regards,
Lars
-- 
___________________________________________________________________
Lars Martin                                 mailto:lars@smb-tec.com
SMB GmbH                                     http://www.smb-tec.com


Re: Bug in org.apache.xml.serialize.BaseMarkupSerializer.java

Posted by Assaf Arkin <ar...@intalio.com>.
Lars,

I apologize for not getting this reply sooner to you. I sent it from my
home PC where I'm using a different e-mail address not registerd with
Xerces-J, so my original reply was rejected but did not bounce back.

setDoctype() was designed to specify a DTD if one was not specified in
the Document object, not to override it.

The serializer by default will take the DTD from Document or from the
SAX events. If a DTD was not specified in either one, it will take the
one supplied by calling setDocType().

Calling setDoctype(null,null) doesn't override the DTD specified in the
Document object in the current implementation.

arkin



Lars Martin wrote:
> 
> Hi all,
> 
> in my last email I've written that I have problems with the serializer package
> that is coming with Xerces. Now I had the time to look at the corresponding code
> and I presume that there is a bug in the XML serialization code.
> 
> The BaseMarkupSerializer comes with the method
> 
>         public setDoctype (string, string)
> 
> which allows to omit DTD serialization. I use this to set it to 'null' with
> 
>         setDoctype (null, null);
> 
> The internal method
> 
>         protected void serializeNode( Node node )
> 
> prints each different type of node. In the case of Node.DOCUMENT_NODE it calls
> 
>         startDTD( docType.getName(), docType.getPublicId(), docType.getSystemId() );
> 
> This resets the members _docTypePublicId and _docTypeSystemId to the values of
> the document. If XMLSerializer.java now tries to write the document with
> 
>         protected void startDocument( String rootTagName )
> 
> the value of _docTypeSystemId is used to test if the DOCTYPE should be printed
> 
>         if ( _docTypeSystemId != null ) {
>                 ... print DOCTYPE
>         }
> 
> But this member is not 'null' because of the startDTD() call in
> BaseMarkupSerializer.java.
> 
> Any help on this?
> 
> Lars
> --
> ___________________________________________________________________
> Lars Martin                                 mailto:lars@smb-tec.com
> SMB GmbH                                     http://www.smb-tec.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org

-- 
----------------------------------------------------------------------
Assaf Arkin                                            www.intalio.com
CTO, Intalio Inc.                                       www.exolab.org