Skip to content

Instantly share code, notes, and snippets.

@amundo
Created September 4, 2018 15:19
Show Gist options
  • Save amundo/50ce2d2fd6b947f167345e473034ff47 to your computer and use it in GitHub Desktop.
Save amundo/50ce2d2fd6b947f167345e473034ff47 to your computer and use it in GitHub Desktop.
an xml file with an xsl “stylesheet”
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="movies.xsl" ?>
<collection>
<movie>
<title>Happy Gilmore</title>
<year>1996</year>
<genre>comedy</genre>
</movie>
<movie>
<title>Rango</title>
<year>2011</year>
<genre>anime</genre>
</movie>
<movie>
<title>Three Kings</title>
<year>1999</year>
<genre>action</genre>
</movie>
</collection>
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/collection">
<html>
<head>
<meta charset="utf-8" />
<title>movies</title>
<style>
body {background:tan;}
ul{ margin: 1em; }
</style>
</head>
<body>
<xsl:for-each select="movie">
<ul>
<li>
<xsl:value-of select="title" />
</li>
<li>
<xsl:value-of select="year" />
</li>
<li>
<xsl:value-of select="genre" />
</li>
</ul>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
@amundo
Copy link
Author

amundo commented Sep 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment