diff --git a/src/mdo/reader-stax.vm b/src/mdo/reader-stax.vm index 4b30a6a9b7..9850149d69 100644 --- a/src/mdo/reader-stax.vm +++ b/src/mdo/reader-stax.vm @@ -348,6 +348,15 @@ public class ${className} { DEFAULT_ENTITIES = Collections.unmodifiableMap(entities); } + static class InputFactoryHolder { + static XMLInputFactory XML_INPUT_FACTORY; + static { + XMLInputFactory factory = XMLInputFactory.newFactory(); + factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false); + XML_INPUT_FACTORY = factory; + } + } + private boolean addDefaultEntities = true; #if ( $locationTracking ) private boolean addLocationInformation = true; @@ -363,6 +372,15 @@ public class ${className} { this.contentTransformer = contentTransformer; } + /** + * Returns the {@link XMLInputFactory} used by this reader. + * + * @return the {@link XMLInputFactory} used by this reader. + */ + public XMLInputFactory getXMLInputFactory() { + return InputFactoryHolder.XML_INPUT_FACTORY; + } + /** * Returns the state of the "add default entities" flag. * @@ -421,13 +439,12 @@ public class ${className} { #else public ${root.name} read(Reader reader, boolean strict) throws XMLStreamException { #end - XMLInputFactory factory = XMLInputFactory.newFactory(); - factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false); #if ( $locationTracking ) StreamSource streamSource = new StreamSource(reader, source != null ? source.getLocation() : null); #else StreamSource streamSource = new StreamSource(reader); #end + XMLInputFactory factory = getXMLInputFactory(); XMLStreamReader parser = factory.createXMLStreamReader(streamSource); #if ( $locationTracking ) return read(parser, strict, source); @@ -458,13 +475,12 @@ public class ${className} { #else public ${root.name} read(InputStream in, boolean strict) throws XMLStreamException { #end - XMLInputFactory factory = XMLInputFactory.newFactory(); - factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false); #if ( $locationTracking ) StreamSource streamSource = new StreamSource(in, source != null ? source.getLocation() : null); #else StreamSource streamSource = new StreamSource(in); #end + XMLInputFactory factory = getXMLInputFactory(); XMLStreamReader parser = factory.createXMLStreamReader(streamSource); #if ( $locationTracking ) return read(parser, strict, source);