File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Rewrite DOM to JAXB: What about UserData

 
Sverre Moe
Ranch Hand
Posts: 110
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm rewriting an application which is using DOM to parse XML and replacing it with JAXB.

However the application is making use of the get/setUserData(String) on org.w3c.dom.Element to associate a Java object to the XML element.

Object org.w3c.dom.Node.setUserData(String key, Object data, UserDataHandler handler)

Associate an object to a key on this node. The object can later be retrieved from this node by calling getUserData with the same key.


Is there a solution to do this with JAXB?

Example:
JAXBElement<Widget>
Attribute:class
The userdata associated with the XML DOM element is the class defined in this attribute for this XML element.

My JAXB objects are generated from XML Schema. Perhaps I could modify the JAXBElement Widget to contain the base class for the class defined in the attribute.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic