Andy,
thanks, the wiki is back up. maybe I need to change something in the
digester (but I don't know what and how) but it's a problem that betwixt
does not send any error/exception/warning in the following example:
I have an XML that looks like this:
<me>
<a/>
<b/>
<c/>
</me>
and the bean mapped to this guy does not know about b, then I have no
error, no message, my bean is just screwed up (I only have a value for
a), which is a pb because I am not notified that there was a pb and that
c could not be mapped.
it is even worst when I have 2 elements <me> like this
<me>
<a/>
<b/>
<c/>
</me>
<me>
<a/>
<b/>
<c/>
</me>
in that case, I have absolutely nothing in the beans. what I would like
to do is handle it in my code, but if I don't get notified that
something went wrong I can't do anything. it seems to me that it's a
problem in betwixt to not report a problem by throwing an exception for
example. betwixt should be able to tell me that something went wrong.
don't you think?
thanks for your help!
Nathalie
[EMAIL PROTECTED] wrote:
Nathalie,
Okay - so you have some input XML like:
<root>
<element a="A" b="B" c="C" />
</root>
or
<root>
<A/>
<B/>
<C/>
</root>
You're reading in this input xml file and you're getting an error
because your
class has no property mapping for the attribute 'b' or element 'B'.
Is that correct?
One sort of mindless approach (a hack, kludge, etc) would be to
subclass you
mapping class and the property for B - just to get this to read in.
This class
serves the role of the superclass - and that'll filtering out B while
getting
your the information you need. That's a quick fix - which I'd likely be
attacked for suggesting if more people read the Betwixt questions (not
say they
don't - just not too many seem to answer them if they are reading).
Question: will you have to output your mapped beans in this XML format?
If there answer is 'No', then you would likely want to look at what
Betwixt is
built on: Digester. If that's a 'Yes' - then you'd like to take in this
information to output later. I'm assuming since you're looking to
filter out
the input XML - the answer is 'No.'
So - Betwixt is built on Digester. Digester uses a set of rules to
specify the
mapping from xml elements and attributes into beans. Betwixt is
generating
these rules for you in a custom ruleset (BeanRuleSet). I believe that
what you
want to do would be look at how you define Rules in Digester to ignore
this.
And that makes sense because you originally asked the question about both
Digester and Betwixt.
I'd take a stab at what you need to do in Digester but their Wiki is
down right
now =( The Advanced "Reading Beans" section for Betwixt mentions
"Adding Custom
Digestion Rules" :
http://commons.apache.org/betwixt/guide/reading.html (but the
section just sort of points you to the Digester page, which is rather
thin - it
looks like the meatier content is on the wiki, again, which is down).
I'd look
at that. I haven't delved into Digester so I can't offer much help
Eventually - the wiki should be back up at some point:
http://wiki.apache.org/commons/Digester
Sorry I can't offer a full solution.
Andy
Quoting Nathalie Doremieux <[EMAIL PROTECTED]>:
Andy,
thanks for your answer but I need to be able to ignore fields on the
XML side, not on the bean side.
I think I can better explain with an example
My bean has 2 elements
A
C
my XML has 3 elements
A
B
C
with that configuration I would like to be able to read A and C into my
bean, but right now I only get A. I basically would like to be able to
tell betwixt to ignore B in the XML as it does not map to anything in
the bean. Is that possible? I know I can also write an XML validator and
make sure my XML is the right format, but if there is a solution within
betwixt it would be nice to know!
thanks for you help!
Nathalie
/****************************************
* @author: Andrew Lenards
* @email: [EMAIL PROTECTED]
* @title: Systems Programmer, Principal
* @project: Tree of Life Web Project
* @website: http://tolweb.org/
* @dept: Dept. of Entomology
* @school: University of Arizona
* @geo-loc: Tucson, AZ 85721
***************************************/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Nathalie Doremieux
New Software Marketing
www.newsoftwaremarketing.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]