[ 
https://issues.apache.org/jira/browse/XERCESJ-150?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18003482#comment-18003482
 ] 

Elliotte Rusty Harold commented on XERCESJ-150:
-----------------------------------------------

Cods is busted by design:

{{    /**
     * Comments and PIs cannot be serialized before the root element,
     * because the root element serializes the document type, which
     * generally comes first. Instead, such PIs and comments are
     * accumulated inside a vector and serialized by calling this
     * method. Will be called when the root element is serialized
     * and when the document finished serializing.}}

This should be fixed

> Processing instruction cannot precede doctype
> ---------------------------------------------
>
>                 Key: XERCESJ-150
>                 URL: https://issues.apache.org/jira/browse/XERCESJ-150
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: Serialization
>    Affects Versions: 2.0.0
>         Environment: Operating System: Other
> Platform: Other
>            Reporter: Paul Prescod
>
> Given: 
> {noformat}
>     public static void main(String []args) throws SAXException{
>         XMLSerializer serializer = new XMLSerializer();
>         serializer.setOutputByteStream(System.out);
>         serializer.startDocument();
>         serializer.processingInstruction("foo", "bar");
>         serializer.startDTD("foo", "bar", "baz");
>         serializer.startElement("foo", "bar", "bar", null);
>         serializer.endElement("foo", "bar", "bar");
>         serializer.endDocument();
>     }
> {noformat}
> Xerces goes to a great deal of effort to make the processing instruction 
> appear 
> AFTER the doctype (serializePreRoot etc.). But why is this so? It is 
> perfectly 
> legal in XML for a processing instruction to proceed the doctype!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to