# HG changeset patch # User Matthew Wild # Date 1396468618 -3600 # Node ID 90da47758f85eaa47bda98db804ee26051922159 # Parent 7f0e6f8bb8e0bbc607f52e7fb216beaf14238d28 Add support for XmlDecl handlers diff -r 7f0e6f8bb8e0 -r 90da47758f85 src/lxplib.c --- a/src/lxplib.c Wed Apr 02 20:53:54 2014 +0100 +++ b/src/lxplib.c Wed Apr 02 20:56:58 2014 +0100 @@ -326,6 +326,16 @@ docall(xpu, 4, 0); } +static void f_XmlDecl (void *ud, const XML_Char *version, + const XML_Char *encoding, + int standalone) { + lxp_userdata *xpu = (lxp_userdata *)ud; + if (getHandle(xpu, XmlDeclKey) == 0) return; /* no handle */ + lua_pushstring(xpu->L, version); + lua_pushstring(xpu->L, encoding); + lua_pushboolean(xpu->L, standalone); + docall(xpu, 3, 0); +} /* }====================================================== */ @@ -346,7 +356,7 @@ "Default", "DefaultExpand", "StartElement", "EndElement", "ExternalEntityRef", "StartNamespaceDecl", "EndNamespaceDecl", "NotationDecl", "NotStandalone", "ProcessingInstruction", - "UnparsedEntityDecl", "StartDoctypeDecl", NULL}; + "UnparsedEntityDecl", "StartDoctypeDecl", "XmlDecl", NULL}; if (hasfield(L, "_nonstrict")) return; lua_pushnil(L); while (lua_next(L, 1)) { @@ -401,6 +411,8 @@ XML_SetUnparsedEntityDeclHandler(p, f_UnparsedEntityDecl); if (hasfield(L, StartDoctypeDeclKey)) XML_SetStartDoctypeDeclHandler(p, f_StartDoctypeDecl); + if (hasfield(L, XmlDeclKey)) + XML_SetXmlDeclHandler(p, f_XmlDecl); return 1; } diff -r 7f0e6f8bb8e0 -r 90da47758f85 src/lxplib.h --- a/src/lxplib.h Wed Apr 02 20:53:54 2014 +0100 +++ b/src/lxplib.h Wed Apr 02 20:56:58 2014 +0100 @@ -20,5 +20,6 @@ #define ProcessingInstructionKey "ProcessingInstruction" #define UnparsedEntityDeclKey "UnparsedEntityDecl" #define StartDoctypeDeclKey "StartDoctypeDecl" +#define XmlDeclKey "XmlDecl" int luaopen_lxp (lua_State *L);