Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML to Java object using JAXB

 
kc pant
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello all,

in my assignment...my tl gave me a xsd and xml file and told me to parse it using SAX parser after that i have to use JAXB to validate and to Get object of XML file into list.

can any one tell me how it should be done


thanks
i am using jdk 1.5 with Oracle Jdeveloper
 
kc pant
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can any one know about it....so please help
 
dileep keely
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didnt get what you meant by "JAXB to validate and to Get object of XML file into list"?
Do you mean
XML&xsd -->SAX-->Object-->JAXB-->XML ?
 
rakesh kumar nampally
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

you can use castor xml mapping for creating java objects from xml. jaxb is some what heavy framework when compared to castor.

i personally recommend castor xml mapping
 
kc pant
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@dileep keely i have to use XSD and i want to get classes and interfaces from that xsd after that i have to validate xml with this xsd and get object of that xml
@Rakesh we cant use caster bet if you know abot xjc then please help me how to use it because i search in net and i installed wsdp 2.0 after that i set classpath for xjc and if i am going to use it through command prompt ( eg path of xjc.bat \xjc.bat -p packagenae xyz.xsd) and i am not getting claases and interfaces . and i am geeting illegal argument error

i hope now you people able to understand it better...
 
rakesh kumar nampally
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any specific reason to not to use castor??
 
kc pant
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
our client not wnat Castor, thats why we cant use Castor.
 
kc pant
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi everyone, can somebody help ...

I have install JWSDP 2.0 on my Windows XP PC. Also I have JDK 1.5
installed

When I run the following command:

Xjc.bat c:\nims-ws\t.xsd

I get the following error

parsing a schema...

compiling a schema...

Exception in thread "main" java.lang.IllegalArgumentException: Expected
class ja

vax.xml.bind.annotation.XmlAccessType but found class
javax.xml.bind.annotation.

 
Jt BoulderCo
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JAXBBuilder Eclipse Plugin makes this task trivial (POJO from XSD), and there is a YouTube tutorial on it that teaches you how to use it in about 7 minutes. I fed it a 600 line XSD and it did not flinch.

If that YouTube hyperlink below gets scraped out for some reason (policy, etc), then search Google (NOT YouTube - won't show up there!) for this term:

"jaxbbuilder eclipse plugin tutorial viewstreet"

See the YouTube here: http://www.youtube.com/watch?v=8jqf0ME6Y1Q
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic