diff --git a/org.springframework.oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java b/org.springframework.oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java index 2d23572100d..12cae278baa 100644 --- a/org.springframework.oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java +++ b/org.springframework.oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java @@ -16,7 +16,7 @@ package org.springframework.oxm.jaxb; -import java.awt.*; +import java.awt.Image; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -65,13 +65,6 @@ import javax.xml.transform.sax.SAXSource; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.XMLReaderFactory; - import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.beans.factory.InitializingBean; import org.springframework.core.annotation.AnnotationUtils; @@ -94,6 +87,14 @@ import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; import org.springframework.util.xml.StaxUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.w3c.dom.ls.LSResourceResolver; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; +import org.xml.sax.helpers.XMLReaderFactory; + /** * Implementation of the Marshaller interface for JAXB 2.0. * @@ -160,6 +161,8 @@ public class Jaxb2Marshaller private boolean supportJaxbElementClass = false; + private LSResourceResolver schemaResourceResolver; + /** * Set multiple JAXB context paths. The given array of context paths is converted to a @@ -286,7 +289,17 @@ public class Jaxb2Marshaller this.schemaLanguage = schemaLanguage; } - /** + /** + * Sets the resource resolver, as used to load the schema resources. + * @see SchemaFactory#setResourceResolver(org.w3c.dom.ls.LSResourceResolver) + * @see #setSchema(Resource) + * @see #setSchemas(Resource[]) + */ + public void setSchemaResourceResolver(LSResourceResolver schemaResourceResolver) { + this.schemaResourceResolver = schemaResourceResolver; + } + + /** * Specify whether MTOM support should be enabled or not. * Default is false: marshalling using XOP/MTOM not being enabled. */ @@ -407,6 +420,9 @@ public class Jaxb2Marshaller schemaSources[i] = new SAXSource(xmlReader, inputSource); } SchemaFactory schemaFactory = SchemaFactory.newInstance(schemaLanguage); + if (schemaResourceResolver != null) { + schemaFactory.setResourceResolver(schemaResourceResolver); + } return schemaFactory.newSchema(schemaSources); }