Software AG Products 10.7 | Integrating On-Premises and Cloud Applications | DSPs and building output templates | Using Output Templates to Format Service Output | %value%
 
%value%
 
DSPs and Output Templates in Different Languages
You use the %value% tag to insert the value of a specified variable in a document.
Syntax
%value [Variable] [option option option...]%
Arguments
Variable specifies the name of the variable whose value you want to insert into the code. You may specify the name of a variable that exists in the pipeline or the following keyword/reserved words.
Variable
Description
$key
Inserts the name of the current key. You can use this keyword when looping over a document (i.e., using the %loop –struct% tag) to retrieve the name of each key in the current scope or a specified document.
url url
returnurl url
Instructs Integration Server to redirect to the specified URL. Software AG recommends that you only use the reserved words url or returnurl when you want to redirect a DSP page to a location internal to Integration Server, by using a relative path (e.g., %value url ../redirectedurl.dsp%), or to redirect to an external URL that you have allowed using the %validConst% tag.
If you attempt to use the reserved words url or returnurl to redirect to an external URL (e.g., http://example.com) that you have not allowed using the %validConst% tag, the setting of the watt.core.template.enableSecureUrlRedirection server configuration parameter governs the server’s behavior. When the watt.core.template.enableSecureUrlRedirection parameter is:
*true, Integration Server uses secure URL redirection and prepends the value “error.dsp?data=” to the output of the %value% tag (e.g., error.dsp?data=http://example.com). This is the default setting for the watt.core.template.enableSecureUrlRedirection parameter.
*false, Integration Server does not use secure URL redirection. That is, Integration Server does not prepend “error.dsp?data=” to the external URL and, as a result, redirection to the external URL is possible, which might put your application at risk.
When you specify Variable, the server retrieves the variable from the current scope. To select a variable outside the current scope, you use the following symbols to address it.
You would use...
To...
/Variable
Insert Variable from the initial scope.
../Variable
Insert Variable from the parent of the current scope.
DocName/Variable
Insert Variable from a document named DocName.
If you don’t specify Variable, the current element within the current scope is assumed. (See example of this usage, below.)
Options
You can use any of the following options with this tag. To specify multiple options, separate the options with spaces.
Option
Description
null=’AnyString’
Specifies the string that you want the server to insert when Variable is null. You specify the string in AnyString. For example: %value carrier null=’No Carrier Assigned’%.
empty=’AnyString’
Specifies the string that you want the server to insert when Variable contains an empty string. You specify the string in AnyString. For example: %value description empty=’Description Not Found’%.
index=IndexNum
Specifies the index of an element that you want to insert. You can use this option to extract an element from an array variable. Specify an integer that represents the element’s position in the array. (Arrays are zero based.) For example: %value backItems index=1%.
$index
Returns the current index number in an array. This option is usually used with the %loop% tag to print the loop’s iteration. See %loop% for more information and an example.
encode(Code)
Encodes the contents of Variable prior to inserting it, where Code specifies the encoding system you want the server to apply to the string.
Set Code to...
To encode the value using...
xml
XML encoding
b64
Base-64 encoding
url
URL encoding
none
No encoding
Note:
When the watt.core.template.enableFilterHtml parameter is set to true (the default), the output from a %value Variable% tag, including XML and JavaScript, is HTML encoded to prevent cross site scripting attacks. To display the value without HTML encoding, use the encode option with Code set to none (%value Variable encode(none)%). For more information about the watt.core.template.enableFilterHtml parameter, see webMethods Integration Server Administrator’s Guide.
decode(Code)
Decodes the contents of Variable prior to inserting it, where Code specifies the way in which Variable is currently encoded.
Set Code to...
To encode the value using...
b64
Base-64 encoding
url
URL encoding
+nl
Adds a new line character. This option is used within the %value% tag so that the lines in the HTML document generated by the server would not be concatenated.
The +nl is similar to the %nl% tag. For more information on %nl%, see %nl%. For example:
%value +nl /carrier/Name%
%value +nl /arrival/Date%
The result of the service will be:
carrierName
arrivalDate
Effect on Scope
None
Examples
The following example invokes a service and then uses the %value% tag to insert the results of the service into the DSP
.
.
.
%invoke orders:getOrderInfo%<br>
<p>%value buyerInfo/companyName%<br>
%value buyerInfo/acctNum%
<P>This shipment contains the following items</P>
<TABLE WIDTH="90%" BORDER="1">
<TR><TD>Number</TD><TD>Qty</TD><TD>Description</TD><TD>Status</TD></TR>
%loop items%
<TD>%value stockNum%</TD>
<TD>%value qty%</TD>
<TD>%value description%</TD>
<TD>%value status%</TD>
</TR>
%endLOOP%
</TABLE>
%endinvoke%
.
.
.
The following example dumps the content of the current scope.
.
.
.
<p>
%loop -struct%
%value $key% %value%<br>
%endloop%
<p>
.
.
.
The following example inserts the contents of carrier. If carrier is null, the string “UPS” is inserted. If carrier is empty, the string “UPS” is also inserted.
  %value carrier null=UPS empty=UPS%