*
The moose likes XML and Related Technologies and the fly likes problem to unmarshal xml file who have element with prefix Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "problem to unmarshal xml file who have element with prefix" Watch "problem to unmarshal xml file who have element with prefix" New topic
Author

problem to unmarshal xml file who have element with prefix

mark smith
Ranch Hand

Joined: Apr 05, 2005
Posts: 246
hi

with jaxb, i try to read an xml file only a few element in xml file are interesting me, so i would like to skip many element
in class, only field i want exist



my class



before i unmarshal, i put a validation handler i get


if i don't put this validation, no error... but when i check objects value, TimeSeries is null

maybe the problem is the flx prefix?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Based on the actual error message you posted, I don't know how you could come to that conclusion. The error message rather clearly says it expected a TimeSeries element in no namespace but instead it found a DocumentHeader element in the namespace represented by your "flx" prefix.

So that's the first problem. Your document has a DocumentHeader element which the class doesn't describe.

However it looks to me like you are going to have a namespace problem. The error message does say it's expecting a TimeSeries element in no namespace, but the TimeSeries element in your document is in a namespace. Perhaps you have to mention that fact in your class?
mark smith
Ranch Hand

Joined: Apr 05, 2005
Posts: 246
Paul Clapham wrote:Based on the actual error message you posted, I don't know how you could come to that conclusion. The error message rather clearly says it expected a TimeSeries element in no namespace but instead it found a DocumentHeader element in the namespace represented by your "flx" prefix.

So that's the first problem. Your document has a DocumentHeader element which the class doesn't describe.

However it looks to me like you are going to have a namespace problem. The error message does say it's expecting a TimeSeries element in no namespace, but the TimeSeries element in your document is in a namespace. Perhaps you have to mention that fact in your class?


like i said, only a few element in the xml interest me.... DocumentHeader don't
are we oblige to put every element of the xml in the class?

i come to this conclusion because if i remove prefix of every element in the xml and change my root header for


that work fine.....

i tried to add namespace in my TimeSeries class in the XmlRootElement, i have no error but my TimeSeries class is null
 
 
subject: problem to unmarshal xml file who have element with prefix
 
Similar Threads
InvalidMappingException
JAXB does not generate @XmlRootElement
Clarification Requested - XML recordset & JAXB classes
JAXB and marshalling
jax-ws complex nested type is killing me