<?xml version="1.0"?> 
<xsl:stylesheet 
     version="1.0" 
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:key name="nodekey" match="/graph/node" use="@id"/>
<xsl:key name="tedgekey" match="/graph/edge" use="@target"/>

<xsl:output indent="yes" method="html"/>

<xsl:template match="text()">
</xsl:template>

<xsl:template match="graph">
<html>
<head>
<title>Broken Links</title>
</head>
<body bgcolor="#ffffff">
<h1>List of Broken Links</h1>
<b>Last Update :</b>
<br></br>
<hr></hr>
This Report gives a List of unique Broken Links (http 
code 404). Each broken link is reported with the HTML page and the caption 
where the broken link is found.
<hr></hr>
<ol>
     <xsl:apply-templates select="node"/>
</ol>
</body>
</html><xsl:text>
</xsl:text>
</xsl:template>

<xsl:template match="node">
     <xsl:apply-templates select="att"/>
</xsl:template>

<xsl:template match="att[@name='code' and @value='404']">
	<xsl:variable name="tid">
	     <xsl:value-of select="../@id"/>
	</xsl:variable>
	<xsl:variable name="tlabel">
	     <xsl:value-of select="../@label"/>
	</xsl:variable>

	<xsl:for-each select="key('tedgekey',$tid)">
	     <xsl:variable name="sid">
	          <xsl:value-of select="@source"/>
	     </xsl:variable>
	     <xsl:variable name="cap">
	          <xsl:value-of select="@label"/>
	     </xsl:variable>
	     <xsl:for-each select="key('nodekey',$sid)">
         	  <xsl:variable name="slabel">
	             <xsl:value-of select="@label"/>
	          </xsl:variable>
                  <xsl:for-each select="att[@name='title']">
         	     <xsl:variable name="tit">
		        <xsl:value-of select="@value"/>
	             </xsl:variable>
<li>
<pre><xsl:value-of select="$tlabel"/></pre>
<pre><b>Caption:</b><xsl:value-of select="$cap"/></pre>
<a href="{$slabel}"><xsl:value-of select="$tit"/><br></br>
<xsl:value-of select="$slabel"/></a>
</li>
	          </xsl:for-each>
	     </xsl:for-each>
	</xsl:for-each>
</xsl:template>	      

</xsl:stylesheet>
