14.07.2013 Views

Contents - Cultural View

Contents - Cultural View

Contents - Cultural View

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CookXml 107<br />

Creators, setters, adders, and converters together form a tag library which is used by the CookXml engine to perform<br />

the XML data binding.<br />

Dynamic Tag Library Construction<br />

Because CookXml tag library uses delegates, its tag library needs to be dynamically constructed. This feature is both<br />

good and bad. It is bad because there will be a slight initiation cost when the tag library is constructed, and its<br />

integrity may not be verified until runtime. It is also good because it allows developers to easily extend an existing<br />

tag library at run time.<br />

Preorder and Postorder Addition<br />

Like any trees that can be traversed in preorder and postorder, the object corresponding to an XML element can be<br />

added to the parent object in preorder or postorder. In the preorder addition, the object is added to the parent before<br />

descendant XML elements get processed. In the postorder addition, the object is added to the parent after descendant<br />

XML elements get processed.<br />

XML Tag Inheritance<br />

One discovery made while writing CookXml was that class inheritance of Object-oriented languages can be mirrored<br />

into XML element tag inheritance. Semantically, tag inheritance means that the derived tag will inherit the setters<br />

and adders of the inherited tags.<br />

For example, javax.swing.JMenu is a child class of javax.swing.JMenuItem. Assuming that javax.swing.JMenu is<br />

mapped to tag and javax.swing.JMenuItem is mapped to tag, then we can declare in CookXml<br />

that tag inherits tag. tag then inherts the setters for attributes such as "text" and "icon"<br />

of the tag.<br />

Polymorphisms of OOP can be mirrored in XML tag inheritance as well. Class casting is similar to dynamically<br />

renaming the current namespace and the tag of the element being processed.<br />

XML tag inheritance is a methodology not present in any other XML data binding tools. This feature is immensely<br />

useful in mapping XML documents to classes with deep inheritance hierarchy, typically found in GUI API. Thus<br />

CookXml is useful in writing XUL motors. CookSwing and CookSwt are two such examples for mapping XML<br />

documents to Swing and SWT classes.<br />

Namespace Handling<br />

Since version 3.0, CookXml is capable of dealing XML documents with multiple namespaces. For backward<br />

compatibility, CookXml also parse XML documents without namespaces or partially utilizing namespaces.<br />

Other Implementation Details<br />

As of version 3.0, CookXml operates on top of XML DOM tree to map an XML document to objects. This feature<br />

allows developers to utilize XML schema if such exist to verify the incoming XML documents. On the other hand,<br />

the memory consumption for a large XML document can be problematic.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!