lua-users home
lua-l archive

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


Jay Carlson writes:

It will be harder to get agreement on the tree API, so I'd suggest we work
on the event-based one first---"Lua SAX"?
expat sets an upper bound on how much functionality we can expect.  For
instance, expat won't distinguish <foo></foo> from <foo/>.
I really like interfaces where you set up callbacks with function
o.callback() end, as you can probably tell from Lua FLTK and Lxp :-)

This sounds like a good plan - I would be willing to put some effort
into defining this and modifying both my LuaXML and lxp (if you have no
objections) to support this once we have rough consensus.
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 biggest difference is in text handling where LuaXML will generate a
single callback for the text (optionally ignoring non-significant
whitespace) unlike the expat CharacterDataHandler which can generate
multiple calls.
I dont know if you have had a chance to take a look at the API -
is documented in xml.lua and I would be interested in whether you think
this is the right approach - assuming so I will look at merging in
any changes to allow expat to be used as a backend as well and use this
as the basis of the solution. I should hopefully be able to put something
together this weekend (modulo household distractions).
I'd rather take *your* suggestions on the merge. The last serious work I did with XML was like 2-3 years ago, and I don't use it enough day-to-day to understand what people need these days to get things done. At this point, all I can do is try to offer clever (well, at least I think they're clever) suggestions on tricks to make the API more Lua-friendly.

I dont claim to be an XML expert but in the absence of anyone else am
willing to have a go. I would appreciate any feedback on the LuaXML
code - this is my first attempt to do anything particularly serious in
Lua) Regards, PaulC