Cernunnos Manual


<with-attribute>

Description:

Creates a request attribute with the specified KEY and VALUE, then invokes subtasks.

<with-attribute> can be thought of as a shorthand for <with> where only one attribute is needed.

Reagents:

Name XPath Description Reagent Type Expected Type Required
KEY @key Name to be used for the new request attribute. PHRASE java.lang.String Yes
VALUE @value Value of the request attribute. PHRASE java.lang.Object Yes
SUBTASKS * The set of tasks that are children of this task. NODE_LIST java.util.List 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> 
       
    

Takes a web address as a parameter (e.g. 'www.yahoo.com'); computes the checksum value of the document at the specified address, then copies that document to a local file called 'markup.html' and finally compares the checksum value of the local document against the previous, online checksum value:

 
       
        <with-attribute key="onlineChecksum" value="${checksum(http://${$1})}"> 
          <copy-file location="http://${$1}/" to-file="markup.html"/>  
          <with-attribute key="localChecksum" value="${checksum(markup.html)}"> 
            <groovy> 
              <script>if (onlineChecksum == localChecksum) { println 'Both checksum values are the same: ' + onlineChecksum; } else { println 'The checksum values are different:\n\tonline=' + onlineChecksum + '\n\tlocal=' + localChecksum; }</script> 
            </groovy> 
          </with-attribute> 
        </with-attribute>