Skip to main content

"DefaultValidationEventHandler: unexpected element" error on unmarshalling

5 replies [Last post]
tysinsh
Offline
Joined: 2003-09-15
Points: 0

Hi!

I used JAXB 2.1.1 with IMS LD schema files to generate jaxb classes. Parsing xml files, conforming to IMS LD schema, I've came across a problem which made me stuck.

The symptom is:

DefaultValidationEventHandler: [ERROR]: unexpected element (uri:"http://www.imsglobal.org/xsd/imsld_v1p0", local:"title"). Expected elements are <{}title>,<{}prerequisites>,<{}learning-objectives>,<{}method>,<{}components>,<{}metadata>

in xml file:

Introduction to the Dutch language

Learner

.....

However, IMS LD schema implies all elements are described there, and are in the same namespace, which is xmlns:imsld="http://www.imsglobal.org/xsd/imsld_v1p0", though declaration seems to be a little bit different:

- for <{}title>

for <{imsld="http://www.imsglobal.org/xsd/imsld_v1p0"}learning-design>

Suppose this bug has something in common with this one
http://forums.java.net/jive/thread.jspa?forumID=46&threadID=19136&messag...

What should I do to original schema files or whatever to make it work without changing element namespace to xmlns="" (which really solves the problem, but only for this particular title element of course)?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kohsuke
Offline
Joined: 2003-06-09
Points: 0

Can you file an issue in https://jaxb.dev.java.net/issues/ and attach the schema so that we can take a look?

I'm assuming that you've checked package-info.java.

Also, if you haven't read https://jaxb.dev.java.net/guide/Unmarshalling_is_not_working__Help_.html yet, please consider trying that.

tysinsh
Offline
Joined: 2003-09-15
Points: 0

Sorry, Kohsuke

I got confused by versions: I've made classes using Jaxb 2.1.1 command line, but then used JDK 6 built-in version to unmarshal file. I've generated classes with JDK 6 built-in version and now got everything working all right.

Thank you for reply!

Anton

kohsuke
Offline
Joined: 2003-06-09
Points: 0

Well, actually using 2.1.1 CLI for generation and running the result on JDK6 should have been just fine, provided that you put "-target 2.0" to indicate that your runtime is 2.0, not 2.1.

And even if you forgot to do that, you still shouldn't have seen this unexpected element.

I still think there's something wrong here.

tysinsh
Offline
Joined: 2003-09-15
Points: 0

Kohsuke,

I've filed the issue #320 about the case and attached zip with schema files and sample xml.

kohsuke
Offline
Joined: 2003-06-09
Points: 0

Thanks.