Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

XML to Java object using JAXB

 
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
 
Ranch Hand
Posts: 112
  • 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 ?
 
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.

 
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
 
Water proof donuts! Eat them while reading this tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic