| Author |
XML to Java object using JAXB
|
kc pant
Greenhorn
Joined: May 10, 2011
Posts: 13
|
|
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
Joined: May 10, 2011
Posts: 13
|
|
can any one know about it....so please help
|
 |
dileep keely
Ranch Hand
Joined: Jun 28, 2010
Posts: 91
|
|
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
Joined: Feb 03, 2007
Posts: 44
|
|
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
|
thanks & regards, Rakesh
|
 |
kc pant
Greenhorn
Joined: May 10, 2011
Posts: 13
|
|
@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
Joined: Feb 03, 2007
Posts: 44
|
|
|
Any specific reason to not to use castor??
|
 |
kc pant
Greenhorn
Joined: May 10, 2011
Posts: 13
|
|
|
our client not wnat Castor, thats why we cant use Castor.
|
 |
kc pant
Greenhorn
Joined: May 10, 2011
Posts: 13
|
|
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
Joined: Jul 22, 2011
Posts: 1
|
|
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
|
 |
 |
|
|
subject: XML to Java object using JAXB
|
|
|