This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Rewrite DOM to JAXB: What about UserData

Sverre Moe
Ranch Hand
Posts: 110
  • 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?

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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic