≡ Menu

Robust XML

I was hoping to keep you updated with my Tetris status. Sadly, the Nintendo leaderboard has been broken for the past week, so I have not be able to tell you where I\’m at… Needless to say, I am not number 1 in the world at the moment… At best, I\’m number 2. I can beat the guy that is number 1, but he beats me more… Practice I guess.. Cool guy though.

So really, what I\’m writing about today is something I put together for sunfox (and maybe oxwaf if we can switch out the engine at some point) that allows for more robust xml parsing of what we call blueprints.

Blueprints are XML documents in Oxwaf that determine what gets put on the page. They are designed to be fast and allow you to use the same layout over and over again without having to recode everything over and over again. The version in Oxwaf had a problem though. XML is a very picky language. If you get a parsing error, not only does it let you know, but it stops processing the document all together.

When something like this happened in Oxwaf, the whole page would blow up and it would most likely say \"Could not get content document\" or give some other parse message. For a development site, this is ok, but for a production site, you can\’t have this happen.

Our style in the past has always been to prevent those errors from coming up by not coding anything that could make it possible. However, time and time again, someone always finds a way to get one of those errors to pop up. Whether it be by using some strange unicode character, or using missing a closing tag. The problem isn\’t that the computer doesn\’t know what to do in that case, it\’s that the computer refuses to parse anything after it, or remember what it did before that, meaning: No page.

The new parser though solves this problem. Instead of giving up, it trys again, but before trying again, it removes the tag that is bad, and all it\’s contents. It\’s not perfect yet, but it\’s better than what we had. This way, instead of getting a content error message and not doing anything, it will at least do what it can with the good stuff, and \"skip over\" the bad stuff.

Pretty cool if you ask me. So as long as the bad stuff isn\’t your entire page, you\’ll get something. Not much more I can say about that.

Next post:

Previous post: