Skip to content

Instantly share code, notes, and snippets.

@homelinen
Created March 29, 2012 21:10
Show Gist options
  • Save homelinen/2243849 to your computer and use it in GitHub Desktop.
Save homelinen/2243849 to your computer and use it in GitHub Desktop.
Over the Top XPath Transform
<?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