Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I recently used Spring OXM &amp; JAXB for that. The class is <code>org.springframework.oxm.jaxb.Jaxb2Marshaller</code>. You can, ofcourse, use any other implementation of <code>org.springframework.oxm.Unmarshaller</code>.</p> <p>But first You'll need to generate the objects based on Your XSD. For that I used <code>maven-jaxb2-plugin</code>.</p> <pre><code>&lt;plugin&gt; &lt;groupId&gt;org.jvnet.jaxb2.maven2&lt;/groupId&gt; &lt;artifactId&gt;maven-jaxb2-plugin&lt;/artifactId&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;generate-oxm&lt;/id&gt; &lt;goals&gt; &lt;goal&gt;generate&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;schemaDirectory&gt;src/main/resources/META-INF/xsd&lt;/schemaDirectory&gt; &lt;generatePackage&gt;com.stackoverflow.xjc&lt;/generatePackage&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; </code></pre> <p>And then configure the marshaller:</p> <pre><code>@Configuration public class ApplicationConfiguration { @Autowired private ResourcePatternResolver resourceResolver; @Bean public Jaxb2Marshaller oxmMarshaller() throws IOException { Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); marshaller.setContextPath("com.stackoverflow.xjc"); marshaller.setSchemas(resourceResolver.getResources("classpath:/META-INF/xsd/*.xsd")); return marshaller; } } </code></pre> <p>Than just:</p> <pre><code>File xmlFile = new File("my.xml"); Source source = new StreamSource(new FileInputStream(xmlFile)); JAXBElement&lt;MyXmlRootElemClass&gt; result = oxmMarshaller.unmarshal(source); MyXmlRootElemClass theObject = result.getValue(); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload