File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 250
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: 18987
    
    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: 250
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem to unmarshal xml file who have element with prefix