Fabio Mascarenhas | 1 Feb 01:14
Picon
Favicon
Gravatar

Re: Lua vs. XML

On Sun, Jan 31, 2010 at 6:23 PM, Alexander Gladysh <agladysh <at> gmail.com> wrote:
Hi, list!

I need to load some trivial XMLs into Lua data at run-time. XML-s are
trivial, but do use UTF-8, CDATA and fancy entities, so library must
handle them well.

I wanted to use some luarocks-installable module, but failed to find
one that would install on my Ubuntu box.

Both luaexpat (which also looks too heavy for my needs) and
lua-xmlreader (which looks stalled at version 0.1) rocks fail to build
(I may provide bug reports if anyone interested).


I just uploaded new rocks for LuaExpat that uses the builtin build type instead of make, could you try them? They are building fine on OSX, could you try them on Ubuntu?

--
Fabio Mascarenhas

Yang Fan | 1 Feb 01:34
Picon
Gravatar

Re: Lua vs. XML

Hi, Alexander Gladysh

	I used ltxml ever, but it fails sometimes, I could not figure out the bug. And then I wrote an extremely
simple Xerces-C++ ( maybe much heavier for your needs ) DOM  api binding myself, it was tested on Windows box
only, but I'm not sure if there are no other bugs. You can check the source code from
http://code.google.com/p/lua-binding-libraries/ , good luck! 

======= 2010-02-01 04:24:03 you wrote:=======

>Hi, list!
>
>I need to load some trivial XMLs into Lua data at run-time. XML-s are
>trivial, but do use UTF-8, CDATA and fancy entities, so library must
>handle them well.
>
>I wanted to use some luarocks-installable module, but failed to find
>one that would install on my Ubuntu box.
>
>Both luaexpat (which also looks too heavy for my needs) and
>lua-xmlreader (which looks stalled at version 0.1) rocks fail to build
>(I may provide bug reports if anyone interested).
>
>All other Lua XML bindings I know about are not listed in the
>available rocks list. (And I'd like to avoid to try them one after
>another to find they just don't work for me...)
>
>Is the situation with XML handling in Lua really that dire as I
>imagine it, or am I just having a bad day? What do you use to handle
>XML in Lua?
>
>By the way, in my opinion, lua-users Wiki page on XML really sucks. :(
>
>http://lua-users.org/wiki/LuaXml

>
>(No, I'm not volunteering to fix it — I do not have enough data.)
>
>Alexander.

= = = = = = = = = = = = = = = = = = = =
			

        Regards

 
				 
        Yang Fan
        missdeer <at> gmail.com
          2010-02-01
Alexander Gladysh | 1 Feb 01:39
Picon
Gravatar

Re: Lua vs. XML

> I just uploaded new rocks for LuaExpat that uses the builtin build type
> instead of make, could you try them? They are building fine on OSX, could
> you try them on Ubuntu?

Confirmed, builds fine Ubuntu, thank you!

$ sudo luarocks install luaexpat
Installing http://luarocks.org/repositories/rocks/luaexpat-1.1.0-4.rockspec...
gcc -O2 -fPIC -I/usr/include/lua5.1 -c src/lxplib.c -o src/lxplib.o
-I/usr/include -Isrc/
gcc -shared -o lxp.so -L/usr/lib src/lxplib.o -L/usr/lib -lexpat
Updating manifest for /usr/local/lib/luarocks/rocks

However, I was not able to test it on OS X, as I started getting the
following error (now, on Ubuntu as well):

$ sudo luarocks install luaexpat
Installing http://luarocks.org/repositories/rocks/luaexpat-1.1.0-4.rockspec...

Error: Error fetching file: Failed downloading
http://luaforge.net/frs/download.php/2469/luaexpat-1.1.tar.gz

Looks like one more LuaForge problem to me.

http://downforeveryoneorjustme.com/luaforge.net

I've found GitHub project Downloads area really useful for hosting
releases. They also create tarballs automatically for each tag (now
with nicer URLs). (It seems, however, that LuaRocks does not handle
well all the HTTP redirections required to get such auto-generated
file...)

Alexander.

Picon

Re: Lua 5.2 and continue

> We've seen a work-in-progress version. Noone says that these features
> are here to stay.

Yes. http://www.lua.org/work/ explicitly says that "Everything may
change in the final version."

Picon

Re: Lua 5.2 and continue

 	Hi Martin

 	What's the problem with this version?

-- pseudo-code...
while true do
 	-- Read 10 bytes of data.
 	-- Last 9 bytes of previous run are re-used first if needed.
 	data = socket:read(10, data:sub(2))
 	if not data then
 		-- Serious error, break the loop
 		break
 	end

 	-- Check packet start code
 	if data:byte(1) == 0x47 then -- inverted condition
 		-- Parse raw bytes into a table with keys
 		pkt = convert(data)

 		-- More packet validation checking
 		if verifyHeader(pkt) then -- inverted condition
 			-- We used all data of this packet, don't re-use any of it
 			-- in the next run
 			data = ""

 			-- Do something with the packet
 			if pkt.cmd == CMD_EXIT then
 				break
 			elseif pkt.cmd == CMD_FOO then
 				foo()
 			end
 		end
 	end
end

 	The code becomes more indented, but in this specific case, it is
not a problem to me.  To me this version is clearer than yours, but I
am sure this is a matter of taste :-)

 	Regards,
 		Tomás
pan shizhu | 1 Feb 02:11
Picon

Re: Lua 5.2 and continue

> I believe that Lua Team position on "popular requests" and new
> language features was stated many times on this list and elsewhere. It
> is very conservative, and that is good.
>

Perhaps I'm the only person who follows the PIL?

The manual clearly states that you should staticaly link lua to your
application, that means you always have your own version of Lua in
your application.

I always put lua code inside my project and compile it with the
application, so any local change should work. If the official code
states how to enable the code for continue, I can add continue to my
Lua and nobody else get hurt.

I'd like lua to add lots of compile-time options, macro defines, to
let the developers include lua features selectively.

Picon

Re: Lua 5.2 and continue

> I'd like lua to add lots of compile-time options, macro defines, to
> let the developers include lua features selectively.

Which ones for instance?

David Burgess | 1 Feb 02:23
Picon

Re: Lua 5.2 and continue

#define LUA_NO_DEBUGLIB 1
#define LUA_NO_IOLIB 1
#define LUA_NO_OSLIB 1
#define LUA_NO_TABLELIB 1
#define LUA_NO_BITLIB 1

On 1/2/2010 12:18 PM, Luiz Henrique de Figueiredo wrote:
>> I'd like lua to add lots of compile-time options, macro defines, to
>> let the developers include lua features selectively.
>
> Which ones for instance?

Picon

Re: Lua 5.2 and continue

> #define LUA_NO_DEBUGLIB 1
> #define LUA_NO_IOLIB 1
> #define LUA_NO_OSLIB 1
> #define LUA_NO_TABLELIB 1
> #define LUA_NO_BITLIB 1

All this is easy: just remove the corresponding lines in lualibs in linit.c.
Or use LUA_INIT with "debug=nil;io=nil;os=nil;table=nil;bit=nil".
Or lua -e "debug=nil;io=nil;os=nil;table=nil;bit=nil".

Patrick Donnelly | 1 Feb 02:44

Re: Lua 5.2 and continue

Hi David,

On Sun, Jan 31, 2010 at 8:23 PM, David Burgess <dabsoft <at> gmail.com> wrote:
> #define LUA_NO_DEBUGLIB 1
> #define LUA_NO_IOLIB 1
> #define LUA_NO_OSLIB 1
> #define LUA_NO_TABLELIB 1
> #define LUA_NO_BITLIB 1

This is a bit unreasonable. luaconf.h should be for making *common*
sweeping changes to the Lua source. Not compiling a couple libraries
is a simple makefile and linit.c change (as lhf noted).

--

-- 
-Patrick Donnelly

"Let all men know thee, but no man know thee thoroughly: Men freely
ford that see the shallows."

- Benjamin Franklin


Gmane