diff options
author | Hans Hagen <pragma@wxs.nl> | 2012-05-22 01:22:00 +0200 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2012-05-22 01:22:00 +0200 |
commit | 3ecd4ddc188bb441690ea80cef39a06a875c9701 (patch) | |
tree | 4baa10dc663d18380857843629be0ab7b49d11c0 /scripts/context/stubs/unix | |
parent | 2895f6edd9f6692d7941a84e30ca06254338dfa8 (diff) | |
download | context-3ecd4ddc188bb441690ea80cef39a06a875c9701.tar.gz |
beta 2012.05.22 01:22
Diffstat (limited to 'scripts/context/stubs/unix')
-rwxr-xr-x | scripts/context/stubs/unix/mtxrun | 74 |
1 files changed, 72 insertions, 2 deletions
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun index 335c4fcb9..a8bbca885 100755 --- a/scripts/context/stubs/unix/mtxrun +++ b/scripts/context/stubs/unix/mtxrun @@ -8112,7 +8112,7 @@ xml.tocdata(e,"error") </typing> --ldx]]-- -function xml.tocdata(e,wrapper) +function xml.tocdata(e,wrapper) -- a few more in the aux module local whatever = type(e) == "table" and xmltostring(e.dt) or e or "" if wrapper then whatever = format("<%s>%s</%s>",wrapper,whatever,wrapper) @@ -10095,6 +10095,36 @@ function xml.cdatatotext(e) end end +-- local x = xml.convert("<x><a>1<b>2</b>3</a></x>") +-- xml.texttocdata(xml.first(x,"a")) +-- print(x) -- <x><![CDATA[1<b>2</b>3]]></x> + +function xml.texttocdata(e) -- could be a finalizer + local dt = e.dt + local s = xml.tostring(dt) -- no shortcut? + e.tg = "@cd@" + e.special = true + e.ns = "" + e.rn = "" + e.dt = { s } + e.at = nil +end + +-- local x = xml.convert("<x><a>1<b>2</b>3</a></x>") +-- xml.tocdata(xml.first(x,"a")) +-- print(x) -- <x><![CDATA[<a>1<b>2</b>3</a>]]></x> + +function xml.elementtocdata(e) -- could be a finalizer + local dt = e.dt + local s = xml.tostring(e) -- no shortcut? + e.tg = "@cd@" + e.special = true + e.ns = "" + e.rn = "" + e.dt = { s } + e.at = nil +end + xml.builtinentities = table.tohash { "amp", "quot", "apos", "lt", "gt" } -- used often so share local entities = characters and characters.entities or nil @@ -10242,7 +10272,7 @@ if not modules then modules = { } end modules ['lxml-xml'] = { } local concat = table.concat -local find = string.find +local find, lower, upper = string.find, string.lower, string.upper local xml = xml @@ -10639,6 +10669,46 @@ function xml.textonly(e) -- no pattern return concat(textonly(e,{})) end +-- + +-- local x = xml.convert("<x><a x='+'>1<B>2</B>3</a></x>") +-- xml.filter(x,"**/lowerall()") print(x) +-- xml.filter(x,"**/upperall()") print(x) + +function finalizers.lowerall(collected) + for c=1,#collected do + local e = collected[c] + if not e.special then + e.tg = lower(e.tg) + local eat = e.at + if eat then + local t = { } + for k,v in next, eat do + t[lower(k)] = v + end + e.at = t + end + end + end +end + +function finalizers.upperall(collected) + for c=1,#collected do + local e = collected[c] + if not e.special then + e.tg = upper(e.tg) + local eat = e.at + if eat then + local t = { } + for k,v in next, eat do + t[upper(k)] = v + end + e.at = t + end + end + end +end + end -- of closure |