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