Srinivasan Chikkala <srinivasan.chikkala_at_sun.com> wrote:
> I want to edit/add/remove the XML comments in the XML Content
> unmarshaled/marshaled by JAXB. Is there any option in xjc / schema
> bindings so that it generates the java objects corresponding to the XML
> Comments ? or any other approach to do this.
Comments can go anywhere, so exposing those really doesn't fit well with
strongly-typed world of JAXB. You really need to go down to the infoset
level if you need that kind of thing.
If you are in a position to define a schema by yourself, you could
introduce a <comment> tag instead of <!-- XML comment -->. This will
make it easy to programmatically handle those. I mean, if you are not
writing an XML editor and yours is reading and writing comments, that
doesn't sound like a good use of comments to me.
Or if you know exactly where your comment must go (like the case of the
other guy a few weeks ago), you could use a marshaller to insert it.
regards,
--
Kohsuke Kawaguchi 408-276-7063 (x17063)
Sun Microsystems kohsuke.kawaguchi_at_sun.com