OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [xml-dev] use SAX to get "tree" under XML node




> The response from Ron Bourrett was on the mark except
> that I'd have said to always use an XMLWriter of some kind.

> There are too many corner cases you can trip over when you
> try to turn "raw data" into XML text.

I think it depends on XML subset one is using. 
When using "Monastic XML" , the only thing 
needed is encoding of few symbols into 
corresponding &entities; and that should be all (?)

Generating a full-blown XML with 
several namespaces becomes a tricky puzzle, 
very much different from trivial 
_normattr and _normvalue.
 
> (And I'd not describe turning a partial event stream into text
> to be getting a "tree" ... in that case I'd be more likely to build
> a data structure, maybe even populate a DOM fragment, with
> those events.)

This is very interesting point and I know that 
I could  not understand your comment, if I read it just 
a week ago.

Here is why.

I've been generating XML files for a very long time
with those print " " statements. But now, when 
I have Chunks implemented, the way I generate 
XML is :

c = Chunk()

c.cput("/doc/title/#value' , "List of books" )
c.cput("/doc/#array/book/#value", books_list )

And then 

c.emit()  # this has _normattr and _normciontent implemented ;-)

That will dump out 

<doc>
<title>List of books</title>
<book> book 1</book>
<book> book 2</book>
</doc>

I guess one can do similial things with DOM, 
but because XPath is not bi-directional, I'm 
not sure that DOM-based code would be as
terse as an (actual) code written above.

My point was to agree that 'populate-then-emit'
strategy is definately viable and may result in 
a terse and robust code, comparing it to 
'write it out with "print" '

Rgds.Paul.