Cernunnos Manual


<write-file>

Description:

Writes the specified content to the specified file.

Reagents:

Name XPath Description Reagent Type Expected Type Required
STRING @string Contents of the new file as a String. The default is the value of the 'Attributes.STRING' request attribute. PHRASE java.lang.String No
FILE @file Optional file system path to which the contents of STRING will be written. It may be absolute or relative, in which case it will be evaluated from the directory in which Java is executing. The default is the value of the 'Attributes.LOCATION' request attribute. PHRASE java.lang.String No

Examples:

Reads the file 'example.txt' into a String, replaces all instances of 'foo' with 'bar' and all instances of 'abc' with 'xyz' in the text, then writes the result back to 'example.txt':

 
       
        <with-attribute key="Attributes.STRING" value="${contents(example.txt)}"> 
          <string-replace regex="foo" replacement="bar"> 
            <string-replace regex="abc" replacement="xyz"> 
              <write-file file="example.txt"/> 
            </string-replace> 
          </string-replace> 
        </with-attribute>