Unnamed Fossil Project

Check-in [4481b65d54]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Vylepsen XMLCodec.
Timelines: family | ancestors | trunk
Files: files | file ages | folders
SHA1:4481b65d547919cce06bbf9d53d06a2aa19e7229
User & Date: Yasha 2014-04-21 17:33:01
Context
2014-04-21
17:33
Vylepsen XMLCodec. Leaf check-in: 4481b65d54 user: Yasha tags: trunk
16:07
Budeme mit testy. check-in: 9d774c8178 user: Yasha tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to lib/xmlcodec.lua.

25
26
27
28
29
30
31





32
33
34
35
36
37
38
			current.root = elem
		end
	end,
	attribute = function(name,value,nsURI)
		current.elem[name] = value
	end,
	closeElement = function(name)





		pop(current.stack)
		current.elem = last(current.stack) -- set parent elem as current
	end,
	text = function(value)
		push(current.elem or {}, value)
	end,
	comment = function(value)







>
>
>
>
>







25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
			current.root = elem
		end
	end,
	attribute = function(name,value,nsURI)
		current.elem[name] = value
	end,
	closeElement = function(name)
		if current.opts.check_balanced then
			if current.elem[0]~=name then
				error("Unbalanced XML - expected </" .. current.elem[0] .. " ...> instead of </" ..name .. "...>" )
			end
		end
		pop(current.stack)
		current.elem = last(current.stack) -- set parent elem as current
	end,
	text = function(value)
		push(current.elem or {}, value)
	end,
	comment = function(value)

Changes to tests/xmlcodec.lua.

7
8
9
10
11
12
13



14




15
assert(foo[0]=="foo")
assert(type(foo[1])=="table")
assert(type(foo[2])=="string")
assert(foo[2]=="baz")
assert(foo[1][0]=="bar")
assert(foo[1]['baz']=="foo")









print "OK"







>
>
>

>
>
>
>

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
assert(foo[0]=="foo")
assert(type(foo[1])=="table")
assert(type(foo[2])=="string")
assert(foo[2]=="baz")
assert(foo[1][0]=="bar")
assert(foo[1]['baz']=="foo")

local crossing = [[<ex>
<i>this is <b>typical</i> example</b>
</ex>]]

local ingore_unbalaced, errmsg = pcall(function() codec.parse(crossing,{check_balanced=true}) end)
assert(not ingore_unbalanced)
assert(errmsg:find("Unbalanced",1,true))

print "OK"