In the below scenario, I have a marshaller that picks one object & validate against an xsd. I need to map this Request object to multiple xsds within one marshaller.
<bean id="jaxbMarshallerForCOTRequestObject" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
<value>com.fidintl.retail.myProject.model.th.Request</value>
</list>
</property>
<property name="schema" value="classpath:internal/test1.xsd"></property>
<property name="validationEventHandler" ref="ceFeedXmlValidationEventHandlerService"></property>
<property name="marshallerProperties">
<map>
<entry key="jaxb.encoding">
<value>ISO-8859-1</value>
</entry>
</map>
</property>
</bean>
Can somebody provide how? I tried using <schemas>
tag but it didnt work for me.
I have done this in java instead of xml using the method setSchemas of Jaxb2Marshaller and it works fine for me.
Jaxb2Marshaller jaxb2Marshaller = new Jaxb2Marshaller();
jaxb2Marshaller.setPackagesToScan(""); //mention packages here
ClassPathResource xsdONE = new ClassPathResource(""); //path to first xsd
ClassPathResource xsdTWO = new ClassPathResource(""); //path to second xsd
jaxb2Marshaller.setSchemaLanguage(XMLConstants.W3C_XML_SCHEMA_NS_URI);
jaxb2Marshaller.setSchemas(xsdONE, xsdTWO);
jaxb2Marshaller.afterPropertiesSet();
PS I know it is an old post, but I was searching for the answer some time back and stumbled upon this post. I was able to find the answer after googling a bit and then trying it out so thought it might help someone looking for an answer.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.