Hi Joao, I do not know how much you know about Castor and if I understand your requirements in all details. So let's start with a short description of the 3 modes Castor supports for marshalling:
1. Introspection Castor introspects the entities to be marshaled with reflection and generates a default XML document. 2. Mapping You pass a XML mapping file to Castor that contains information how to marshal an entity. When loading the mapping Castor internally generates descriptor instances that will hold the mapping information and will be used at marshaling. 3. Code generation You use Castor's code generator to create entities and descriptors. The descriptors hold the information how an entity has to be marshaled. As far as I understand your requirements the XML mapping file is what fits best to your needs as the information how entities are to be marshaled is provided at runtime. The only difference is, that you do not want to provide a XML mapping file but instead like to use your individual Annotations. If you could transform your individual Annotations into descriptor instances and register them somehow at Castor, the result should be something similar to what you need. Having said that Werner knows this part of Castor much better than I do. Regards Ralf Am 09.05.2011 16:20, schrieb João Antunes: > Hi Werner, > > answers below: > > *João Antunes* > > > MsC in Communication Networks Engineering > <https://fenix.ist.utl.pt/cursos/merc?locale=en_EN> at IST > <http://www.ist.utl.pt/en/about-IST/> > > Web: http://web.ist.utl.pt/~joao.a.p.antunes > <http://web.ist.utl.pt/%7Ejoao.a.p.antunes> > > E-mail: [email protected] > <mailto:[email protected]> > > LinkedIn: http://pt.linkedin.com/in/joaoapantunes > > > *Instituto Superior Técnico - Centro de Informática/Direcção de > Serviços de Informação* > > Software Engineer - FénixEDU team > > > *Proud associate of **G3SI* <http://g3si.netai.net/index.php?lang=en> > > > Em 09/05/11 14:31, Werner Guttmann escreveu: >> Hi Joao, >> >> On 09.05.2011 09:05, João Antunes wrote: >>> Hello! >>> >>> First of all, thanks for the contribute given to the O.S. community that >>> the castor lib represents; also, please accept my apologies if an answer >>> for this question already exists, meaning that I didn't search >>> thoroughly enough for it. >>> >>> I was wondering if I can use Castor to map Annotations in fields/methods >>> in Java to translate into XML location elements or XML attributes, >> No, it does not have support for XML annotations. There used to be >> active development on providing support for JAXB annotations, but that >> died off ... and to my knowledge is not finished. >> >>> e.g.: >>> -- >>> Java file: >>> [...] >>> Class YPTO { >>> @XPTOAnnotation{ yada } >>> private String stringToPersist; >>> public String getStringToPersist() { >>> [...] >>> >>> into >>> XML File: >>> <YPTO> >>> <stringToPersist XPTOAnnotation=yada>contentofthestring</stringToPersist> >>> [...] >>> or alternatively: >>> >>> <YPTO> >>> <XPTOAnnotation yada> >>> <stringToPersist>contentofthestring</stringToPersist> >>> [or] >>> <YPTO> >>> <XPTOAnnotation> >>> <yada> <!-- Or even without the YADA, I really don't need the details of >>> the annotations --> >>> <stringToPersist>contentofthestring</stringToPersist> >>> [...] >>> >>> -- >>> >>> As I could understand, the field element in the XML Mapping does not >>> support the annotations. Is there any plugin/element that I missed to >>> implement this? >> No, you have not missed anything. >> >>> My end goal is to generate XHTML using XML which came from a JavaBean, >>> the idea is to make a generic XSLT (or DVSL, whichever is easier [ I >>> guess DSVL <http://velocity.apache.org/dvsl/devel/> will be easier, also >>> if anyone has any comment about this, feel free to give a hint :)]) that >>> will pickup on the hints provided on the bean on the form of annotations >>> (I will use annotations because I guess that is the way to go here, but >>> I can go with something else if it's easier to implement ) to render the >>> XHTML using a predetermined 'XHTML template'. >>> >>> In case a plugin doesn't exist, any info on how I should do this? >>> writing a plugin/patch to the lib to implement this behaviour might be >>> what I end up doing, ... >> Hmm, why not invest the time in trying to finish the support for the >> JAXB annotations ? >> >> I guess that's not the answer you've been looking for (at least not >> precisely), but let's see what you think of my answers. > Because I'm not sure that JAXB annotations are what I need. Actually I > just checked them and I think it wouldn't solve the problem I have. > Also, quite bluntly speaking, I have a full stack of projects to work > on, unfortunately even my O.S. library is being neglected ATM, so, > sorry, no time for that. > > It seems that the way for me to go is to use Castor marshaller and > then get all of the annotations of the class and iterate through the > XML DOM to add the XML attributes. I'll post the solution as soon as I > have implemented it for whomever who might be interested in doing > something similar and runs into this thread. > > Cheers, > João >> Cheers >> Werner >> >>> as long as it's less time consuming than the >>> alternative which is to define a XSD and use JAXB and a generic >>> algorithm to interpret beans [which castor already does] and its >>> annotations [which is what it would be perfect if castor already did >>> had :)]. >>> >>> Thanks in advance, >>> João Antunes >>> >> --------------------------------------------------------------------- >> To unsubscribe from this list, please visit: >> >> http://xircles.codehaus.org/manage_email >> >> > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email -- Syscon Ingenieurbüro für Meß- und Datentechnik GmbH Ralf Joachim Raiffeisenstraße 11 72127 Kusterdingen Germany Tel. +49 7071 3690 52 Mobil: +49 173 9630135 Fax +49 7071 3690 98 Internet: www.syscon.eu E-Mail: [email protected] Sitz der Gesellschaft: D-72127 Kusterdingen Registereintrag: Amtsgericht Stuttgart, HRB 382295 Geschäftsleitung: Jens Joachim, Ralf Joachim

