Ralf and Werner, thanks for your time.
Best regards, *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 10/05/11 16:45, Ralf Joachim escreveu:
Hi Joao,Castor does not support any changes to mapping information during marshaling. As you seam not to be able to define a entity class to XML tag mapping prior to invocation of the marshaler Castor can not be used for your application as is. To add such a dynamic mapping feature much more time would be required than you are able to spend.Regards Ralf Am 10.05.2011 15:09, schrieb Joao Antunes:2011/5/9 Ralf Joachim <[email protected] <mailto:[email protected]>>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.Yes, kind of, I mean, it would be ok for me to make an XML mapping file (as long as I could specify a 'rule' to apply to all classes independently of their name), however, for what I understood, you can't use your own individual annotations to catch fields in classes and translate them to either XML location elements or plainly attributes.So, I would be ok with something like an XML mapping file that would map every class and would add attributes/location tags depending on the annotations i specified on the XML mapping.It would also be okay to implement this behaviour in Castor, but I already had took a brief look at the FieldDescriptor class before posting my resolution of "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" (by castor marshaller I meant plain method 1. Introspection.) because I do not know enough of the library for me to do it as easily as it would be to do that.I'll be willing to refrain from this decision and actually implement the behaviour if I get mentored. The kind of info I'm looking for is something on the lines of:* How could I use a mix between the mapping file and the runtime to specify the classes to marshal (instead of having to specify the name attribute in the class element - if that isn't already an option); * What factory/class whatever takes care of handling the field attributes in the mapping file, so, you would have to add implement this class/change this class to make sure it would grab your new field attribute called annotation... [ OR ] * How to alter the classes that do the introspection to catch my specific annotations (although this method would have to be generalized to allow a user to easily specify their own annotations and the impact on the resulting XML so that: Castor would benefit from this; I wouldn't be stuck with a patch in a frozen in time library; I could enjoy the fun to give back to the community, but that due to obvious objective constrictions I can not do things like implement the JAXB annotations)So, if you guys feel like that would be a 'feature' worth the effort of mentoring me to have on Castor, let me know what I would have to do, and I'll let you know if I would do it (if i see that it takes a week to do, guys, I'm sorry but I can't).Anyway, my offer is worth what it is, and at the end it might not have worth nothing, but still, that's all i can give ATM.Cheers 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ãoCheers Werneras 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 <tel:%2B49%207071%203690%2052> Mobil:+49 173 9630135 <tel:%2B49%20173%209630135> Fax+49 7071 3690 98 <tel:%2B49%207071%203690%2098> Internet:www.syscon.eu <http://www.syscon.eu> E-Mail:[email protected] <mailto:[email protected]> Sitz der Gesellschaft: D-72127 Kusterdingen Registereintrag: Amtsgericht Stuttgart, HRB 382295 Geschäftsleitung: Jens Joachim, Ralf Joachim-- 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
<<attachment: joao_antunes.vcf>>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email

