summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/lxml-tex.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2017-09-25 20:02:27 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2017-09-25 20:02:27 +0200
commite5c13c74b45e08527dda1d1be1788cccd96b6dac (patch)
tree8a723643b5eba3a89a8ea752ffe427cbe64161f6 /tex/context/base/mkiv/lxml-tex.lua
parentf7ee609d470a08a16e5cdaad14582fc8ed993c5e (diff)
downloadcontext-e5c13c74b45e08527dda1d1be1788cccd96b6dac.tar.gz
2017-09-25 19:25:00
Diffstat (limited to 'tex/context/base/mkiv/lxml-tex.lua')
-rw-r--r--tex/context/base/mkiv/lxml-tex.lua55
1 files changed, 44 insertions, 11 deletions
diff --git a/tex/context/base/mkiv/lxml-tex.lua b/tex/context/base/mkiv/lxml-tex.lua
index b7c76c193..2fd26c3b2 100644
--- a/tex/context/base/mkiv/lxml-tex.lua
+++ b/tex/context/base/mkiv/lxml-tex.lua
@@ -201,8 +201,8 @@ end
-- tex interface
-lxml.loaded = lxml.loaded or { }
-local loaded = lxml.loaded
+local loaded = lxml.loaded or { }
+lxml.loaded = loaded
-- print(contextdirective("context-mathml-directive function reduction yes "))
-- print(contextdirective("context-mathml-directive function "))
@@ -322,6 +322,40 @@ end
-- storage
+do
+
+ local noferrors = 0
+ local errors = setmetatableindex("number")
+ local errorhandler = xml.errorhandler
+
+ function xml.errorhandler(message,filename)
+ if filename and filename ~= "" then
+ noferrors = noferrors + 1
+ errors[filename] = errors[filename] + 1
+ end
+ errorhandler(filename)
+ end
+
+ logs.registerfinalactions(function()
+ if noferrors > 0 then
+ local report = logs.startfilelogging("lxml","problematic xml files")
+ for k, v in table.sortedhash(errors) do
+ report("%4i %s",v,k)
+ end
+ logs.stopfilelogging()
+ --
+ if logs.loggingerrors() then
+ logs.starterrorlogging(report,"problematic xml files")
+ for k, v in table.sortedhash(errors) do
+ report("%4i %s",v,k)
+ end
+ logs.stoperrorlogging()
+ end
+ end
+ end)
+
+end
+
function lxml.store(id,root,filename)
loaded[id] = root
xmlsetproperty(root,"name",id)
@@ -557,8 +591,8 @@ function lxml.load(id,filename,compress)
noffiles, nofconverted = noffiles + 1, nofconverted + 1
starttiming(xml)
local ok, data = resolvers.loadbinfile(filename)
--- local xmltable = lxmlconvert(id,(ok and data) or "",compress,formatters["id: %s, file: %s"](id,filename))
-local xmltable = lxmlconvert(id,(ok and data) or "",compress,filename)
+ -- local xmltable = lxmlconvert(id,(ok and data) or "",compress,formatters["id: %s, file: %s"](id,filename))
+ local xmltable = lxmlconvert(id,(ok and data) or "",compress,filename)
stoptiming(xml)
lxml.store(id,xmltable,filename)
return xmltable, filename
@@ -600,19 +634,18 @@ function lxml.include(id,pattern,attribute,options)
filename = resolveprefix(filename) or filename
end
-- some protection
- if options.rootpath then
- if dirname(filename) == "" and root.filename then
- local dn = dirname(root.filename)
- if dn ~= "" then
- filename = joinfile(dn,filename)
- end
+ if options.rootpath and dirname(filename) == "" and root.filename then
+ local dn = dirname(root.filename)
+ if dn ~= "" then
+ filename = joinfile(dn,filename)
end
end
if trace_loading then
report_lxml("including file %a",filename)
end
noffiles, nofconverted = noffiles + 1, nofconverted + 1
- return resolvers.loadtexfile(filename) or "",
+ return
+ resolvers.loadtexfile(filename) or "",
resolvers.findtexfile(filename) or ""
else
return ""