Java Code Examples for org.jdom2.input.SAXBuilder#setFeature()
The following examples show how to use
org.jdom2.input.SAXBuilder#setFeature() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XMLUtil.java From airsonic-advanced with GNU General Public License v3.0 | 5 votes |
public static SAXBuilder createSAXBuilder() { SAXBuilder builder = new SAXBuilder(); builder.setFeature("http://apache.org/xml/features/disallow-doctype-decl",true); builder.setFeature("http://xml.org/sax/features/external-general-entities", false); builder.setFeature("http://xml.org/sax/features/external-parameter-entities", false); return builder; }
Example 2
Source File: XmlCustomModifier.java From amodeus with GNU General Public License v2.0 | 5 votes |
public XmlCustomModifier(File xmlFile) throws JDOMException, IOException { if (!xmlFile.isFile()) throw new RuntimeException("not found: " + xmlFile); this.xmlFile = xmlFile; SAXBuilder builder = new SAXBuilder(); builder.setValidation(false); builder.setFeature("http://xml.org/sax/features/validation", false); builder.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false); builder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); document = builder.build(xmlFile); }
Example 3
Source File: XMLUtil.java From airsonic with GNU General Public License v3.0 | 5 votes |
public static SAXBuilder createSAXBuilder() { SAXBuilder builder = new SAXBuilder(); builder.setFeature("http://apache.org/xml/features/disallow-doctype-decl",true); builder.setFeature("http://xml.org/sax/features/external-general-entities", false); builder.setFeature("http://xml.org/sax/features/external-parameter-entities", false); return builder; }
Example 4
Source File: MCRXMLParserImpl.java From mycore with GNU General Public License v3.0 | 5 votes |
public MCRXMLParserImpl(XMLReaderJDOMFactory factory, boolean silent) { this.validate = factory.isValidating(); builder = new SAXBuilder(factory); builder.setFeature(FEATURE_NAMESPACES, true); builder.setFeature(FEATURE_SCHEMA_SUPPORT, validate); builder.setFeature(FEATURE_FULL_SCHEMA_SUPPORT, false); builder.setErrorHandler(new MCRXMLParserErrorHandler(silent)); builder.setEntityResolver(new AbsoluteToRelativeResolver(MCREntityResolver.instance())); }
Example 5
Source File: NameSpaceUtil.java From cia with Apache License 2.0 | 5 votes |
/** * Sets the name space on xml stream. * * @param in the in * @param nameSpace the name space * @return the source * @throws JDOMException the JDOM exception * @throws IOException Signals that an I/O exception has occurred. */ public static Source setNameSpaceOnXmlStream(final InputStream in, final String nameSpace) throws JDOMException, IOException { final SAXBuilder sb = new SAXBuilder(new XMLReaderSAX2Factory(false)); sb.setExpandEntities(false); sb.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); final Document doc = sb.build(in); doc.getRootElement().setNamespace(Namespace.getNamespace(nameSpace)); return new JDOMSource(doc); }
Example 6
Source File: JDOMHandle.java From java-client-api with Apache License 2.0 | 5 votes |
protected SAXBuilder makeBuilder() { SAXBuilder builder = new SAXBuilder(XMLReaders.NONVALIDATING); // default to best practices for conservative security including recommendations per // https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.md builder.setFeature("http://apache.org/xml/features/disallow-doctype-decl",true); builder.setFeature("http://xml.org/sax/features/external-general-entities", false); builder.setFeature("http://xml.org/sax/features/external-parameter-entities", false); return builder; }
Example 7
Source File: XmlUtils.java From cs-actions with Apache License 2.0 | 5 votes |
public static void setFeatures(SAXBuilder reader, String features) throws SAXException { if (!StringUtils.isEmpty(features)) { Map<String, Boolean> featuresMap = parseFeatures(features); for (String key : featuresMap.keySet()) { reader.setFeature(key, featuresMap.get(key)); } } }
Example 8
Source File: DDSXMLParser.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 3 votes |
/** * Parse the DDX waiting in the <code>InputStream</code> and instantiate all of * the member <code>BaseType</code> variables and their associated <code>Attributes * </code> into a <code>DDS</code> using the passed <code>BaseTypeFactory</code> * * @param is The <code>InputStream</code> containing the DDX to parse. * @param targetDDS The <code>DDS</code> in which to place all of the <code>BaseType * </code> variables and their associated <code>Attributes</code>. * @param fac The <code>BaseTypeFactory</code> to use when creating new * <code>BaseType</code> variables. * @param validation Is a boolean indicating whether or not the parser should * validate the XML document using the Schema (typically referenced in the * document itself). In general server side applications should always vaidate, * while clients shouldn't bother (since they are ostensibly receiving the * document from a server that has already done so.) * @see DDS * @see BaseTypeFactory */ public void parse(InputStream is, DDS targetDDS, BaseTypeFactory fac, boolean validation) throws DAP2Exception { try { // get a jdom parser to parse and validate the XML document. SAXBuilder parser = new SAXBuilder(); // optionally turn on validation parser.setFeature("http://apache.org/xml/features/validation/schema", validation); // parse the document into a hierarchical document Document doc = parser.build(is); if (_Debug) System.out.println("Document is " + (validation ? "valid and " : "") + "well-formed.\nContent: " + doc); parse(doc, targetDDS, fac, validation); } catch (JDOMException jde) { throw new DAP2Exception(jde); } catch (IOException ioe) { throw new DAP2Exception(ioe); } }
Example 9
Source File: JDom2Driver.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Create and initialize the SAX builder. * * @return the SAX builder instance. * @since 1.4.9 */ protected SAXBuilder createBuilder() { final SAXBuilder builder = new SAXBuilder(); builder.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); return builder; }