ignore obligatory element

34 views
Skip to first unread message

Paulo "JCranky" Siqueira

unread,
May 2, 2012, 3:42:12 PM5/2/12
to sca...@googlegroups.com
Hi,

Is there someway to tell scalaxb to ignore non-present obligatory elements from doing scalaxb.fromXML - instead of it trowing a parser error?

thanks!

[]s,

--
Paulo "JCranky" Siqueira
Visit my blog: http://www.jcranky.com/

Paulo "JCranky" Siqueira

unread,
May 3, 2012, 1:45:13 PM5/3/12
to sca...@googlegroups.com
If it helps somehow, my scenario is that I'm receiving incomplete xml data and I want to parse it into scala "beans", fill in some of the missing information, and transform it back to xml.

[]s,

2012/5/2 Paulo "JCranky" Siqueira <paulo.s...@gmail.com>

eugene yokota

unread,
May 3, 2012, 1:49:27 PM5/3/12
to sca...@googlegroups.com
If I ignore non-existent required elements, I won't be able to populate the case class.
The point of using data binding tool is to be true to the schema, so unless there's a really good compelling case, I don't see scalaxb supporting that. Do you have specific scenario that requires this?
If the real life data provided by the service does not conform to its advertised schema, then you you either contact the service provider or modify the schema manually.

-eugene

Paulo "JCranky" Siqueira

unread,
May 3, 2012, 1:58:50 PM5/3/12
to sca...@googlegroups.com
Your point makes sense. Maybe I'll have to find a way around scalaxb to support this case. This is what happens:

Party A advertises the schema. And I (lets say party B) Will send fully compatible data. Now, to do that, party C will send B part of the information. B will fill in the blanks and send a full xml to A. Something like:

C -> B -> A

And B won't call A immediately. So the xml might be saved and read and saved again a few times before it is ready to be sent to A.

[]s,

2012/5/3 eugene yokota <eed3...@gmail.com>

eugene yokota

unread,
May 3, 2012, 6:36:21 PM5/3/12
to sca...@googlegroups.com
ok. That makes sense.
In this case, I'd suggest party B makes more relaxed schema under a different namespace.
And B can translate between case classes and send to A.

-eugene

Paulo "JCranky" Siqueira

unread,
May 5, 2012, 11:57:14 AM5/5/12
to sca...@googlegroups.com
Thanks Eugene =)

Usually having two different beans for the same thing would be boring to handle... then it came to mind that I could use scala's Either. I guess the result will be nice.
Reply all
Reply to author
Forward
0 new messages