Xml-script is a lot better, but it still sucks a little bit...
Today I finally got a chance to play with xml-script. The current implementation is, indeed, better than the previous one. Several things have changed in this version. For starters, the interface which was used in previous versions was dropped and now type descriptor objects (used internally for parsing and instantiating elements) are added directly to a "static" property of the class called descriptor. The anonymous object added to this property lets you define which properties, methods and events can userd from xml-script. In my opinion, this is a better approach than the one used before. Here's a quick example copied from the TextBox class:
Sys.Preview.UI.TextBox.descriptor = {
properties: [ { name: 'text', type: String } ],
attributes: [ { name: Sys.Preview.Attributes.ValueProperty, value: 'text' } ]
}
In the current version, you're also free to use any variation of the name of a class that can be used from xml-script (I'm not sure if this is a good thing since XML is supposed to be case sensitive). In other words, if you want to use a Sys.Preview.UI.TextBox control from xml-script, you no longer have to call it <textBox> as happened in the previous versions. So, if you want it, you can use the word TEXTBOX or TEXTbox and everything should work without any problems. This is possible due to a change made in the internal type system and in the parsing engine. Internally, the parsing engine searches the name of the element in a list of namespaces previously registered (since each namespace maintains a list of classes, it's possible to get the type by using this new approach).
Another good news is that you can now perform the correct mapping between a prefix and a specific namespace too. This means that you can use whatever prefix you want and you aren't tied to the script prefix anymore (which, btw, is still the default prefix associated with AJAX controls).
There are still several things I don't like. First, you can still call your top level element anything you want (I've written about this in the past). Second, the current version still doesn't understand global namespaces and now you can't simply declarate a global namespace like this:
<page xmlns="....">
....
</page>
If you do this, the parser will not be able to get an internal list with the current OO namespaces associated with that global XML namespace and it won't create the elements specified inside the <components> element (this happens because currently the parser allways needs a prefix in order to get the correct list of mappings). So, if you really want to use an "AJAX" xml default namespace, you must do this:
<page xmlns:script="....">
....
</page>
Again, this is complete nonsense. Note that in xml terms, the second declaration means that script prefix is associated with a specific namespace and that the <page> element is in a global namespace. If you look at the first excerpt, it says the correct thing, ie, that the page element is defined in a global namespace identified by the xmlns attribute...I still haven't tested global custom elements. I think i'll leave that for tomorrow.