Re: event order

Aleksander Slominski <[email protected]>
Newsgroups gmane.text.xml.xmlpull.devel
Message-ID <[email protected]>
Pawel S. Veselov wrote:

>I have a note regarding the order of the events that are proposed in
>the API. It is, of course, implementation dependent, but API guides
>the implementation to always start with START_DOCUMENT event. Actually,
>this event usually never happens at all, i.e. first call to nextToken()
>will not generate it.
>
hi,

that is right - START_DOCUMENT is before first call to any next*() method.

you may want to think about START_DOCUMENT as the initial parser state 
-parser is in this state *before* processing any content (however parser 
may have already read some input bytes to determine stream character 
encoding etc.)

i agre the name is a bit mileading if you worked with SAX before though ...

>The problem with that, IMVHO, is that the document starts only
>after the document declaration has been read. That pretty much
>comes from the DOM, since DOM needs a document type in order to
>create the Document object, and perhaps it would be more natural, if
>DOCDECL event happens first, so the DocumentType object is created,
>and then START_DOCUMENT follows, so the Docment object is created on
>existing DocmentType. Otherwise, the document creation has to be
>deferred to first event after DOCDECL.
>
you should be able to pull put DOCDECL by using nextToken() and only 
when you reach first START_TAG to create DOM document.

nextToken can report also processing instructions and comments that you 
may want to retain if you are reconstructing XML infoset (see 
http://www.w3.org/TR/xml-infoset/#infoitem.document)

see also my next email and tell me what  you think about use of 
properties to access document type (that could be used with DOM2).

thanks,

alek

-- 
"Mr. Pauli, we in the audience are all agreed that your theory is crazy. 
What divides us is whether it is crazy enough to be true." Niels H. D. Bohr



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/LIgTpC/vN2EAA/xGHJAA/2U_rlB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
[email protected]

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.