![]() | |
Sun Java System Portal Server 6 2005Q4 Technical Reference Guide |
Chapter 53
Robot Application Functions - Filtering Support FunctionsThis chapter contains the following sections:
IntroductionThe functions discussed in this chapter are used during filtering to manipulate or generate information on the resource. The robot can then process the resource by calling filtering functions. These functions can be used in Enumeration and Generation filters in the filter.conf file.
assign-sourceThe assign-source function assigns a new value to a given information source. This permits editing during the filtering process. The function can assign an explicit new value, or it can copy a value from another information source.
Parameters
The following table lists the parameters used with the assign-source function. The table contains two columns. The first column lists the parameter, and the second column provides a description.
dst
Name of the source whose value is to be changed.
value
Specifies an explicit value.
src
Information source to copy to dst
You must specify either a value parameter or a src parameter, but not both.
Example
Data fn=assign-source dst=type src=content-type
assign-type-by-extensionThe assign-type-by-extension function uses the resource’s file name to determine its type and assigns this type to the resource for further processing.
The setup-type-by-extension function must be called during setup before assign-type-by-extension function can be used.
Parameters
The following table lists the parameter used with the assign-type-by-extension function. The table contains two columns. The first column lists the parameter, and the second column provides a description.
src
Source of file name to compare. If you do not specify a source, the default is the resource’s path.
Example
MetaData fn=assign-type-by-extclear-source
clear-sourceThe clear-source function deletes the specified data source. You typically do not need to perform this function. You can create or replace a source by using the assign-source function.
Parameters
The following table lists the parameter used with the clear-source function. The table contains two columns. The first column lists the parameter, and the second column provides a description.
Example
The following example deletes the path source:
MetaData fn=clear-source src=path
convert-to-htmlThe convert-to-html function converts the current resource into an HTML file for further processing, if its type matches a specified MIME type. The conversion filter automatically detects the type of the file it is converting.
Parameters
The following table lists the parameter used with the convert-to-html function. The table contains two columns. The first column lists the parameter, and the second column provides a description.
Example
The following sequence of function calls causes the filter to convert all Adobe Acrobat PDF files, Microsoft RTF files, and FrameMaker MIF files to HTML, as well as any files whose type was not specified by the server that delivered it.
Data fn=convert-to-html type=application/pdf
Data fn=convert-to-html type=application/rtf
Data fn=convert-to-html type=application/x-mif
Data fn=convert-to-html type=unknown
copy-attribute
The copy-attribute function copies the value from one field in the resource description into another.
Parameters
The following table lists the parameters used with the copy-attribute function. The table contains two columns. The first column lists the parameter, and the second column provides a description.
Example
Generate fn=copy-attribute \
src=partial-text dst=description truncate=200 clean=true
generate-by-exactThe generate-by-exact function generates a source with a specified value, but only if an existing source exactly matches another value.
Parameters
The following table lists the parameters used with the generate-by-exact function. The table contains two columns. The first column lists the parameter, and the second column provides a description.
Example
The following example sets the classification to Siroe if the host is www.siroe.com.
Generate fn="generate-by-exact" match="www.siroe.com:80" src="host" value="Siroe" dst="classification"
generate-by-prefixThis generate-by-prefix function generates a source with a specified value, but only if the prefix of an existing source matches another value.
Parameters
The following table lists the parameters used with the generate-by-prefix function. The table contains two columns. The first column lists the parameter, and the second column provides a description.
dst
Name of the source to generate.
value
Value to assign to dst.
src
Source against which to match.
match
Value to compare to src.
Example
The following example sets the classification to Compass if the protocol prefix is HTTP:
Generate fn="generate-by-prefix" match="http" src="protocol" value="World Wide Web" dst="classification"
generate-by-regexThe generate-by-regex function generates a source with a specified value, but only if an existing source matches a regular expression.
Parameters
The following table lists the parameters used with the generate-by-regex function. The table contains two columns. The first column lists the parameter, and the second column provides a description.
dst
Name of the source to generate.
value
Value to assign to dst.
src
Source against which to match.
match
Regular expression string to compare to src.
Example
The following example sets the classification to Siroe if the host name matches the regular expression *.siroe.com. For example, resources at both developer.siroe.com and home.siroe.com will be classified as Siroe:
Generate fn="generate-by-regex" match="\\*.siroe.com" src="host" value="Siroe" dst="classification"
generate-md5The generate-md5 function generates an MD5 checksum and adds it to the resource. You can then use the filter-by-md5 function to deny resources with duplicate MD5 checksums.
Parameters
none
Example
Data fn=generate-md5
generate-rd-expiresThe generate-rd-expires function generates an expiration date and adds it to the specified source. The function uses metadata such as the HTTP header and HTML <META> tags to obtain any expiration data from the resource. If none exists, it generates an expiration date three months from the current date.
Parameters
The following table lists the parameter used with the generate-rd-expires function. The table contains two columns. The first column lists the parameter, and the second column provides a description.
Example
Generate fn=generate-rd-expires
generate-rd-last-modifiedThe generate-rd-last-modified function adds the current time to the specified source.
Parameters
The following table lists the parameter used with the generate-rd-last-modified function. The table contains two columns. The first column lists the parameter, and the second column provides a description.
Example
Generate fn=generate-last-modified
rename-attributeThe rename-attribute function changes the name of a field in the resource description. It is most useful in cases where, for example, extract-html-meta copies information from a <META> tag into a field, and you want to change the name of the field.
Parameters
The following table lists the parameter used with the generate-rd-last-modified function. The table contains two columns. The first column lists the parameter, and the second column provides a description.
Example
The following example renames an attribute from author to author-name:
Generate fn=rename-attribute src="author->author-name"