Created
October 14, 2016 21:12
-
-
Save carols10cents/cd58372b3ad460c32203e5abc2d32f21 to your computer and use it in GitHub Desktop.
This file contains 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
<?xml version="1.0"?> | |
<doc> | |
<album> | |
<title>Thriller</title> | |
<artist>Michael Jackson</artist> | |
</album> | |
<book> | |
<title>Little Women</title> | |
<author>Louisa May Alcott</author> | |
</book> | |
<album> | |
<title>Live Rust</title> | |
<artist>Neil Young</artist> | |
</album> | |
</doc> |
This file contains 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
<?xml version="1.0"?> | |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<xsl:template match="/"> | |
<html> | |
<body> | |
<table border="1"> | |
<tr> | |
<th>Title</th> | |
<th>Creator</th> | |
<th>Favorite?</th> | |
</tr> | |
<xsl:apply-templates select="*" /> | |
</table> | |
</body> | |
</html> | |
</xsl:template> | |
<xsl:template match="album[contains(title, 'Rust')]"> | |
<tr> | |
<td><xsl:value-of select="title" /></td> | |
<td><xsl:value-of select="artist" /></td> | |
<td>YES</td> | |
</tr> | |
</xsl:template> | |
<xsl:template match="album"> | |
<tr> | |
<td><xsl:value-of select="title" /></td> | |
<td><xsl:value-of select="artist" /></td> | |
<td /> | |
</tr> | |
</xsl:template> | |
<xsl:template match="book"> | |
<tr> | |
<td><xsl:value-of select="title" /></td> | |
<td><xsl:value-of select="author" /></td> | |
<td /> | |
</tr> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment