Cernunnos Manual


<append-node>

Description:

Adds the specified XML content to the specified PARENT (at the end) or after the specified SIBLING.

See also: <prepend-node>

Reagents:

Name XPath Description Reagent Type Expected Type Required
NODE @node Optional node that will be appended. If not provided, the 'Attributes.NODE' request attribute will be used. PHRASE org.dom4j.Node No
PARENT @parent Optional node under which the specified content will be added. Specify only PARENT or SIBLING, not both. If neither is specified, the 'Attributes.NODE' request attribute will be used as a PARENT. PHRASE org.dom4j.Node No
SIBLING @sibling Optional node after which the specified content will be added. Specify only PARENT or SIBLING, not both. PHRASE org.dom4j.Node No
CONTENT * Optional XML nodes to append. Use this reagent to specify content in-line. If CONTENT is present, it will be prefered over NODE. NODE_LIST java.util.List No
APPLY_NAMESPACE @apply-namespace Tells this task whether to reconstruct the QNames of added elements to include the namespace of the parent element if: (1) the parent contains a namespace; and (2) the intended child does not. The default is Boolean.TRUE. PHRASE java.lang.Boolean No

Examples:

Creates a new XML document containing '<example foo="bar"/>', then writes it to the file 'example.xml':

 
       
        <with-attribute key="Attributes.NODE" value="${newDoc(example)}"> 
          <append-node node="${attributeNode(foo=bar)}"/>  
          <write-document file="example.xml"/> 
        </with-attribute> 
       
    

Parses the 'books.xml' document, adds a '<book>' child element, places a comment before the '<book>' element, then writes the file back to the same location:

 
       
        <with-attribute key="Attributes.NODE" value="${parseXml(example.xml)}"> 
          <append-node> 
            <book author="George Eliot"> 
              <title>Middlemarch</title> 
            </book> 
          </append-node>  
          <prepend-node node="${commentNode(This is a great book!)}" sibling="${singleNode(book)}"/>  
          <write-document file="books.xml"/> 
        </with-attribute>