use of org.jdom.input.SAXBuilder in project intellij-community by JetBrains.
the class XsltDocumentationProvider method getDocumentationDocument.
private Document getDocumentationDocument() throws IOException, JDOMException {
Document d = com.intellij.reference.SoftReference.dereference(myDocument);
if (d == null) {
d = new SAXBuilder().build(XsltSupport.class.getResource("resources/documentation.xml"));
myDocument = new SoftReference<>(d);
}
return d;
}
use of org.jdom.input.SAXBuilder in project intellij-community by JetBrains.
the class ModelLoader method load.
protected final void load(String name) {
try {
InputStream stream = getClass().getResourceAsStream(name);
Document document = new SAXBuilder().build(stream);
stream.close();
loadDocument(document.getRootElement());
} catch (Throwable e) {
LOG.error(e);
}
}
use of org.jdom.input.SAXBuilder in project zaproxy by zaproxy.
the class ContentMatcher method loadXMLPatternDefinitions.
/**
* Load a pattern list from an XML formatted file.
* Pattern should be enclosed around a {@code <Patterns>} tag and should be
* defined as {@code <Pattern type="xxx"></Pattern>}. Use "regex" to define
* a Regex formatted pattern or "string" for an exact matching pattern.
* @param xmlInputStream the {@code InputStream} used to read the patterns
* @throws JDOMException if an error occurred while parsing
* @throws IOException if an I/O error occurred while reading the {@code InputStream}
*/
protected void loadXMLPatternDefinitions(InputStream xmlInputStream) throws JDOMException, IOException {
strings = new ArrayList<BoyerMooreMatcher>();
patterns = new ArrayList<Pattern>();
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(xmlInputStream);
Element el = doc.getRootElement();
String value;
// go ahead for boundaries and tests
for (Object obj : el.getChildren(TAG_PATTERN)) {
el = (Element) obj;
value = el.getText();
// Check if the pattern has been set to null
if (value != null && !value.isEmpty()) {
// Check if a regex expression has been set
if (el.getAttributeValue(TAG_PATTERN_TYPE).equalsIgnoreCase(TAG_PATTERN_TYPE_REGEX)) {
patterns.add(Pattern.compile(el.getText()));
// Otherwise it's by default an exact match model
} else {
strings.add(new BoyerMooreMatcher(el.getText()));
}
}
}
}
use of org.jdom.input.SAXBuilder in project ACS by ACS-Community.
the class TestHighLevelNodes method testXmlMACI.
public void testXmlMACI() throws Exception {
logger.info("MACI XML string -- Classic: " + xmlXml);
SAXBuilder sb = new SAXBuilder();
InputStream is = new ByteArrayInputStream(rdbXml.getBytes("UTF-8"));
Document doc = sb.build(is);
XMLOutputter xout = new XMLOutputter(Format.getPrettyFormat());
ByteArrayOutputStream out = new ByteArrayOutputStream();
xout.output(doc, out);
logger.info("MACI XML string -- RDB: " + out.toString());
// This fails at the moment because XML returns namespace info, TMCDB doesn't
assertXMLEqual("MACI XML pieces are similar ", xmlXml, rdbXml);
}
use of org.jdom.input.SAXBuilder in project Asqatasun by Asqatasun.
the class KbCsvMojo method getUrls.
private List<String> getUrls(String url) throws JDOMException, JaxenException, IOException {
SAXBuilder builder = new SAXBuilder();
EntityResolver resolver = new XhtmlEntityResolver();
builder.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
builder.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
builder.setEntityResolver(resolver);
Document document = builder.build(new URL(url));
XPath xpath = new JDOMXPath("//*[@id='resultat']//*[@href]/@href");
List<Attribute> results = xpath.selectNodes(document);
List<String> urls = new ArrayList<String>();
for (Attribute attr : results) {
urls.add(attr.getValue());
}
return urls;
}
Aggregations