lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Scott Morgan:-
>1) What happens if you have xml like <item _tag_="PITA">, not likely , 
>but possible.

I agree that this kind of "inband signalling" is not perfect. An easy
alternative would be 

xmlRoot = {["?tag"] = "person"... }

Of course it doesn't have to be a question mark; any character that is
invalid in XML names will do. Feature request for Lua: allow an extra
character (such as "?") as a valid character in identifiers:-

	?tag = "person"

This character would have no special meaning, but it would strengthen Lua
as a data language in situations like the one we are discussing. Of course
if every other language (including XML) follows suit and uses the same
character then we are back where we started! Maybe add the feature, but
politely ask would-be imitators to use their own character...

>2) Getting at the value held by the table is a bit difficult, in the 
>'name' and 'occupation' nodes it's at [1], but in the 'person' node it's 
>at [3]... Idealy all values stored should not be assumed to be 
>of type string.

The value stored need not be a string, but I don't think we can do much
about the variable position of the text data. XML allows you to have more
than one area of text separated by other elements:-

	<div>
		Hello<br/>
		and goodbye
	</div>

In cases like this, you would want the relative order of the text elements
and the <br/> to be preserved. This is not necessary for strictly "data"
uses of XML rather than document markup, though.

&.