Example usage for org.xml.sax.helpers XMLFilterImpl setContentHandler

List of usage examples for org.xml.sax.helpers XMLFilterImpl setContentHandler

Introduction

In this page you can find the example usage for org.xml.sax.helpers XMLFilterImpl setContentHandler.

Prototype

public void setContentHandler(ContentHandler handler) 

Source Link

Document

Set the content event handler.

Usage

From source file:nl.armatiek.xslweb.serializer.RequestSerializer.java

private XMLReader getFilteredXMLReader() throws SAXException {
    if (this.xmlReader == null) {
        XMLFilterImpl filter = new BodyFilter();
        filter.setContentHandler(new ContentHandlerToXMLStreamWriter(xsw));
        this.xmlReader = XMLReaderFactory.createXMLReader();
        this.xmlReader.setFeature("http://xml.org/sax/features/validation", false);
        this.xmlReader.setFeature("http://xml.org/sax/features/namespaces", true);
        this.xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
        if (Context.getInstance().getParserHardening()) {
            this.xmlReader.setFeature("http://xml.org/sax/features/external-general-entities", false);
            this.xmlReader.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
            this.xmlReader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
            this.xmlReader.setEntityResolver(new EntityResolver() {
                @Override//from  w  w w.j a v a 2 s .  c o  m
                public InputSource resolveEntity(String publicId, String systemId)
                        throws SAXException, IOException {
                    return null;
                }
            });
            this.xmlReader.setProperty("http://apache.org/xml/properties/security-manager",
                    "org.apache.xerces.util.SecurityManager");
        }
        this.xmlReader.setContentHandler(filter);
    }
    return this.xmlReader;
}