lua-users home
lua-l archive

Accessing "external" tables from within LuaExpat callbacks

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


Hi,
I used a simple example from LuaExpat (something like this):
local lom = require "lxp"
plugin = {}
function cb( tag, attribute, value )
 plugin[ attribute ] = value
end
local callbacks = {
 StartElement = function( parser, name, attributes )
 for _, attribute in pairs( attributes ) do
 cb( name, attribute, attributes[ attribute ] )
 end
 end,
 EndElement = function( parser, name ) end,
 CharacterData = false
}
	
local xml_file = "info.plist"
local parser = lxp.new( callbacks )
local file = assert( io.open( xml_file, "r" ) )
		
parser:parse( file:read( "*all" ) )
file:close();
collectgarbage()
parser:parse()
parser:close()
Everytime I try to modify a table in the referenced method "cb", the application stops with an accessviolation. What I'm doing wrong?
Best Regards
Micha

AltStyle によって変換されたページ (->オリジナル) /