Vadiraj's Blog

My experiments with Java

XML multiview FAQ (work in progress)

Thursday Apr 26, 2007

Recently I helped Geertjan on creating a new XML multiview for x-work (here and here) related XML files. I thought why can't I convert the discussion I had with him along with known questions into a growing FAQ?

Here is it. 

  1. What is XML multiview API?
    Extension of Multiview API (which allows to create different visualizations for single files.) The XML multiview API extends the Multiview API to support for XML files. It also includes two way synchronization between the visualizations and the XML file.

     

  2. Where can I get this API?
    The API is part of the Netbeans 5.x (upwords) distribution. However, both Multiview API and XML multiview APIs are not yet stable APIs. Still the XML multiview API is used in number of places like web.xml file editing in Java EE application development.

     

  3. Are there any tutorials and samples for this?
    Yes, original Geertjan's blog entry, my tutorial series, part1, part2, and part3 :). The netbeans xml multiview source code includes a Book Example as part of the unit tests and its used in Geertjan's tutorial and as well as in my tutorial series.

     

  4. What all I can do with XML multiview API?
    Develop different kinds of visual editors for any XML file which has a well defined schema or a DTD. You can have a tree type multiview editor similar to the Windows Explorer or the WSDL editor in Netbeans Enterprise Pack 5.5. Also you can have a toolbar multiview, which allows to create multiple separate or shared views for a single file. Each view can be activated by clicking the corresponding button on the toolbar. This is the type of visual editor used in web.xml file editing. You can provide separate visual editors for each sections of XML file and you can have different visual editors for the same XML file or a section of it.

     

  5. So how do I get started?
    Read the tutorials. XML multiview requires javabeans to store/retrieve data to/from XML file. You can use schema2beans as described in the tutorial or from Toni's tutorial on schema2beans generation starting from here. You can also use any other API such as JAXB to generate beans. However, you need to update the two way synchronization accordingly. For schema2beans, it just works. The XML multiview API does not mandate or depend on any of the bean generation technologies.

     

  6. Ok, I have the beans, where is the starting point?
    The easiest way to start is by defining the custom file type support for your XML file in your module. After you create new file type support, you need to modify the generated data object to confirm to the XML multiview API. You need to extend the data object from XmlMultiViewDataObject and implement all the required methods of this class.

     

  7. What all the important methods that I need to implement from XmlMultiviewDataObject, in my existing generated data object?
    The following are the methods with their functionality outlined:
    getMultiViewDesc() - Create multiple multiviews and return an array of them.
    showElement() - Return the root element bean
    Apart from this, you need to create new multiview classes and implement ModelSychronizer and a callback method to signal the synchronization mechanism that the data has changed.
  8. Coming soon.
  9. Coming soon.

Like this post? del.icio.us | furl | slashdot | technorati | digg
Comments:

Post a Comment:
Comments are closed for this entry.