Cernunnos Manual


<prepend-node>

Description:

Adds the specified XML content to the specified PARENT (at the beginning) or before the specified SIBLING.

See also: <append-node>

Reagents:

Name XPath Description Reagent Type Expected Type Required
NODE @node Optional node that will be prepended. 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 at the beginning. 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 before which the specified content will be added. Specify only PARENT or SIBLING, not both. PHRASE org.dom4j.Node No
CONTENT * Optional XML nodes to prepend. 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:

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>