The lookup function inspects a text file for a name-value pair with name name and returns the corresponding value. The name-value pairs in the file are separated by white space.
If the file does not contain a name-value pair with the specified name, this function returns the value of defaultvalue, if specified, or returns an empty string.
lookup(filename, name, defaultvalue)
The expression function has the following arguments:
Table A–12 lookup Arguments
Argument |
Description |
---|---|
filename |
filename is the name of a text file that contains one name-value pair per line. filename can be an absolute path or a path relative to the server's config directory. Names and values are separated by white space. Lines beginning with # are ignored. |
name |
The name of the name-value pair for which the function looks in the text file. |
defaultvalue |
The value returned by the function if filename exists but does not contain a name-value pair with a name matching the value of name. If defaultvalue is not specified, it defaults to an empty string. |
The following example shows a text file called urimap.conf that could be used with the lookup function to map shortcut URIs to URIs:
# This file contains URI mappings for Web Server. # Lines beginning with # are treated as comments. # All other lines consist of a shortcut URI, whitespace, and canonical URI. /webserver /software/products/web_srvr/home_web_srvr.html /solaris /software/solaris/ /java /software/java/
Using the sample text file above, you could use the following lookup expression to implement shortcut URIs for commonly accessed resources:
<If lookup('urimap.conf', uri)> NameTrans fn="redirect" url="$(lookup('urimap.conf', uri))" </If>