[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua XML Parser (LuaXML-0.0.0)
- From: "Jay Carlson" <nop@...>
- Date: Mon, 3 Dec 2001 15:23:05 -0500
> The API for LuaXML is loosely based on the expat/sax callback api but
> slightly restructured to make the handler code easier - so I think it
> meets your criteria (!). To define a handler you can just do something
> like -
>
> myHandler = {}
> myHandler.starttag = function (t,a) ... end
> mtHandler.endtag = function (t,a) ... end
> xmlParser(myHandler):parse("<xml>...")
The way I handled this was to require that myHandler be initialized from a
function call:
myHandler = makeParser()
myHandler.starttag = function (t, a) end
myHandler:parse("<xml>")
But in some ways your solution is superior in that you can build the
myHandler table once and use it for multiple parses, where in mine I have to
add the entries to the table each time I call makeParser(). It's easy
enough to switch back and forth between the styles, I suppose, but you can't
do "for i,v in jaysParser" as jaysParser is userdata---have I mentioned that
I like ExtendingForAndNext? So it's easier to emulate your style than it is
to emulate mine.
I'm sorry I didn't respond earlier---I got sucked off into spec lawyering on
the xml-rpc list.
Jay