|  | ||
| 
 | 
Sometimes you don't have a complete tree to parse. This is the case with a jabber-xmlrpc project I worked on. In this case I had to do all kinds of funky things to the xml tree to parse it a node at a time.
I am intrigued by Jay's proposal.
-joe
-----Original Message-----
From: John Belmonte [mailto:john@neggie.net] 
Sent: Monday, February 23, 2004 11:08 AM
To: Lua list
Subject: Re: lazy xml teaser
Jay Carlson wrote:
> Why is this interesting?  Trees are a natural data model to process
> XML documents.  A simple tree implementation reads the entire document
> into memory at once.  For large documents, this can be too expensive.
> Although callback and event APIs are memory-efficient, they are
> painful to program to.
> 
> Lazynode constructs an conventional-seeming XML tree as its contents
> are referenced, parsing more source document as necessary to fill out
> the contents on demand.
I understand how this could save memory in a Lua table represent ion of 
an XML document.  The "parsing more source document as necessary" is 
arguable.  I've found it best to run an XML document through a validator 
like relax-ng before using it, relieving my program from the task of 
ad-hoc validation.  Considering this, the XML often has already been 
parsed before your program gets to it.
-John
-- 
http:// if  ile.org/