Replacements
Support for external applications was removed from XperienCentral in version R29.3.
A replacement integrates links and style properties from XperienCentral into the HTML retrieved from an external application. XperienCentral includes several default replacements that perform common tasks necessary to render the HTML. For example, sometimes images are referenced by an internal path that is not available to XperienCentral and an external URL must be used to access the image. Similarly, hyperlinks in the HTML from the external application are relative and must be made absolute in order for them to properly function. In addition to the default replacements, you can also create new replacements to handle situations specific to your project.
In This Topic
Default XperienCentral Replacements
XperienCentral contains a number of default replacements that you can use to transform HTML retrieved from an external application. These are described in the table below:
Replacement | Description |
---|---|
WM — FORM with absolute action | Ensures that a form is not sent directly to the original application server through the absolute URL. The form is first handled by XperienCentral and then forwarded to the application server. In order to reintegrate the content where the link points to when it is followed, the original link is included using the wm_includeURL parameter.To view which application the link originates from, use the wm_elementid parameter. |
WM — FORM with relative action | Ensures that the form is not sent directly to the original application server through the relative URL. The form is first handled by XperienCentral and then forwarded to the application server. In order to reintegrate the content where the link points when it is followed, the original link is included using the wm_includeURL parameter. To view which application the link originates from, use the wm_elementid parameter. |
WM — Make all external links absolute | Ensures that all links except absolute links, links with java script: , and dummy links with #top within the content no longer point to the original URL but instead to the XperienCentral page's URL.In order to reintegrate the content where the link points to when followed, the original link is included as a wm_includeURL parameter. To view which application the link originates from, a wm_elementid parameter is included. |
WM — Make FRAME, src "..." absolute | Every frame has its own unique URL from which the content is retrieved. This replacement turns all relative URLs into absolute URLs. |
WM — Make IMG absolute | Turns all relative URLs that link to an image into an absolute URL. |
WM — Make INPUT, type="image" absolute | Turns all relative URLs that link to a button image into an absolute URL. |
WM — Make SCRIPT, src="..." absolute | Inserts a snippet of Javascript. |
WM — Transform name normalclass | "Normalclass" is a standard design template. With this replacement, the external application's appearance can be transformed using another design template. |
WM — Delete HTML head | Deletes the HTML HEAD from the external application so that the page's HTML HEAD will also be valid for the external application. This includes the HTML tag, the DOCTYPE tags, the LINK tags, and all the code between <HEAD> and </HEAD> . |
Creating a Replacement
To create a new replacement, follow these steps:
- Select "<New replacement>" from the drop-down list. New fields will appear below.
Define the following fields for the replacement:
Field Description Name The name of the replacement. This is the name that appears in the list of replacements in the WMReplacementsFilter
on the "External Applications" tab.Source regular expression A Java regular expression that defines the string to search for in the source (see regular expressions or examine the default XperienCentral replacements for more information). Replacement text The text that will replace the search string found in the target. This must take the form of a Java regular expression. The replacement text can contain parameters that are replaced by XperienCentral, for example "self", "urlBase", and "wm_elementid". Result Replacement text that contains the page and property replacements. If there are no page or property replacements, the result is the same as the replacement text.
WM — Make IMG absolute Turns all relative URLs that link to an image into an absolute URL. WM — Make INPUT, type="image" absolute Turns all relative URLs that link to an images as a button into an absolute URL. WM — Make SCRIPT, src="..." absolute Inserts a Javascript snippet. WM — Transform name normalclass "Normalclass" is a standard design template. With this replacement, the external application's appearance can be transformed using a customized design template. WM — Delete HTML head Delete the HTML HEAD
from the external application, so the page's HTMLHEAD
will also be valid for the external application. This includes theHTML
tag, theDOCTYPE
tags, theLINK
tags, and all the code between<HEAD>
and</HEAD>
.- In the "Source regular expression" field, enter the regular expression that defines what the replacement transforms.
- In the "Replacement text" field, enter a regular expression that performs the replacement.
- Click [Apply]. The result of the replacement text appears next to "Result".
Replacement Examples
Suppose you retrieve the following HTML code from the external application:
<html> <head> <title>test page for application integration</title> </head> <body> <a href="/index.html"target="_top"> <img src="logo.gif" width="75" height="25" border="0"> </a> </body> </html>
and you want to transform it so that it is correctly rendered in XperienCentral. In the example above, the HTML between the <a></a>
tags will be retained. The following three replacements need to be made:
- The superfluous HTML code needs to be removed (the
<html></html><head></head><title></title>
and<body></body>
tags). XperienCentral does not need these for rendering. - The reference to
index.html
has to be replaced with the URL of the home page (shown in red). - The reference to the
logo.gif
has to be replaced with a reference to an image.
After the replacements have been made, the HTML looks like this:
<a href="/web/show/id=26111/langid=43" target="_top"> <img src="/web/upload/46899_441_1151402457928-GX-LOGO-grijzehaken.jpg" width="75" height="25" border="0"> </a>
The transformation of the above HTML makes it suitable to be shown in XperienCentral. The regular expression that accomplishes the above replacements is shown below:
(?si)<html>.*?<a.*?/index.html.*?><img.*?logo.gif.*?></a>.*?</html>
In the above regular expression, (?si)
turns the code into one long, case insensitive line and .*?
is the starting point from which a string will be read in until the next .*?
is found.
The parts of the HTML that you want to keep can be turned into parameters by enclosing them in parentheses:
(?si)<html>.*?<a(.*?)/index.html(.*?)><img(.*?)logo.gif(.*?)></a>.*?</html>
In the target code these parameters can be referred to using the notation $1
for the first parameter, $2>
for the second parameter, and so forth. The replacement text for the above regular expression then becomes:
<a$1@homepage@$2><img$3@logo@$4></a>