Hello,
I just started to use betwixt for reading XML into JavaBeans (is that 
called de-serialization?).
I'm using version 0.6 which appears to be a bit outdated. Nevertheless I 
would like to give
some comments:

Simply mapping XML elements into JavaBeans works impressivley well. In 
fact I really had
trouble to understand the code I need to analyze because everthing appears 
to happen 
"automagically".

My problem starts when doing something "not straightforward". It's 
probably quite simple
for the experts I guess. All I want to have is a mapping between 

<project>
  <dependency alias="LOG4j">
    <version>1.2.8<version>
  <dependency />
 </project> 
 
and this Bean:

class Dependency {
  ..
  void setAlias(String s) { .. }
  void setVersion(String s) { .. }
};
 
In other words, the attribute 'alias' shall be mapped to 'setter' 
setAlias(). 

I assume that I need to create a file "Dependency.betwixt" - the 
documentation does not
really explain this very well.  For  example,  the tutorial in [1] just 
mentions a ".betwixt"
file but will it  be a  "Channel.betwixt"  or  a  "RSS.betwixt"?? Note 
also  that  there's  no
".betwixt" file (whatsoever) in the tutorial's source code directory [2] 
(!).

Let's assume now that "Dependency.betwixt" is ok. What should be in this 
file??

=> A plain empty file creates an Exception. Why? Wouldn't it be better to 
apply to have 
    a standard mapping this case?  There's  not  a  big difference between 
an empty file
    and a non-existing file (at least not for me).

=> I'm getting similar exceptions in this cases:
    a. only <xml> header
    b. <info/>

=> I would have expected a kind of warning in this case:

    <?xml version="1.0" encoding="UTF-8" ?>
    <info>
      <element name="non-existing-element">
        <addDefaults/>
      </element> 
    </info>

Another thing which is not entirly clear is what should be the 'root' 
element for Dependency.betwixt?
Should it  be:

    <?xml version="1.0" encoding="UTF-8" ?>
    <info>
      <element name="project">
         [..]
      </element> 
    </info>

or should it be

    <?xml version="1.0" encoding="UTF-8" ?>
    <info>
      <element name="dependency">
         [..]
      </element> 
    </info>

When looking at the tutorial [1] the latter seems to be the case (and this 
appears to be "logical") but
it's not well explained.

Cheers,
Wolfgang.


[1] http://jakarta.apache.org/commons/betwixt/guide/tutorial.html
[2] 
http://jakarta.apache.org/commons/betwixt/xref-test/org/apache/commons/betwixt/examples/rss/



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to