users@jaxb.java.net

Unexpected element JAXB 2.0

From: Vallamshettla, Anand <Anand.Vallamshettla_at_tgslc.org>
Date: Tue, 8 Feb 2005 12:34:42 -0600

Kohsuke,

 

 Thanks for the reply.

 

 I already looked into JAXB 2.0. It did take while writing a test
program and getting it to work as things have obviously changed on how
JAXBContext is constructed and how the objects are retrieved from
unmarshall. :-)

 

 I am not getting the "Unexpected element" errors on the same things
that I used to get with JAXB 1.0. I am getting errors on some of the
choice items; but couldn't figure out why they are giving errors. Having
source code might help in debugging the problem.

 

 I added an extra tag (which is not in schema) inside a complex element;
JAXB 2.0 did go through fine reading the file but all the elements
(inside this complex element) after this extra element are not being
read properly. May be this is similar to Discard handler being used when
unexpected element is hit. What we expect is that if such unexpected
element appears in xml, throw error just on that element and go on fine
with the rest of the elements.

 

For ex:

 

<contacts>

     <HomeAddress>

            <city>dfsdf</city>

            <country>dfdsf</country>

     </HomeAddress>

     <extraTag>fdsfsdfsd</extraTag>

     <OfficeAddress>

            <city>dfsdf</city>

            <country>dfdsf</country>

     </OfficeAddress>

</contacts>

 

   When 'extraTag' is encountered, JAXB 2.0 is reporting 'Unexpected
element' as desired; but it is throwing errors on 'OfficeAddress' and
not reading it at all (as it is in the same complex element 'contacts'
that 'extraTag' is in). This whole thing is similar to what is happening
in JAXB 1.0, which is validating structure against schema. Are you guys
planning to change the implementation?

 

 When are you expecting JAXB 2.0 being available for production
releases? Will source code be released soon?

 

 Just to let you know - JAXB 2.0 is taking 3 secs now with the same XML
that took 1 sec with JAXB 1.0 (haven't tested using any performance
testing tool - just ran on my machine).

 

 

Thanks,

Anand Vallamshettla