Code example for SAXSource

0
        // add our XMLFilter which disables dtd downloading 
        NamespaceFilter xmlFilter = new NamespaceFilter(parser.getXMLReader());
        xmlFilter.setContentHandler(unmarshaller.getUnmarshallerHandler());
 
        // Wrap the input stream with our filter 
        SAXSource source = new SAXSource(xmlFilter, new InputSource(in));
 
        // unmarshal the document 
        return unmarshaller.unmarshal(source);
    } 
 
    // todo Inject the proper namespace 
    public static class NamespaceFilter extends XMLFilterImpl {
        private static final InputSource EMPTY_INPUT_SOURCE = new InputSource(new ByteArrayInputStream(new byte[0]));
 
        public NamespaceFilter(XMLReader xmlReader) {
            super(xmlReader);
        } 
 
        public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
            return EMPTY_INPUT_SOURCE;