What are the steps getting an (model) object from an XML file?
Given an XSD and JAXB dependency at Spring 3, built with Maven using Java 1.6.
Note: I am new to Spring and that technologies.
What I tried
I put that dependency (can I use a newer version):
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-oxm-tiger</artifactId>
<version>1.5.4</version>
</dependency>
and that
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<executions>
<execution>
<id>generate-oxm</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaDirectory>src/main/resources/META-INF/xsd</schemaDirectory>
<generatePackage>com.aaa.xjc</generatePackage>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
to my POM file.
I made a class like that:
@Configuration
public class XmlAdapter {
@Autowired
private ResourcePatternResolver resourceResolver;
@Bean
public Jaxb2Marshaller oxmMarshaller() throws IOException {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath("com.aaa.xjc");
marshaller.setSchemas(resourceResolver.getResources("classpath:/META-INF/xsd/*.xsd"));
return marshaller;
}
}
Problem
Actually I didn't understand that context path and how to call that oxmMarshaller method.
How can I use my existing XSD to validate them? I tried that according to my previous question: Xml to Object java Spring 3