How to use JAXB / XJC to convert an XML file to an object?

I do JAXB and XJC research, but from the documentation there , including the Oracle pages and some of the questions here, I don’t think there is a clear definition of what the difference is between JAXB and XJC and how to use it to convert an XML file to an object.

So, from my understanding, JAXB is a method for XML -> Java analysis and vice versa, and xjc is one implementation for it that is included in java tools?

+5
source share
2 answers

JAXB (JSR-222) implementations convert instances of Java classes (which may contain annotations) to / from XML. XJC (XML to Java Compiler) is a utility for generating these objects from an XML schema. It is included as part of the JDK with Java SE 6.

Exanple

Here is a link to my blog demonstrating how to generate a Java model from an XML schema:

+7
source

Not sure if this is what you are looking for, but seems close ...

Use the Java architecture to bind XML (JAXB) xjc to compile the XML schema file into fully annotated Java classes.

https://www.ibm.com/support/knowledgecenter/SSEQTP_8.5.5/com.ibm.websphere.base.doc/ae/twbs_jaxbschema2java.html

+1
source

Source: https://habr.com/ru/post/1498659/


All Articles