📄 xtp-page.xtp
字号:
<s1 title="Link Rewriting"><p>Rewriting links to encode sessions is a tedious and error-prone task.If you use URL-encoded sessions, every <a> link and every <form> actionneeds a rewritten link using <var/response.encodeURL()/>. XTP can rewritethose for you automatically.</p><example title="stylesheet.xsl"><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <!-- make sure '<' is not printed as '&lt;' --> <xsl:output disable-output-escaping='true'/> <!-- copy input to output --> <xsl:template match='*|@*'> <xsl:copy> <xsl:apply-templates select='node()|@*'/> </xsl:copy> </xsl:template> <!-- rewrite <a href> --> <xsl:template match="a[@href]"> <a href='<%= response.encodeURL("{@href}") %>'> <xsl:apply-templates select="node()|@*[name(.)!="href"]"/> </a> </xsl:template></xsl:stylesheet></example><p>Your XTP page may look something like:</p><example title='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></example><p>The transformed file will look like:</p><results><?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></results></s1>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -