blob: 77996561a870c025eb06285621636f20ec2afc76 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/>
<!-- Purpose: ESC of non-ASCII chars in URI attribute values using method
cited in Section B.2.1 of HTML 4.0 Spec. -->
<xsl:template match="doc">
<html>
<head>
<title>
<xsl:value-of select="header"/>
</title>
</head>
<!-- Note the body/@background should be escaped as well, I think -->
<body background="file'%.gif">
<xsl:apply-templates select="list"/>
</body>
</html>
</xsl:template>
<xsl:template match="list">
<h1>List</h1>
<xsl:apply-templates select="list | item"/>
</xsl:template>
<!-- A simplistic template for testing performance of HTML escaping;
vaguely like what you might see in real life. Includes various
avt's interspersed with escaped characters and one non-escaped
attribute font/@color.
-->
<xsl:template match="item">
<br/>
spacer
<p>1. "&" <A HREF="&{.}"><xsl:copy-of select="text()"/></A></p>
<p>2. "<" <img src="<"></img></p>
<p>3. ">" <IMG src=">"></IMG></p>
<p>4. """ <img SRC=""{text()}"/></p>
<p>5. "'" <font color="'"><xsl:copy-of select="text()"/></font></p>
<p>6. "©" <a HREF="©"><xsl:value-of select="text()"/></a></p>
<p>7. "#" <A href='&{{text()}}between#after'>Note the amp-double-braces should be escaped differently</A></p>
<p>8. "¥" <A href="¥after"><xsl:value-of select="text()"/></A></p>
<p>9. " " <a href="before "><xsl:copy-of select="text()"/></a></p>
<p>10."%" <IMG SRC="{.}%"><xsl:value-of select="."/></IMG></p>
<p>11."	" <A href="beforeand	after">No value</A></p>
<p>12."" <A HREF="{.}after"><xsl:value-of select="."/></A></p>
<p>13."Ñ" <A href="Ñ">plain text</A></p>
<P>14."Œ" <A href="Œ">more plain text</A></P>
</xsl:template>
<!--
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-->
</xsl:stylesheet>
|