Lists Home |
Date Index |
Isn't there a problem with the example? The document has two asset
elements within the quote element (probably could have any number), yet
your hypothetical getAssetName() method seems to assume only one asset.
Other than that, your general approach (generate with JAXB, use
introspection over the generated classes to produce a wrapper class) is
probably ok, just not as simple as you may suppose. First thing to do is
generate some code with JAXB from your schema and read the generated code.
Oswald Campesato wrote:
> Hello, everyone:
> I need to dynamically generate a Java class that
> will expose a methods for each element of a given
> XML document.
> For example, suppose I have this XML document:
> I need to generate a Java class with the following:
> public String getQuoteName()
> public String getAssetName()
> public String getAssetLoc()
> where 'quote' is a JAXB-based instance of a
> Java class corresponds to an unmarshalled
> instance of the preceding XML document.
> The Java wrapper class needs to be generated
> each time an XSD is modified, and it will be
> invoked by a third-party product in order to
> modify the contents of an XML document.
> I was thinking of using JAXB 2.0 to generate the
> Java binding classes associated with an XSD, and
> then use introspection to determine the existing
> methods, and then iterate over those methods to
> generate the Java wrapper class.
> Does this seem like a good approach, or is there
> a more 'elegant' approach? Hopefully this makes