/**
   * Convert the passed object to a new DOM document
   *
   * @param aObject The object to be converted. May not be <code>null</code>.
   * @return <code>null</code> if converting the document failed.
   */
  @Nullable
  public final Document write(@Nonnull final JAXBTYPE aObject) {
    ValueEnforcer.notNull(aObject, "Object");

    final Document aDoc = XMLFactory.newDocument();
    return write(aObject, TransformResultFactory.create(aDoc)).isSuccess() ? aDoc : null;
  }
  @Test
  public void testGetRecursiveChildIter() {
    final Document doc = XMLFactory.newDocument();

    // No children present
    assertFalse(new ChildElementIterator(doc).hasNext());

    // 1 child
    final Element eRoot = (Element) doc.appendChild(doc.createElement("root"));
    assertEquals(1, ContainerHelper.newList(new ChildElementIterator(doc)).size());

    // 2 children
    eRoot.appendChild(doc.createElement("Hallo"));
    eRoot.appendChild(doc.createTextNode(" - "));
    eRoot.appendChild(doc.createElement("Welt"));
    assertEquals(2, ContainerHelper.newList(new ChildElementIterator(eRoot)).size());
    assertEquals(
        1,
        ContainerHelper.newList(
                new ChildElementIterator(eRoot, new FilterElementWithTagName("Hallo")))
            .size());

    try {
      new ChildElementIterator(doc).remove();
      fail();
    } catch (final UnsupportedOperationException ex) {
    }
    try {
      new ChildElementIterator(null);
      fail();
    } catch (final NullPointerException ex) {
    }
  }