Created
March 29, 2012 21:10
-
-
Save homelinen/2243849 to your computer and use it in GitHub Desktop.
Over the Top XPath Transform
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
<?xml version="1.0" encoding="UTF-8"?> | |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
<xsl:key name="actorKey" match="person" use="@aID"/> | |
<xsl:template match="/"> | |
<html> | |
<head> | |
<title>Movies</title> | |
</head> | |
<body> | |
<h1>Profit of Films Starring Jessica Alba</h1> | |
<p> | |
<xsl:for-each select="//actorID"> | |
<xsl:if test="key('actorKey', .)[name='Jessica Alba']"> | |
<p><span style="font-weight:bold"><xsl:value-of select="../../title" /> Profit:</span> | |
<xsl:if test="../../gross"> | |
<xsl:value-of select="../../gross - ../../budget"/> | |
</xsl:if> | |
<xsl:if test="not(../../gross)"> | |
-<xsl:value-of select="../../budget"/> | |
</xsl:if> | |
</p> | |
</xsl:if> | |
</xsl:for-each> | |
</p> | |
</body> | |
</html> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment