java - JAXB - Ignore element -
is there way ignore element jaxb parsing? have large xml file, , if ignore 1 of large, complex elements, parse lot quicker.
it better if not validate element contents @ , parse rest of document if element not correct.
ex:this should generate foo.element1 , foo.element2
<foo> <element1>i want this</element1> <element2>and this</element2> <bar> <a>all of bar should ignored</a> <b>this should ignored</b> <c> <x>a lot of c take time process</x> </c> <c> <x>a lot of c take time process</x> </c> <c> <x>a lot of c take time process</x> </c> <c> <x>a lot of c take time process</x> </c> </bar> </foo>
assuming jaxb model looks this:
@xmlrootelement(name="foo") public class foo { @xmlelement(name="element1") string element1; @xmlelement(name="element2") string element2; @xmlelement(name="bar") bar bar; }
then removing bar
field foo
skip <bar/>
element in input document.
alternatively, annotated field @xmltransient
instead of @xmlelement
, , skipped.
Comments
Post a Comment