List of usage examples for org.dom4j DocumentHelper makeElement
public static Element makeElement(Branch source, String path)
makeElement
a helper method which navigates from the given Document or Element node to some Element using the path expression, creating any necessary elements along the way.From source file:org.pentaho.pac.server.config.WebXml.java
License:Open Source License
public void setContextParamValue(String name, String value) { String xPath = MessageFormat.format(CONTEXT_PARAM_NAME_TEMPLATE_XPATH, name); Element contextParamNameElement = (Element) document.selectSingleNode(xPath); if (value == null) { if (contextParamNameElement != null) { contextParamNameElement.getParent().detach(); }/*from w w w .j a va 2s . co m*/ } else { if (contextParamNameElement == null) { contextParamNameElement = document.getRootElement().addElement(CONTEXT_PARAM_ELEMENT); Element paramNameElement = contextParamNameElement.addElement(PARAM_NAME_ELEMENT); paramNameElement.setText(name); } Element paramValueElement = DocumentHelper.makeElement(contextParamNameElement.getParent(), PARAM_VALUE_ELEMENT); paramValueElement.setText(value); } }
From source file:org.pentaho.platform.plugin.services.email.EmailConfigurationXml.java
License:Open Source License
private static void setValue(final Document doc, final String xPath, final String value) { Element element = (Element) doc.selectSingleNode(xPath); if (null == element) { element = DocumentHelper.makeElement(doc, xPath); }/* w w w . j av a2 s .co m*/ element.setText(value); }