It probably makes little difference to your code whether you read the XML file once or multiple times. (It affects performance, but that's not the real issue. And you should be able to switch between the two approaches with little effort.)
The real issue is how your rendering code accesses the information (in a sense, metadata) represented by the XML. You have a number of alternatives. For example:
- Your rendering code could use the W3C DOM APIs directly (or jdom, dom4j, etc) to access access the metadata ... as it goes.
- You could write some extra code to turn the DOM into an in-memory data structure with nicer interfaces.
- You could to the same, but using a SAX parser to build the data structure.
- You could use some technology like EMF to generate custom Java classes from your XSD, and then load them.
Which is best rather depends on the complexity of your XML (or more precisely, its schema), and how much of your rendering code needs to "touch" the metadata. Generally speaking, the greater the complexity and the more your code depends on it, the more you need to move away from using the DOM directly.