org.dom4j.Branch Java Examples

The following examples show how to use org.dom4j.Branch. 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: VersionedXmlDoc.java    From onedev with MIT License 5 votes vote down vote up
private static void unmarshallElement(HierarchicalStreamReader reader, Branch branch) {
	Element element = branch.addElement(reader.getNodeName());
	for (int i=0; i<reader.getAttributeCount(); i++) {
		String attributeName = reader.getAttributeName(i);
		String attributeValue = reader.getAttribute(i);
		element.addAttribute(attributeName, attributeValue);
	}
	if (StringUtils.isNotBlank(reader.getValue()))
		element.setText(reader.getValue().trim());
	while (reader.hasMoreChildren()) {
		reader.moveDown();
		unmarshallElement(reader, element);
		reader.moveUp();
	}
}
 
Example #2
Source File: Dom4jNodeModel.java    From engine with GNU General Public License v3.0 5 votes vote down vote up
@Override
public TemplateSequenceModel getChildNodes() throws TemplateModelException {
    if (node instanceof Branch) {
        List childNodes = ((Branch) node).content();
        if (childNodes != null) {
            return new SimpleSequence(childNodes, wrapper);
        } else {
            return null;
        }
    } else {
        return new SimpleSequence(Collections.emptyList(), wrapper);
    }
}
 
Example #3
Source File: XmlObjectWriter.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
private void writeValue(final Branch branch, final Object obj, final String key, final String sValue, final boolean asAttribute,
    final boolean asCDATA)
{
  if (sValue == null) {
    return;
  }
  if (asAttribute == true) {
    addAttribute((Element) branch, obj, key, sValue);
  } else if (asCDATA == true) {
    branch.addElement(key).add(new DefaultCDATA(sValue));
  } else {
    branch.addElement(key).setText(sValue);
  }
}
 
Example #4
Source File: Dom4JXMLOutput.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void openTag(String tagName, XMLAttributeList attributeList) {
    Branch top = stack.getLast();
    Element element = top.addElement(tagName);
    stack.addLast(element);

    for (Iterator<XMLAttributeList.NameValuePair> i = attributeList.iterator(); i.hasNext();) {
        XMLAttributeList.NameValuePair pair = i.next();
        element.addAttribute(pair.getName(), pair.getValue());
    }
}
 
Example #5
Source File: Dom4JWriter.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
protected Object createNode(final String name) {
    final Element element = documentFactory.createElement(encodeNode(name));
    final Branch top = top();
    if (top != null) {
        top().add(element);
    }
    return element;
}
 
Example #6
Source File: Dom4JWriter.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public Dom4JWriter(final Branch root) {
    this(root, new DocumentFactory(), new XmlFriendlyNameCoder());
}
 
Example #7
Source File: Dom4JWriter.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @since 1.2.1
 * @deprecated As of 1.4 use {@link Dom4JWriter#Dom4JWriter(Branch, DocumentFactory, NameCoder)} instead.
 */
public Dom4JWriter(
    final Branch root, final DocumentFactory factory, final XmlFriendlyReplacer replacer) {
    this(root, factory, (NameCoder)replacer);
}
 
Example #8
Source File: Dom4JWriter.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
private Branch top() {
    return (Branch)getCurrent();
}
 
Example #9
Source File: Dom4JReader.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @since 1.4.11
 */
public Dom4JReader(final Branch branch) {
    this(branch instanceof Element ? (Element)branch : ((Document)branch).getRootElement());
}
 
Example #10
Source File: Dom4JXMLOutput.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void openTag(String tagName) {
    Branch top = stack.getLast();
    Element element = top.addElement(tagName);
    stack.addLast(element);
}
 
Example #11
Source File: Dom4JWriter.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @since 1.4
 */
public Dom4JWriter(final Branch root, final NameCoder nameCoder) {
    this(root, new DocumentFactory(), nameCoder);
}
 
Example #12
Source File: Dom4JXMLOutput.java    From spotbugs with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void startTag(String tagName) {
    Branch top = stack.getLast();
    Element element = top.addElement(tagName);
    stack.addLast(element);
}
 
Example #13
Source File: ElementWrapper.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void appendContent(Branch branch) {
	element.appendContent( branch );
}
 
Example #14
Source File: Dom4jProxy.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void appendContent(Branch branch) {
	target().appendContent( branch );
}
 
Example #15
Source File: XmlObjectWriter.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
public Element write(final Branch parent, final Object obj)
{
  reset();
  return write(parent, obj, null, false, false);
}
 
Example #16
Source File: Dom4JWriter.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @since 1.4
 */
public Dom4JWriter(
    final Branch root, final DocumentFactory factory, final NameCoder nameCoder) {
    super(root, nameCoder);
    documentFactory = factory;
}
 
Example #17
Source File: VersionedXmlDoc.java    From onedev with MIT License 4 votes vote down vote up
public void appendContent(Branch branch) {
	getWrapped().appendContent(branch);
}
 
Example #18
Source File: Dom4JWriter.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * @since 1.2.1
 * @deprecated As of 1.4 use {@link Dom4JWriter#Dom4JWriter(Branch, NameCoder)} instead
 */
public Dom4JWriter(final Branch root, final XmlFriendlyReplacer replacer) {
    this(root, new DocumentFactory(), (NameCoder)replacer);
}
 
Example #19
Source File: Dom4JXMLOutput.java    From spotbugs with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Constructor.
 *
 * @param topLevel
 *            the Document or Element that is the root of the tree to be
 *            built
 */
public Dom4JXMLOutput(Branch topLevel) {
    this.stack = new LinkedList<>();
    stack.addLast(topLevel);
}