diff --git a/src/main/java/org/xembly/Directives.java b/src/main/java/org/xembly/Directives.java index 7645a5b8..3dd1f645 100644 --- a/src/main/java/org/xembly/Directives.java +++ b/src/main/java/org/xembly/Directives.java @@ -230,6 +230,18 @@ public Directives append(final Iterable 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 diff --git a/src/test/java/org/xembly/DirectivesTest.java b/src/test/java/org/xembly/DirectivesTest.java index 5605401f..a1f5bfdc 100644 --- a/src/test/java/org/xembly/DirectivesTest.java +++ b/src/test/java/org/xembly/DirectivesTest.java @@ -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( + "", + "\u20ac", + " " + ) + ).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