Example usage for org.apache.commons.digester3 Digester setProperty

List of usage examples for org.apache.commons.digester3 Digester setProperty

Introduction

In this page you can find the example usage for org.apache.commons.digester3 Digester setProperty.

Prototype

public void setProperty(String property, Object value)
        throws SAXNotRecognizedException, SAXNotSupportedException 

Source Link

Document

Set the current value of the specified property for the underlying XMLReader implementation.

Usage

From source file:com.thoughtworks.go.plugin.infra.plugininfo.GoPluginDescriptorParser.java

private static Digester initDigester() throws SAXNotRecognizedException, SAXNotSupportedException {
    Digester digester = new Digester();
    digester.setValidating(true);//from w  w  w.j av  a  2  s .  c o m
    digester.setErrorHandler(new ErrorHandler() {
        @Override
        public void warning(SAXParseException exception) throws SAXException {
            throw new SAXException("XML Schema validation of Plugin Descriptor(plugin.xml) failed", exception);
        }

        @Override
        public void error(SAXParseException exception) throws SAXException {
            throw new SAXException("XML Schema validation of Plugin Descriptor(plugin.xml) failed", exception);
        }

        @Override
        public void fatalError(SAXParseException exception) throws SAXException {
            throw new SAXException("XML Schema validation of Plugin Descriptor(plugin.xml) failed", exception);
        }
    });
    digester.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
            XMLConstants.W3C_XML_SCHEMA_NS_URI);
    digester.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource",
            GoPluginDescriptorParser.class.getResourceAsStream("/plugin-descriptor.xsd"));
    return digester;
}