Two rules are required to rewrite the specified page content. The first
rule identifies the onClick JavaScript token. The second
rule identifies the parameter of the check function that
needs to be rewritten. In this case, only the first parameter is rewritten
because paramPatterns has the value y in
place of first parameter.

The Gateway URL and the base URL of the page on which the JavaScript
tokens appear are prefixed to the required parameter.

Form Rules for HTML Content

The HTML pages that a user browses may contain forms. Some form elements
may take a URL as the value.

The input tag attribute value’s value is rewritten
as shown in the output. The specified valuePatterns is
located, and all content following the matched valuePatterns is
rewritten by prefixing the Gateway URL, and the base URL of the page. See Using Pattern Matching in Rules.

Applet Rules for HTML Content

A single web page may contain many applets, and each applet may contain
many parameters. Rewriter matches the values specified in the rule with the
HTML definition of the applet and modifies the URL values present as a part
of the applet parameter definition. This replacement is carried out at the
server and not when the user is browsing the particular web page. This rule
identifies and rewrites the parameters in both the applet and object tags
of the HTML content.

Specifying Specialized Characters in valuePatterns

Using Wild Cards in valuePatterns

You can use the wildcard asterisk (*) character to achieve pattern matching
for rewriting.

You cannot specify just an * in the valuePatterns field.
Because * indicates a match with all text, no text follows the valuePattern. Therefore, Rewriter has no text to rewrite. You must use * in
conjunction with another string such as *abc. In this case,
all content that follows *abc is rewritten.

Note –

An asterisk (*) can be used as a wildcard in any of the fields
of the rule. However, all the fields in the rule cannot contain an *. If all
fields contain a *, the rule is ignored. No error message is displayed.

You can use a * or ** along with the separation character (a semicolon
or comma) that displays in the original statement to separate multiple fields.
One asterisk (*) matches any field that is not to be rewritten, and two asterisks
(**) to match any field that needs to be rewritten.

url1 and url3 are rewritten because ** indicates the portion to be rewritten

XYZABChttp://host1.sesta.com/dir1.html

valuePatterns = "*ABC"

only the portion http://host1.sesta.com/dir1.html is
rewritten. Everything after *ABC needs to be rewritten.

"0|dir1|dir2|dir3|dir4|test|url1

valuePatterns = "*|*|**|*|**|*|"

dir2, dir4 and url1 are
rewritten. The last field that needs to be rewritten does not have to be indicated
by using **.

Rules for JavaScript Content

JavaScript can contain URLs in various locations. Rewriter cannot directly
parse the JavaScript and determine the URL portion. A special set of rules
need to be written to help the JavaScript processor to identify and translate
the URL.

All variables of type URL and name beginning with imgsrc are
rewritten. For the first line of the output, the Gateway URL and the base
URL of the page on which the variable displays are prefixed. The second line
already contains the absolute path, and hence only the Gateway URL is prefixed.
Third var imagsrc2 would not be rewritten as it’s
value is not a string but another JavaScript value.

EXPRESSION Variables

Expression variables have an expression on the right hand side. The
result of this expression is a URL. Rewriter appends a JavaScript function
(psSRAPRewriter_convert_expression) to the HTML page as
it cannot evaluate such expressions on the server. This function takes the
expression as a parameter and evaluates it to the required URL at the client
browser.

If you are not sure whether a statement contains a simple URL or an
EXPRESSION URL, use EXPRESSION rules because it can handle both scenarios.

The function psSRAPRewriter_convert_expression is
prefixed to the right side of the expression variable expvar in
the first line. This function processes the expression and rewrites the content
at runtime. In the third line the value is rewritten as a simple URL.

The JavaScript parser reads the value of dhtmlVar as
HTML content and sends the content through the HTML parser. The HTML parser
applies the HTML rules where the href attribute rules are matched and hence
the URL is rewritten.

Two rules are required here. The first rule locates the dynamic JavaScript
variable dJSVar. The value of this variable is again a
JavaScript of type URL. The second rule is applied to rewrite
the value of this JavaScript variable.

SYSTEM Variables

These are variables are not declared by the use and have limited support.
They are available as a part of the JavaScript standard. For example, window.location.pathname.

SYSTEM Variable Syntax

<Variable name=”variableName” type="SYSTEM" [source=”*”]/>

where

variableName is the JavaScript system variable (mandatory
and the values could be ones that match these patterns: document.URL, document.domain,
location, doument.location, location.pathname, location.href, location.protocol,
location.hostname, location.host and location.port. All these are present
in the generic_ruleset. Do not modifiy these system var rules .

type specifies system type values (mandatory and
value is SYSTEM)

source is the URI of this pages (optional, default
value is *, meaning in any page)

Rewriter locates the system variable which matches the rule, then the psSRAPRewriter_convert_system function is prefixed. This function
processes the system variable at runtime and rewrites the resulting URL accordingly.

Function Arguments

Function parameters whose value needs to be rewritten are classified
into 4 categories:

The first rule specifies that the first two parameters in the function
with name test need to be rewritten. Hence the first two
parameters of the test function are rewritten. The second rule specifies that
the first parameter of the window.open function needs to
be written. The URL within the window.open function is
prefixed with the Gateway URL and the base URL of the page that contains the
function parameters.

EXPRESSION Parameters

These parameters take an expression value, which when evaluated, results
in a URL.

The rule specifies that the first parameter of the jstest1 function
needs to be rewritten by considering this as an EXPRESSION function param.
In the sample page content, the first parameter is an expression that will
be evaluated only at runtime. Rewriter prefixes this expression with the psSRAPRewriter_convert_expression function. The expression is evaluated,
and the psSRAPRewriter_convert_expression function rewrites
the output at runtime.

Note –

In the above example, the variable test1 is not required as
a part of the JavaScript variable rule. The function rule for jstest1 takes
care of the rewriting.

DHTML Parameters

Function parameter whose value is HTML

Native JavaScript methods such as document.write() that
generate an HTML page dynamically fall under this category.

The first rule specifies that the first parameter in the function document.write needs to be rewritten. The second rule specifies
that the first parameter in the function document.writeln needs
to be rewritten. The third rule is a simple HTML rule that specifies that
all attributes with the name href need to be rewritten.
In the example, the DHTML parameter rules identify the parameters in the functions
that need to be rewritten. Then the HTML attribute rule is applied to actually
rewrite the identified parameter.

The first rule specifies that the second parameter of the function NavBarMenuItem which contains JavaScript needs is to be rewritten.
Within the JavaScript, the variable top.location also needs
to be rewritten. This variable is rewritten using the second rule.

Rules for XML Content

Web pages may contain XML content which in turn can contain URLs. XML
content that needs to be rewritten is classified into two categories:

The first line in the page content has an Attribute Example. The second line in the page content does not contain an attribute
with the attribute called name and value of attribute name to be src,
and hence no rewriting is done. To rewrite this also we need to have <TagText
tag="attribute"/>

Attribute

The rules for XML attributes are similar to the attribute rules for
HTML. The difference is that attribute rules of XML are cases sensitive while
HTML attribute rules are not. This is again due to case sensitivity built
into XML and not into HTML.