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, 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?
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, 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