caucho
Resin
FAQ
Reference Guide
JavaDoc
Demo
Tutorial

JSP page
Config
URLs
Database Forms
XTP Copy
Hello Tag
Vary Filter
HardCore
Mailing Forms
Beans
Cache
XSL Filter
run-at

Formatting
XTP Page
Strict XSL
JSP Tag Libraries with XTP
JSP Tag Libraries with StyleScript
 Link Rewriting

Formatting
XTP Copy
Strict XSL

Rewriting links to encode sessions is a tedious and error-prone task. If you use URL-encoded sessions, every <a> link and every <form> action needs a rewritten link using response.encodeURL(). XTP can rewrite those for you automatically.

stylesheet.xsl
<!-- make sure '<' is not printed as '&lt;' -->
$output(disable-output-escaping=>true);

<!-- copy input to output -->
*|@* <<
  $copy() <<
    $apply-templates(node()|@*);
  >>
>>

<!-- rewrite <a href> -->
a[@href] <<
  <a href='<%= response.encodeURL("{@href}") %>'>
    $apply-templates(node()|@*[name(.)!="href"]);
  </a>
>>

Your XTP page may look something like:

test.xtp
<?xml-stylesheet href='stylesheet.xsl'?>
<h1>My test</h1>

Adding: 2 + 2 = <%= 2 + 2 %>

<p>New? <%= session.isNew() %>

<p>And <a href='test.xtp'>linking</a>

The transformed file will look like:

<?xml-stylesheet href='stylesheet.xsl'?>
<h1>My test</h1>

Adding: 2 + 2 = <%= 2 + 2 %>

<p>New? <%= session.isNew() %>

<p>And <a href='<%= response.encodeURL("test.xtp") %>'>linking</a>

Formatting
XTP Copy
Strict XSL
Copyright © 1998-2001 Caucho Technology. All rights reserved.
Copyright © 1998-2001 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark, and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc.