diff options
author | Hans Hagen <pragma@wxs.nl> | 2009-09-25 23:52:00 +0200 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2009-09-25 23:52:00 +0200 |
commit | d83bd4e8a89d96bd9dfabf4427d02efb9623e5a2 (patch) | |
tree | c46ca0538a22b89af545e545fa627f1cb6418dd2 /tex/context/base/lxml-tab.lua | |
parent | 43986f8edd2afd919afbb9988cb6778fc3c02077 (diff) | |
download | context-d83bd4e8a89d96bd9dfabf4427d02efb9623e5a2.tar.gz |
beta 2009.09.25 23:52
Diffstat (limited to 'tex/context/base/lxml-tab.lua')
-rw-r--r-- | tex/context/base/lxml-tab.lua | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/tex/context/base/lxml-tab.lua b/tex/context/base/lxml-tab.lua index 52e04befd..b49bf0ecb 100644 --- a/tex/context/base/lxml-tab.lua +++ b/tex/context/base/lxml-tab.lua @@ -39,7 +39,7 @@ xml = xml or { } --~ local xml = xml local concat, remove, insert = table.concat, table.remove, table.insert -local type, next, setmetatable = type, next, setmetatable +local type, next, setmetatable, getmetatable = type, next, setmetatable, getmetatable local format, lower, find = string.format, string.lower, string.find --[[ldx-- @@ -175,6 +175,14 @@ local stack, top, dt, at, xmlns, errorstr, entities = {}, {}, {}, {}, {}, nil, { local mt = { __tostring = xml.text } +function initialize_mt(root) + mt = { __tostring = xml.text, __index = root } +end + +function xml.setproperty(root,k,v) + getmetatable(root).__index[k] = v +end + function xml.check_error(top,toclose) return "" end @@ -366,9 +374,14 @@ local grammar = P { "preamble", -- todo: xml.new + properties like entities and strip and such (store in root) -function xml.convert(data, no_root, strip_cm_and_dt, given_entities) -- maybe use table met k/v (given_entities may disapear) +function xml.convert(data, no_root, strip_cm_and_dt, given_entities, parent_root) -- maybe use table met k/v (given_entities may disapear) strip = strip_cm_and_dt or xml.strip_cm_and_dt stack, top, at, xmlns, errorstr, result, entities = {}, {}, {}, {}, nil, nil, given_entities or {} + if parent_root then + mt = getmetatable(parent_root) + else + initialize_mt(top) + end stack[#stack+1] = top top.dt = { } dt = top.dt |