blob: c1c2b43ef616d9a62abaa85417f0d7e9d1f379ea [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>EncodeURL Transformer</title>
<link href="http://purl.org/DC/elements/1.0/" rel="schema.DC">
<meta content="in @doctitle@" name="DC.Subject">
<meta content="Bernhard Huber" name="DC.Creator">
<meta content="This document describes the EncodeURL transformer." name="DC.Description">
</head>
<body>
<h1>EncodeURL Transformer</h1>
<p>
The encodeURL transformer emits encoded URLs.
This transformer applies encodeURL method to URLs.
You may want to use this transform to avoid doing the manually
encodeURL() call.
</p>
<p>
Usually this transformer is appended as last transformer before
the serialization process. In this case it is possible to encode
URLs introduced in the generator, and xslt transformer phase.
</p>
<p>
You can specify which attributes hold URL values in order to restrict
URL rewriting to specific attributes and values only. In the current implementation
you specify include, and exclude patterns as regular expressions, concatting
element-name-regexp + "/@" + attribute-name-regexp [ + "=" + attribute-value-regexp ]
whereas the part in brackets [] are optional.
</p>
<p>
The EncodeURLTransformer has several configuration options. These options
may be specified in the sitemap, or by each request.
</p>
<dl>
<dt>include-name</dt>
<dd>RE pattern for including attributes for encode URL rewriting,
The attribute values are encoded, if an
expressions of the form
<span class="codefrag">element-name-regexp/@attribute-name-regexp[=attribute-value-regexp]</span>
matches.
<br>
By default <span class="codefrag">include-name</span> is defined as
<span class="codefrag">.*/@href|.*/@action|frame/@src</span>.
</dd>
<dt>exclude-name</dt>
<dd>RE pattern for excluding attributes from encode URL rewriting,
The attribute values are not encoded, if an
expressions of the form
<span class="codefrag">element-name-regexp/@attribute-name-regexp[=attribute-value-regexp]</span>
matches.
<br>
By default <span class="codefrag">exclude-name</span> is defined as
<span class="codefrag">img/@src</span>.
</dd>
</dl>
<ul>
<li>Name : encodeURL</li>
<li>Class: org.apache.cocoon.transformation.EncodeURLTransformer</li>
<li>Cacheable: yes.</li>
</ul>
<p>
A simple example might help to use the EncodeURLTransformer effectivly:
</p>
<p>
Add the EncodeURLTransformer to the components in your sitemap.xmap
</p>
<pre class="code">
...
&lt;map:components&gt;
...
&lt;map:transformers default="xslt"&gt;
...
&lt;map:transformer name="encodeURL"
src="org.apache.cocoon.transformation.EncodeURLTransformer"&gt;
&lt;!-- default configuration, explicitly defined --&gt;
&lt;include-name&gt;.*/@href|.*/@action|frame/@src&lt;/include-name&gt;
&lt;exclude-name&gt;img/@src|(a/@href|iframe/@src)=.*adserver&lt;/exclude-name&gt;
&lt;/map:transformer&gt;
...
</pre>
<p>
Next define in your pipeline to use the EncodeURLTransformer
</p>
<pre class="code">
&lt;map:match pattern="*.xsp"&gt;
&lt;map:generate type="serverpages" name="docs/samples/xsp/{1}.xsp"/&gt;
&lt;map:transform src="stylesheets/page/simple-page2html.xsl"/&gt;
&lt;map:transform type="encodeURL"/&gt;
&lt;map:serialize/&gt;
&lt;/map:match&gt;
</pre>
<p>
In this example pipeline it is assumed that the attribute
<span class="codefrag">href</span> of element <span class="codefrag">a</span> contains an URL which should get
encoded.
Moreover the attribute <span class="codefrag">action</span> of any element contains an URL
which should get encoded, too.
Finally the attribute <span class="codefrag">src</span> of element
<span class="codefrag">frame</span> should get encoded, too.
</p>
<p>
The attribute <span class="codefrag">src</span> of element <span class="codefrag">img</span> is excluded from
encoding.
</p>
<p>
In other words, images are served regardless of the current session, in contrast
anchor links, form actions, and frame src are served depending on the current session.
</p>
<p>
The encoding itself applies the servlet method <span class="codefrag">response.encodeURL()</span>
upon the URL.
</p>
</body>
</html>