Triligon / Projects / Xinha and ezxhtml / How it works




How it works

This is a short yet technical description of how ezxhtml was implemented.

Basically, I started with ezxmltext and once I had seen the >4000 lines it's comprised of (mostly parsing and validation of XML, most not using DOM), I decided that there gotta be a simpler way and started overriding the input and output handlers (from all I know, OE and XMLarea do that, too).

First mission was to get links working which is relatively easy (everything that contains eznode:// or ezcontent:// as href needs a new href, done [for editor support, the editor data will remain unchanged)).

embed is much harder. After some pondering and messing around with it, I have decided to simply replace nodes with the embed template they refer to. Yes that does mean that nested embed wont work but so far, I haven't really come up with an use case for that. The doc on the site claims it works with the original ezxmltext to some degree but what it is good for, I don't know. 

For both things, instead of parsing the whole XML tree in a sax like manner, I decided to simply use getElementByTagName and do my dirty work with it. That works quite well, really.

As for tags, if those contain a src eznode or ezcontent id attribute, it will be replaced with an embed (but with type="image" set so we can convert it back for the editors), too. On the output, the embed tempalte for images will be used as well.