Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Aug 5, 2020
2 parents f058e13 + 35385af commit e279293
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/org/xembly/Directives.java
Expand Up @@ -230,6 +230,18 @@ public Directives append(final Iterable<Directive> dirs) {
return this;
}

/**
* Appends the {@link Node node}.
* @param node The node to append
* @return This object
* @see #append(java.lang.Iterable)
* @see Directives#copyOf(org.w3c.dom.Node)
* @since 0.23
*/
public Directives append(final Node node) {
return this.append(Directives.copyOf(node));
}

/**
* Add node to all current nodes.
* @param name Name of the node to add
Expand Down
30 changes: 30 additions & 0 deletions src/test/java/org/xembly/DirectivesTest.java
Expand Up @@ -218,6 +218,36 @@ public void copiesExistingNode() throws Exception {
);
}

/**
* Appends an existing node.
* @throws Exception If some problem inside
* @since 1.0
*/
@Test
public void appendsExistingNode() throws Exception {
final Document dom = DocumentBuilderFactory.newInstance()
.newDocumentBuilder().newDocument();
new Xembler(
new Directives().add("guys").append(
new XMLDocument(
StringUtils.join(
"<joe name='Joey'><first/><second/>",
"<io a='x'><f><name>\u20ac</name></f></io>",
"<x><![CDATA[hey you]]></x> </joe>"
)
).node()
)
).apply(dom);
MatcherAssert.assertThat(
XhtmlMatchers.xhtml(dom),
XhtmlMatchers.hasXPaths(
"/guys/joe[@name = 'Joey']",
"/guys/joe[first and second]",
"/guys/joe/io[@a='x']/f[name='\u20ac']"
)
);
}

/**
* Directives can understand case.
* @throws Exception If some problem inside
Expand Down

0 comments on commit e279293

Please sign in to comment.