释义 |
- Unmarshalling Dynamic Tag Library Construction Preorder and Postorder Addition XML Tag Inheritance Namespace Handling Other Implementation Details Schema and Documentation Generation
- Future Work
- See also
- External links
{{multiple issues|{{Orphan|date=May 2010}}{{Unreferenced|date=November 2010}} }}CookXml is a unique XML data binding engine in Java. It is capable of mapping XML documents of desired format directly onto the corresponding object-oriented classes, essentially treating XML as a programming language rather than merely a data storage format. Therefore, it is ideal to use CookXml to write any programs that interpret XML. The tag library of CookXml is constructed dynamically at run time, and thus allows dynamic XML schema. The current implementation has unmarshalling part done. CookXml is free software, distributed under a permissive, X11 style, licence. UnmarshallingCookXml offers the ability to directly map XML documents onto existing classes by breaking down the process into three general steps. Then use a set of delegates, together forming a tag library, to handle actions performed at these steps. - Object creation. Each element tag corresponds to an object instance. The action to create the object instance corresponds to a creator in CookXml.
- Property setting. Each attribute of the XML element corresponds to setting a property of the object instance. This property can be handled by a setter in CookXml. For languages that offer reflection, such as Java and C, such property setting can be automatically detected using reflection. In these cases, to match the string attribute value to the target property class type, a converter is necessary.
- Add action. When CookXml obtains an object corresponding to an element tag, it is "added" to the parent object corresponding to the parent element tag. The specific add action is handled by an adder in CookXml.
Except for CDATA nodes, the three above types of actions can handle all elements in an XML document. CDATA in general can be handled either in the creator function or the adder function. Creators, setters, adders, and converters together form a tag library which is used by the CookXml engine to perform the XML data binding. Dynamic Tag Library ConstructionBecause the CookXml tag library uses delegates, its tag library needs to be dynamically constructed. This feature is both good and bad. It is bad because there will be a slight initiation cost when the tag library is constructed, and its integrity may not be verified until runtime. It is good because it allows developers to easily extend an existing tag library at runtime. Preorder and Postorder AdditionLike any trees that can be traversed in preorder and postorder, the object corresponding to an XML element can be added to the parent object in preorder or postorder. In the preorder addition, the object is added to the parent before descendant XML elements get processed. In the postorder addition, the object is added to the parent after descendant XML elements get processed. XML Tag InheritanceOne discovery made while writing CookXml was that class inheritance of Object-oriented languages can be mirrored into XML element tag inheritance. Semantically, tag inheritance means that the derived tag will inherit the setters and adders of the inherited tags. For example, javax.swing.JMenu is a child class of javax.swing.JMenuItem. Assuming that javax.swing.JMenu is mapped to |