Skip to content

Instantly share code, notes, and snippets.

@bauhouse
Created November 18, 2011 05:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bauhouse/1375655 to your computer and use it in GitHub Desktop.
Save bauhouse/1375655 to your computer and use it in GitHub Desktop.
<data>
<hello>
<entry id="2">
<phrase>Hello</phrase>
<name>World</name>
</entry>
</hello>
</data>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
omit-xml-declaration="yes"
encoding="UTF-8"
indent="yes" />
<xsl:template match="/">
<html>
<head>
<xsl:apply-templates select="data/hello/entry" mode="head" />
</head>
<body>
<xsl:apply-templates select="data/hello/entry" mode="body" />
</body>
</html>
</xsl:template>
<xsl:template match="data/hello/entry" mode="head">
<title><xsl:call-template name="salutation" /></title>
</xsl:template>
<xsl:template match="data/hello/entry" mode="body">
<h1><xsl:call-template name="salutation" /></h1>
</xsl:template>
<xsl:template name="salutation">
<xsl:value-of select="phrase" />
<xsl:text>, </xsl:text>
<xsl:value-of select="name" />!
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment