Java Code Examples for org.jdom.input.SAXBuilder#setIgnoringElementContentWhitespace()

The following examples show how to use org.jdom.input.SAXBuilder#setIgnoringElementContentWhitespace() . 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: JDOMParser.java    From commons-jxpath with Apache License 2.0 6 votes vote down vote up
public Object parseXML(InputStream stream) {
    if (!isNamespaceAware()) {
        throw new JXPathException("JDOM parser configuration error. JDOM "
                + "does not support the namespaceAware=false setting.");
    }

    try {
        SAXBuilder builder = new SAXBuilder();
        builder.setExpandEntities(isExpandEntityReferences());
        builder.setIgnoringElementContentWhitespace(
                isIgnoringElementContentWhitespace());
        builder.setValidation(isValidating());
        return builder.build(stream);
    }
    catch (Exception ex) {
        throw new JXPathException("JDOM parser error", ex);
    }
}
 
Example 2
Source File: SlackNotificationSettingsTest.java    From tcSlackBuildNotifier with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void test_WebookConfig() throws JDOMException, IOException{
	SAXBuilder builder = new SAXBuilder();
	List<SlackNotificationConfig> configs = new ArrayList<SlackNotificationConfig>();
	builder.setIgnoringElementContentWhitespace(true);
		Document doc = builder.build("src/test/resources/testdoc2.xml");
		Element root = doc.getRootElement();
		if(root.getChild("slackNotifications") != null){
			Element child = root.getChild("slackNotifications");
			if ((child.getAttribute("enabled") != null) && (child.getAttribute("enabled").equals("true"))){
				List<Element> namedChildren = child.getChildren("slackNotification");
				for(Iterator<Element> i = namedChildren.iterator(); i.hasNext();)
	            {
					Element e = i.next();
					SlackNotificationConfig whConfig = new SlackNotificationConfig(e);
					configs.add(whConfig);
	            }
			}
		}

	
	for (SlackNotificationConfig c : configs){
		SlackNotification wh = new SlackNotificationImpl(c.getChannel());
		wh.setEnabled(c.getEnabled());
		//slackNotification.addParams(c.getParams());
		System.out.println(wh.getChannel());
		System.out.println(wh.isEnabled().toString());

	}
}
 
Example 3
Source File: SlackNotificationSettingsTest.java    From tcSlackBuildNotifier with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void test_ReadXml() throws JDOMException, IOException {
	SAXBuilder builder = new SAXBuilder();
	//builder.setValidation(true);
	builder.setIgnoringElementContentWhitespace(true);
	
		Document doc = builder.build("src/test/resources/testdoc1.xml");
		Element root = doc.getRootElement();
		System.out.println(root.toString());
		if(root.getChild("slackNotifications") != null){
			Element child = root.getChild("slackNotifications");
			if ((child.getAttribute("enabled") != null) && (child.getAttribute("enabled").equals("true"))){
				List<Element> namedChildren = child.getChildren("slackNotification");
				for(Iterator<Element> i = namedChildren.iterator(); i.hasNext();)
	            {
					Element e = i.next();
					System.out.println(e.toString() + e.getAttributeValue("url"));
					//assertTrue(e.getAttributeValue("url").equals("http://something"));
					if(e.getChild("parameters") != null){
						Element eParams = e.getChild("parameters");
						List<Element> paramsList = eParams.getChildren("param");
						for(Iterator<Element> j = paramsList.iterator(); j.hasNext();)
						{
							Element eParam = j.next();
							System.out.println(eParam.toString() + eParam.getAttributeValue("name"));
							System.out.println(eParam.toString() + eParam.getAttributeValue("value"));
						}
					}
	            }
			}
		}

}
 
Example 4
Source File: ConfigLoaderUtil.java    From tcSlackBuildNotifier with MIT License 4 votes vote down vote up
public static Element getFullConfigElement(File file) throws JDOMException, IOException{
	SAXBuilder builder = new SAXBuilder();
	builder.setIgnoringElementContentWhitespace(true);
	Document doc = builder.build(file);
	return doc.getRootElement();
}