lua-users home
lua-l archive

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


Hello,
 
I'm using luaexpat (from the Kepler project) to parse xml files that contain entities like  
These cause the parser to abort with the error 'undefined entity'...
 
Is the a way to tell luaexpat to handle these errors 'gently', or do I have to preprocess the input to catch them?
 
Thanks,
    Hans.

Example:
 
#!/usr/bin/env lua
require("lxp")
 
function doStart(parser, name, attr)  print('start of', name) end
data = ''
local xml = lxp.new{ StartElement = doStart}
 
a,b = xml:parse(data)
if not a then
  local l,c = xml:pos()
  print(string.format("ERROR: [%d,%d] %s", l, c, b))
else
  xml:close()
end
 
Output:
start of        aa
start of        bb
start of        cc
ERROR: [1,34] undefined entity