Dennis Sosnoski wrote:

In the meantime, John, you can use an optional empty <structure/> to recognize and discard a particular element name when unmarshalling without generating anything when marshalling. See the table at the top of http://jibx.sourceforge.net/details/structure-element.html for details.

Yes, I pointed to this option in my mail as well. This already saved our day in using JiBX...




It's not as simple as it might appear, Falk. The issue is that JiBX makes use of element ordering in combination with a pull parser to improve unmarshalling performance. Because of this, JiBX always wants to know what to expect next.

ok, I see why its not supported yet.

However, there may be a chance that You only THINK its not trivial while there still is a trivial solution to it (at least in the unordered/optional cases).

Lets call the mode JiBX would need 'relaxed' and lets assume that 'relaxed' implies 'unordered' or 'optional'.

JiBX already certainly IS able to skip above unknown elements when encountered as childs of an unmapped element (the empty <structure/>). This skipping does probably happen inside the pull parser.

I do not know how You handle unordered elements. Anyway, it somehow must be easy to proceed as follows ('OLD' is what I think JiBX is already doing now).

(1) OLD: call next() in the pull parser API
(2) OLD: inquire the tag name for a START_TAG event, if in 'unordered'/'optional'/'relaxed' mode
(3a) OLD: pull the element
(3b) or OLD: skip the element when optional
(3c) or OLD: skip the element when mapped to empty <structure/>
(3d) or NEW: skip the element when in 'relaxed' mode
(3e) or OLD: throw exception if expected element not found.



It should be easy when You combine such a 'relaxed' mode with something JiBX already has, like 'optional' or 'unordered'.


I just couldn't find the right location in your source code. It should really be as easy as adding two lines of code or so. Just add condition (3d).



On the political side, I am certain that a Java-centric approach must be able to "pick" isolated information out of bloat-XML. JiBX should not require to know every little detail to create a valid binding.xml. Otherwise, I could directly create an XML schema and generate a binding out of it. Something that many JiBX users exactly do NOT want to do, I guess.


It may be possible to provide a "skip unbound elements" feature in the future, but I'm going to need to think it through carefully to make sure I don't end up with something that only works part of the time. The basic approach would be to have the methods in the UnmarshallingContext that match an element name be smart enough to skip over things that don't match. This would need to include both the start tag and end tag matching code. Since I'd suspect most users want the existing behavior

(3d) means that You switch dynamically into (3c) for the present tag. This assumes that the tag name is a dynamic property of an "empty <structure/>"-descriptor. The end tag code would not change if it works on a stack of mapping descriptors.



(throw an exception on anything unexpected), I'll also need to make this pluggable. Perhaps I'll combine it with a pluggable parser implementation, so that StAX parsers can be used in place of XMLPull parsers. In any cases, it's not a trivial change.

This feature should not in any way depend on choice of parser etc. It should then also work for DOM trees, BTW. I think it just is a sub-mode of unordered.



I am not the expert. Still, my intuition tells me that it should be trivial... If I can be of any help in actually implementing this feature, I would be glad to get a pointer where step (3c) is implemented in the current code.


Regards,
Falk



-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
jibx-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to