Cernunnos Manual


${singleNode()}

Description:

Returns the first node that matches the specified XPATH expression when evaluated against the SOURCE node.

Reagents:

Name XPath Description Reagent Type Expected Type Required
CACHE @cache A shared Map to cache items in. The default is the value of the 'Attributes.CACHE' request attribute. PHRASE java.util.Map No
CACHE_MODEL @cache-model Specify either NONE, ONE, or ALL. PHRASE java.lang.String No
SOURCE @source Optional source node against which the XPATH expression will be evaluated. If not provided, the value of the 'Attributes.NODE' request attribute will be used. PHRASE org.dom4j.Node No
XPATH descendant-or-self::text() An XPATH expression. PHRASE java.lang.String Yes

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>