<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet>
<!-- 
test code:
 xsltproc opreport-op.xsl opreport-op.xml > opreport-op.html
 -->
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns="http://www.w3.org/1999/xhtml">

  <xsl:template match="/">
    <html>
      <head>
        <!-- link rel="stylesheet" type="text/css" href="./XXX.css" /-->
	<title><xsl:value-of select="/profile/@title"/></title>
      </head>
      <body>
	<h1><xsl:value-of select="/profile/@title"/></h1>
	<xsl:element name="ul">
	  <xsl:for-each select="/profile/binary">
	    <xsl:element name="li">
	      BINARY:<xsl:value-of select="@name"/>: 
	      <xsl:choose>
		<xsl:when test="count(symbol)>0">
		<!-- This is Kernel image, where module information is not available-->
		<xsl:value-of select="count"/>
		  <xsl:element name="ul">
		    <xsl:for-each select="symbol">
		      <xsl:element name="li">  
			      SYMBOL:
			<xsl:variable name="symboltable" select="@idref"/>
			<xsl:value-of select="/profile/symboltable/symboldata[attribute::id=$symboltable]/@name"/>
			: 
			<xsl:value-of select="count"/>
		      </xsl:element>
		    </xsl:for-each>
		  </xsl:element>
		</xsl:when>
		<xsl:when test="count(module)>0">
		  <!-- This is userland image.
		  try to search for symbol info and output -->
		  <xsl:element name="ul">
		    <xsl:for-each select="module">
		      <xsl:element name="li">
			MODULE:<xsl:value-of select="@name"/>: 
			<xsl:element name="ul">
			  <xsl:for-each select="symbol">
			    <xsl:element name="li">  
			      SYMBOL:
			      <xsl:variable name="symboltable" select="@idref"/>
			    <xsl:value-of select="/profile/symboltable/symboldata[attribute::id=$symboltable]/@name"/>
			      : 
			      <xsl:value-of select="count"/>
			    </xsl:element>
			  </xsl:for-each>
			</xsl:element>
		      </xsl:element>
		    </xsl:for-each>
		  </xsl:element>
		</xsl:when>
		<xsl:otherwise>
		  <!-- just output the value when module information is not available (happens with kernel module) -->
		  <xsl:value-of select="count"/>
		</xsl:otherwise>
	      </xsl:choose>
	    </xsl:element>
	  </xsl:for-each>
	</xsl:element>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>
