Created
April 8, 2018 20:39
-
-
Save PanJarda/0fbf766144c4684827ac8e165af75cc6 to your computer and use it in GitHub Desktop.
XML->HTML over XSLT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<data> | |
<brand>Jennifer Doe</brand> | |
<title>About Me</title> | |
<routes> | |
<route href="/about">About Me</route> | |
<route href="/research">Research</route> | |
<route href="/publications">Publications</route> | |
<route href="/teaching">Teaching</route> | |
<route href="/gallery">Gallery</route> | |
<route href="/contact">Contact & Meet Me</route> | |
<route href="/download">Download CV</route> | |
</routes> | |
<bio> | |
A social psychologist and marketer, Jennifer Doe is the General Atlantic Professor of Marketing and Ormond Family Faculty at Stanford University’s Graduate School of Business. Her research spans time, money and happiness. She focuses on questions such as: What actually makes people happy, as opposed to what they think makes them happy? | |
</bio> | |
<academic_positions> | |
<position> | |
<start_year>2005</start_year> | |
<end_year>Present</end_year> | |
<name>General Atlantic Professor</name> | |
<place>Stanford University</place> | |
<department>Graduate School of Business</department> | |
</position> | |
<position> | |
<start_year>2005</start_year> | |
<end_year>Present</end_year> | |
<name>General Atlantic Professor</name> | |
<place>Stanford University</place> | |
<department>Graduate School of Business</department> | |
</position> | |
<position> | |
<start_year>2005</start_year> | |
<end_year>Present</end_year> | |
<name>General Atlantic Professor</name> | |
<place>Stanford University</place> | |
<department>Graduate School of Business</department> | |
</position> | |
</academic_positions> | |
</data> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> | |
<xsl:output method="html" /> | |
<xsl:template match="route"> | |
<li><a href="{@href}"><xsl:value-of select="."/></a></li> | |
</xsl:template> | |
<xsl:template match="routes"> | |
<nav> | |
<ul> | |
<xsl:apply-templates select="route"/> | |
</ul> | |
</nav> | |
</xsl:template> | |
<xsl:template match="position"> | |
<li> | |
<xsl:value-of select="start_year"/> - <xsl:value-of select="end_year"/><br/> | |
<strong><xsl:value-of select="name"/></strong><br/> | |
<i><xsl:value-of select="place"/></i><br/> | |
<xsl:value-of select="department"/> | |
</li> | |
</xsl:template> | |
<xsl:template match="academic_positions"> | |
<h2>Academic positions</h2> | |
<ul> | |
<xsl:apply-templates select="position"/> | |
</ul> | |
</xsl:template> | |
<xsl:template match="bio"> | |
<p><xsl:value-of select="."/></p> | |
</xsl:template> | |
<xsl:template match="/data"> | |
<html> | |
<head> | |
<title><xsl:value-of select="title"/> - <xsl:value-of select="brand"/></title> | |
</head> | |
<body> | |
<h1><xsl:value-of select="title"/></h1> | |
<xsl:apply-templates select="routes"/> | |
<xsl:apply-templates select="bio"/> | |
<xsl:apply-templates select="academic_positions"/> | |
</body> | |
</html> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment