XML typos

A place to discuss everything about the Orxonox framework.

Moderator: PPS-Leaders

Post Reply
User avatar
1337
Baron Vladimir Harkonnen
Posts: 521
Joined: Wed Oct 10, 2007 7:59 am

XML typos

Post by 1337 » Fri Nov 28, 2008 3:22 pm

What exactly should happen if there is a small error in an XML script of ours?

I have three suggestions:
1) We simply ignore the part that couldn't be parsed because of the type or mistake.
2) We only ignore small things like "velocty = "1,2,3"" and issue a warning.
3) We display the error and abort the loading.

Personally, I can only think of 3) as a good solution. The reason simply being that you can have an XML full of mistakes, half of the code does nothing, but something is still getting loaded.

What do you think?
http://www.xkcd.com/
A webcomic of romance, sarcasm, math, and language.

User avatar
beni
Baron Vladimir Harkonnen
Posts: 949
Joined: Tue Oct 03, 2006 9:15 am
Location: Zurich
Contact:

Post by beni » Fri Nov 28, 2008 11:27 pm

A running level suggest it has been loaded correctly. I don't know if a warning about something which cannot be loaded is good enough.

I would suggest 3) but when I think about levels that have to work with several versions of the game, I think small things like a parameter (like in 2) could be ignored with a warning. However ignoring will suggest everything went great. 1) is out of question I think.
"I'm Commander Shepard and this is my favorite forum on the internet."

User avatar
x3n
Baron Vladimir Harkonnen
Posts: 810
Joined: Mon Oct 30, 2006 5:40 pm
Contact:

Post by x3n » Sat Nov 29, 2008 12:52 pm

There's currently no mechanism to detect undefined XML keywords, but I've already thought about it and it shouldn't be a big deal since we store all XML containers in the Identifiers.

But I don't want to correct mistakes (2) which is very uncommon in all kind of computer languages and I neither want to abort loading (3), because sometimes you just quickly want to test a level or a new feature and don't care about hundreds of errors in your XML code.
I prefer ignoring the error (1) and droping a warning. If someone wants to release a new level, he will of course remove all warnings, so in the end it's the same for players but more convenience for developers.
Fabian 'x3n' Landau, Orxonox developer

User avatar
1337
Baron Vladimir Harkonnen
Posts: 521
Joined: Wed Oct 10, 2007 7:59 am

Post by 1337 » Sat Nov 29, 2008 9:38 pm

Then I suggest something like a switch (command line or configvalue) that teaches the parser not to issue exceptions. However this cannot be hidden at all. The developer must choose it explicitly.

I'm not ready to correct hundreds of script errors just because everyone ignores the warnings.
I mean, I can't remember any (script) language that compiles with typos.
http://www.xkcd.com/
A webcomic of romance, sarcasm, math, and language.

User avatar
x3n
Baron Vladimir Harkonnen
Posts: 810
Joined: Mon Oct 30, 2006 5:40 pm
Contact:

Post by x3n » Sun Nov 30, 2008 1:22 am

But XML is not a script language, it's a description language. You're not writing right or wrong code, you're describing something and it depends completely on the reader if he understands your code.

You can as well write HTML code with typos and you won't get any errors or warnings neither by the browser nor the server nor the HTML editor, it's just not doing what you wanted it to do. Correcting typos is even worse, that's more or less what Internet Explorer did.

Writing "velocty" is not an error, you're just defining a new parameter. And the absence of "velocity" is neither an error, because XML will use the default value.

But of course you're right when pointing out it wasn't the users will to define a new parameter named "velocty" in this case. So I totally agree to throw a warning as a convenience for developers, like the w3c validator for HTML. Of course those warnings should be configurable, because the common user just wants to play the game and we don't want to disturb him.

But I really don't share your fear of having to correct other peoples errors (Why would you? Are you the good Samaritan or what?). It's completely in the responsibility of the level designer to create error- and warning-free code. And even if there are warnings, it doesn't matter, because obviously the level is working as expected by the designer (otherwise he wouldn't release the level). Removing those warnings then reduces to removing undefined parameters which is a rather simple work.

If you want a more formal explanation, you have to realize that XML code can be used by several instances whereof everyone just understands a part of the code. This is in fact exactly what Orxonox is doing, every XMLPortParam is such an instance. This is also the reason why it's not totally simple to detect unknown parameters.

You could also think of a level which was designed for a modification but is now played in the regular game. Several classes and additional parameters are unknown, but nevertheless it's a playable level and the player may have much fun.
Fabian 'x3n' Landau, Orxonox developer

User avatar
1337
Baron Vladimir Harkonnen
Posts: 521
Joined: Wed Oct 10, 2007 7:59 am

Post by 1337 » Sun Nov 30, 2008 9:30 am

x3n wrote: You can as well write HTML code with typos and you won't get any errors or warnings neither by the browser nor the server nor the HTML editor, it's just not doing what you wanted it to do. Correcting typos is even worse, that's more or less what Internet Explorer did.
I didn't know that (no wonder, I have never written HTML code). But it makes me feel bad about it.
There's something I would like to add: We're not exactly using 'just' XML. It's our own description language and it can be well defined.
x3n wrote: Writing "velocty" is not an error, you're just defining a new parameter. And the absence of "velocity" is neither an error, because XML will use the default value.
This is my worst fear: The code you just wrote doesn't do what you expect. Big warnings will be required for the developer of that level.
x3n wrote: If you want a more formal explanation, you have to realize that XML code can be used by several instances whereof everyone just understands a part of the code. This is in fact exactly what Orxonox is doing, every XMLPortParam is such an instance. This is also the reason why it's not totally simple to detect unknown parameters.

You could also think of a level which was designed for a modification but is now played in the regular game. Several classes and additional parameters are unknown, but nevertheless it's a playable level and the player may have much fun.
I fully agree on that. As long as the modifications are in a style of only adding new things, you have a point.


My Conclusion:
--> Level 1 or 2 warnings for the release (so the user doesn't see them)
--> Normal developer sees these warnings
--> Special mode that forces you to correct your mistakes.

Though the last point is rather a nice feature than something essential.
http://www.xkcd.com/
A webcomic of romance, sarcasm, math, and language.

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests