condor888
asked on
How to populate Java objects from XML given the xsd schema?
Given that I've already know a very complicated XML schema in xsd (such as https://github.com/mtconnect/schema/blob/master/MTConnectAssets_1.3_1.0.xsd) How can I create the appropriate Java classes to represent the data which I convert from XML files following that xsd?
What tools and techniques may I use to fulfil that requirement?
Should I create the Java classes to represent the data manually or is it possible to use some tool to generate those Java classes?
What tools and techniques may I use to fulfil that requirement?
Should I create the Java classes to represent the data manually or is it possible to use some tool to generate those Java classes?
ASKER
That is a very helpful comments.
I saw different ways to parse XML using Java, such as JAXB, JAXP, DOM and SAX API. Would you please help me to compare those?
I saw different ways to parse XML using Java, such as JAXB, JAXP, DOM and SAX API. Would you please help me to compare those?
"Parsing" and "Binding" are two different things.
JAXP (Java API for XML Processing) This is the set of XML API's in Java used to parse an XML document using things like DOM and SAX.
JAXB (Java Architecture for XML Binding) is an API used to bind XML documents to a java object model.
JAXP (Java API for XML Processing) This is the set of XML API's in Java used to parse an XML document using things like DOM and SAX.
JAXB (Java Architecture for XML Binding) is an API used to bind XML documents to a java object model.
ASKER
@gurpsbassi thanks for your answer.
So when is the best scenario to use XML binding instead of just parsing it?
How can I persist the java object that we unmarshal from XML using relational database?
So when is the best scenario to use XML binding instead of just parsing it?
How can I persist the java object that we unmarshal from XML using relational database?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry about the confusion and thanks again for your patience.
From this you can create a JAXB object model using the XSD.
Type xjc -help to see all the possible options.