Cernunnos Manual


<write-document>

Description:

Writes the specified source node to the specified file system location.

Reagents:

Name XPath Description Reagent Type Expected Type Required
FILE @file File system location to which the document should be written. PHRASE java.lang.String Yes
NODE @node Optional source node to be written. If not provided, the value of the 'Attributes.NODE' request attribute will be used. PHRASE org.dom4j.Node 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>