Siddharth,

Currently, the only way to handle comments is if you have a class which implements a SAX LexicalHandler (to get the comments) and a Castor UnmarshalListener (to know which object is currently being unmarshalled). You can use the org.exolab.castor.util.LocalConfiguration class to create an instance of the XMLReader so that you can configure it appropriately.

The code will look something like this (I haven't compiled this sample so there may be some typos):


myCommentHandler (implements LexicalHandler, UnmarshalListener)


XMLReader reader;

reader = LocalConfiguration.getInstance().getXMLReader():
reader.setLexicalHandler(myCommentHandler);
..
Unmarshaller unm = new Unmarshaller(...);
..
unm.setUnmarshalListener(myCommentHandler);
..
UnmarshalHandler handler = unm.createHandler();
..
reader.setContentHandler(handler);
reader.parse();
..
MyObject object = (MyObject)handler.getObject();


I know it's not pretty, but it should allow you to get access to the comments.


--Keith


Siddharth Chhabra wrote:
hi

I do not know how to unmarshal xml comments(<!-- -->).
Can I somehow get the text inside the xml comments in
some fields/Listener ? Plus the fact that they can
exist anywhere in the xml file further compounds the
problem ?

I thought I had things under control, but a change in
requirements now forces us to read these
comments(supposed to be annotations in the xml source)
and make something out of them. A search on the user
list with keywords 'unmarshal comments', and various
other permutations yielded nothing much.


If a developer/user could point me to a thread or give
me a snippet of a mapping file or explain how to g
about doing it, I would be extremely thankful.

-Siddharth

________________________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping" your friends today! Download Messenger Now http://uk.messenger.yahoo.com/download/index.html




----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user






----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user

Reply via email to