Skip to content

Instantly share code, notes, and snippets.

@brendo
Created January 22, 2017 03:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save brendo/82ce88129e00aa9f0bd5070e446c2085 to your computer and use it in GitHub Desktop.
Save brendo/82ce88129e00aa9f0bd5070e446c2085 to your computer and use it in GitHub Desktop.
XSLT and Entities
<!ENTITY world "world">
<!ENTITY copy "&#169;">
<!DOCTYPE xsl:stylesheet [
<!ENTITY world "world">
<!ENTITY copy "&#169;">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="no" method="html" indent='yes' />
<xsl:template match="/">
<xsl:text disable-output-escaping="yes">&lt;</xsl:text>!DOCTYPE html<xsl:text disable-output-escaping="yes">&gt;&#10;</xsl:text>
<head>
<title>Test</title>
</head>
<body>
<h1>Hello &world;</h1>
<p>Look at me using crazy entities like &copy;.</p>
</body>
</xsl:template>
</xsl:stylesheet>
<!DOCTYPE xsl:stylesheet [
<!ENTITY % entities SYSTEM "entities.dtd">
%entities;
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="no" method="html" indent='yes' />
<xsl:template match="/">
<xsl:text disable-output-escaping="yes">&lt;</xsl:text>!DOCTYPE html<xsl:text disable-output-escaping="yes">&gt;&#10;</xsl:text>
<head>
<title>Test</title>
</head>
<body>
<h1>Hello &world;</h1>
<p>Look at me using crazy entities like &copy;.</p>
</body>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment