[OpenAjaxIDE] Move 'managed' from <properties> to <property>

Jon Ferraiolo jferrai at us.ibm.com
Mon Sep 14 11:49:22 PDT 2009



BACKGROUND - IMPLEMENTATION EXPERIENCE
---------------------------

As Javier was working on the open source widget loader, (building on prior
work by Adam) he came up with an elegant, fast, general, and extensible
approach for converting OAM XML files into JavaScript objects. Details:

* Arbitrary XML attributes map (no matter whether defined in the spec or
not) to JavaScript properties, which is nice  because we get XML namespace
extensibility for free.
* For sub-elements, we needed to create a small table that lists the
plural/singular element combinations (e.g., properties/property), and from
that he could convert any elements in the table into a JavaScript array
property.

For example, the following XML:

<widget ...>
  <properties>
    <property name="a"/>
    <property name="b"/>
  </properties>
</widget>

could be represented in JavaScript/JSON as follows:

var widget = {
  property: [
    a: {...},
    b: {...},
  ]
}

Note that the JSON representation is really handy if you have a
browser-based widget system. In fact, a web-based tool probably will want
to convert XML to JSON either at design time or at run-time on the server
(with caching, of course) so that the client doesn't have to parse XML.


THE WEIRD ATTRIBUTE: 'managed'
---------------------------

The widget parsing code is reasonably tight and compact, but when marching
through the spec, we discovered one attribute that is different that the
rest: the 'managed' attribute on the <properties> element. We had to
special case this attribute. It applies to all of the child <property>
elements but is specified on the parent <properties> element. Therefore,
our code ends up putting an "_managed_" property onto each property. For
example:

<widget ...>
  <properties managed="true">
    <property name="a"/>
    <property name="b"/>
  </properties>
</widget>

becomes the following in JavaScript/JSON:

var widget = {
  property: [
    a: { "_managed_": true, ...},
    b: { "_managed_": true, ...},
  ]
}


PROPOSAL: Move 'managed' from <properties> to <property>
---------------------------

Has anyone implemented the 'managed' attribute? If not, can we remove it
from <properties> and put it on <property>?

Jon


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://openajax.org/pipermail/ide/attachments/20090914/694ec374/attachment.html 


More information about the IDE mailing list