本文整理了Java中org.dom4j.Element.content()
方法的一些代码示例,展示了Element.content()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.content()
方法的具体详情如下:
包路径:org.dom4j.Element
类名称:Element
方法名:content
暂无
代码示例来源:origin: gocd/gocd
protected ConfigSaveState updatePartial(String xmlPartial, final String md5) throws Exception {
LOGGER.debug("[Config Save] Updating partial");
Document document = documentRoot();
Element root = document.getRootElement();
Element configElement = ((Element) root.selectSingleNode(getXpath()));
List nodes = configElement.getParent().content();
int index = nodes.indexOf(configElement);
LOGGER.debug("[Config Save] Converting to object");
Element newConfigElement = reader.read(new StringReader(xmlPartial)).getRootElement();
nodes.set(index, newConfigElement);
return saveConfig(document.asXML(), md5);
}
代码示例来源:origin: igniterealtime/Openfire
@Override
public void visit( Element node )
{
// This orders only the elements from the content, which can get messy if mixed content is of importance.
// At the time of writing, the content other than elements was whitespace text (for indentation), which
// is safe to ignore.
Collections.sort( node.content(), new ElementByOrderAttributeComparator() );
super.visit( node );
}
};
代码示例来源:origin: hibernate/hibernate-orm
for ( Object o : properties.content() ) {
final Element element = (Element) o;
element.setParent( null );
代码示例来源:origin: org.opencms/opencms-solr
/**
* Provides a type safe / generic wrapper for {@link Element#content()}.<p>
*
* @param element the element to get the content for
*
* @return type safe access to {@link Element#content()}.<p>
*/
@SuppressWarnings("unchecked")
public static List<Node> content(Element element) {
return element.content();
}
代码示例来源:origin: org.dom4j/dom4j
appendDOMTree(domDocument, domElement, element.content());
代码示例来源:origin: org.opencms/opencms-core
/**
* Provides a type safe / generic wrapper for {@link Element#content()}.<p>
*
* @param element the element to get the content for
*
* @return type safe access to {@link Element#content()}.<p>
*/
@SuppressWarnings("unchecked")
public static List<Node> content(Element element) {
return element.content();
}
代码示例来源:origin: hibernate/hibernate
public List content() {
return element.content();
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core
public List content() {
return element.content();
}
代码示例来源:origin: org.dom4j/dom4j
boolean textOnly = true;
for (Node node : element.content()) {
if (node instanceof Text) {
if (lastTextNode == null) {
Node lastTextNode = null;
for (Node node : element.content()) {
if (node instanceof Text) {
writeNode(node);
代码示例来源:origin: com.atlassian.plugins/atlassian-plugins-core
protected static Document mergeDocuments(final Document mainDocument, final Iterable<Document> supplementalDocuments) {
Element mainRootElement = mainDocument.getRootElement();
for (Document supplementalDocument : supplementalDocuments) {
Element supplementaryRoot = supplementalDocument.getRootElement();
for (Iterator<Node> iter = supplementaryRoot.content().iterator(); iter.hasNext(); ) {
Node node = iter.next();
iter.remove();
mainRootElement.add(node);
}
}
return mainDocument;
}
代码示例来源:origin: com.github.jjYBdx4IL.utils/xml-dom4j-utils
public static boolean hasNonTextChilds(Element element) {
for (Object node : element.content()) {
Node e1 = (Node) node;
if (e1.getNodeType() != Node.TEXT_NODE) {
return true;
}
}
return false;
}
代码示例来源:origin: jboss.jboss-embeddable-ejb3/hibernate-all
public List content() {
return target().content();
}
代码示例来源:origin: org.dom4j/dom4j
currentParent.content().set(contentIndex, modifiedElement);
代码示例来源:origin: com.github.jjYBdx4IL.utils/xml-dom4j-utils
public static boolean hasTextChildsWithNonWhitespace(Element element) {
for (Object node : element.content()) {
Node e1 = (Node) node;
if (e1.getNodeType() != Node.TEXT_NODE) {
continue;
}
Text textNode = (Text) e1;
if (!textNode.getText().trim().isEmpty()) {
return true;
}
}
return false;
}
代码示例来源:origin: com.haulmont.addon.dashboard/dashboard-gui
protected void loadParams(DashboardFrame resultComponent, Element element) {
List<Parameter> parameters = (List<Parameter>) element.content().stream()
.filter(child -> child instanceof DefaultElement &&
"parameter".equals(((DefaultElement) child).getName()))
.map(xmlParam -> createParameter((DefaultElement) xmlParam))
.collect(Collectors.toList());
resultComponent.setXmlParameters(parameters);
}
代码示例来源:origin: dom4j/dom4j
protected void mutate(Element element) throws Exception {
DocumentFactory factory = DocumentFactory.getInstance();
List list = element.elements();
list.add(factory.createElement("last"));
list.add(0, factory.createElement("first"));
List list2 = element.elements();
assertTrue("Both lists should contain same number of elements", list
.size() == list2.size());
XMLWriter writer = new XMLWriter(System.out);
log("Element content is now: " + element.content());
writer.write(element);
}
}
代码示例来源:origin: dom4j/dom4j
public void testContent() throws Exception {
Element root = document.getRootElement();
assertNotNull("Has root element", root);
List<Node> content = root.content();
assertNotNull("Root has content", content);
assertTrue("Root has content", content.size() >= 2);
boolean iterated = false;
for (Node object : content) {
iterated = true;
}
assertTrue("Iteration completed", iterated);
}
代码示例来源:origin: dom4j/dom4j
public void testBug926713() throws Exception {
Document doc = getDocument("/xml/test/cdata.xml");
Element foo = doc.getRootElement();
Element bar = foo.element("bar");
List content = bar.content();
assertEquals(3, content.size());
assertEquals(Node.TEXT_NODE, ((Node) content.get(0)).getNodeType());
assertEquals(Node.CDATA_SECTION_NODE, ((Node) content.get(1))
.getNodeType());
assertEquals(Node.TEXT_NODE, ((Node) content.get(2)).getNodeType());
}
}
代码示例来源:origin: dom4j/dom4j
protected void testParentRelationship(Element element) {
testParentRelationship(element, element.attributes());
testParentRelationship(element, element.content());
}
代码示例来源:origin: dom4j/dom4j
public void testParentAfterSetContent() throws Exception {
Document doc = DocumentHelper.parseText("<root>" + "<a>a</a>"
+ "<b>b</b>" + "<x>x</x>" + "<d>d</d>" + "</root>");
Node x = doc.selectSingleNode("/root/x");
List content = doc.getRootElement().content();
int position = content.indexOf(x);
Element c = DocumentHelper.createElement("c");
c.setText("c");
content.add(position, c);
assertNotNull(c.getParent());
doc.getRootElement().setContent(content);
assertNotNull("Parent is null of setting content", c.getParent());
}
内容来源于网络,如有侵权,请联系作者删除!