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.
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