/** * Creates a <code>XmlSlurper</code>. * * @param validating <code>true</code> if the parser should validate documents as they are parsed; false otherwise. * @param namespaceAware <code>true</code> if the parser should provide support for XML namespaces; <code>false</code> otherwise. * @param allowDocTypeDeclaration <code>true</code> if the parser should provide support for DOCTYPE declarations; <code>false</code> otherwise. * * @throws ParserConfigurationException if no parser which satisfies the requested configuration can be created. * @throws SAXException for SAX errors. */ public XmlSlurper(final boolean validating, final boolean namespaceAware, boolean allowDocTypeDeclaration) throws ParserConfigurationException, SAXException { SAXParserFactory factory = FactorySupport.createSaxParserFactory(); factory.setNamespaceAware(namespaceAware); this.namespaceAware = namespaceAware; factory.setValidating(validating); setQuietly(factory, XMLConstants.FEATURE_SECURE_PROCESSING, true); setQuietly(factory, "http://apache.org/xml/features/disallow-doctype-decl", !allowDocTypeDeclaration); reader = factory.newSAXParser().getXMLReader(); }
/** * Creates a <code>XmlSlurper</code>. * * @param validating <code>true</code> if the parser should validate documents as they are parsed; false otherwise. * @param namespaceAware <code>true</code> if the parser should provide support for XML namespaces; <code>false</code> otherwise. * @param allowDocTypeDeclaration <code>true</code> if the parser should provide support for DOCTYPE declarations; <code>false</code> otherwise. * * @throws ParserConfigurationException if no parser which satisfies the requested configuration can be created. * @throws SAXException for SAX errors. */ public XmlSlurper(final boolean validating, final boolean namespaceAware, boolean allowDocTypeDeclaration) throws ParserConfigurationException, SAXException { SAXParserFactory factory = FactorySupport.createSaxParserFactory(); factory.setNamespaceAware(namespaceAware); this.namespaceAware = namespaceAware; factory.setValidating(validating); setQuietly(factory, XMLConstants.FEATURE_SECURE_PROCESSING, true); setQuietly(factory, "http://apache.org/xml/features/disallow-doctype-decl", !allowDocTypeDeclaration); reader = factory.newSAXParser().getXMLReader(); }