Cernunnos Manual


${contents()}

Description:

Reads the resource at the specified location and returns the contents as a String.

Reagents:

Name XPath Description Reagent Type Expected Type Required
CONTEXT @context Optional context from which missing elements of the LOCATION will be inferred if it is relative. The default is the value of the 'Attributes.CONTEXT' request attribute (if present) or the directory from which Java is executing (otherwise). PHRASE java.lang.String No
LOCATION descendant-or-self::text() Optional location of a resource; if omitted, the value of the 'Attributes.LOCATION' request attribute will be used. LOCATION may be a filesystem path or a URL, and may be absolute or relative; if a relative value is provided, it will be resolved based on the value of CONTEXT. 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>