<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">

<!--
//****************************************************************
// You are free to copy the "XTree" scripts as long as you
// keep this copyright notice:
//
// original script concepts realized by
//     Author:  Emmanuele De Andreis (manudea@duemetri.it) May '2001
//     Located: http://manudea.duemetri.net/xtree/
//
// *** SEE <WhatsNew.txt> FOR A LISTING OF MODIFICATIONS MADE ***
//****************************************************************
-->


  <xsl:template match="/">
      <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="xtree">
    <HTML>
    	<HEAD>
		<H1>Materials - Example Ontology Visualisation</H1>
		<H2>Material costs are not now up to date</H2>
    		<link rel="stylesheet" href="2mxtree.css" />
			<xsl:if test="@target">
				<base>
					<xsl:attribute name="target"><xsl:value-of select="@target"/></xsl:attribute>
				</base>
			</xsl:if>

    	<SCRIPT><![CDATA[
		    //Open or close nodes
		    
    		function SetNode(nodename) {
    			
    			if (eval("documents" + nodename + ".style.display == 'none';")) {
					// Open
	    			eval("image" + nodename + ".src = 'images/minus.gif'");
				eval("nodeimage" + nodename + ".src = 'images/open.gif'");
				eval("documents" + nodename + ".style.display = 'block'");
		
    				}
				else {
					// Close
	    			eval("image" + nodename + ".src = 'images/plus.gif'");
	    			eval("nodeimage" + nodename + ".src = 'images/closed.gif'");
	    			eval("documents" + nodename + ".style.display = 'none'");
    				}
	    		}
       		]]>//</SCRIPT>
    	</HEAD>
    	<BODY>
		  <nobr>
        	<xsl:apply-templates/>
		  </nobr>
        </BODY>
    </HTML>
  </xsl:template>

  
  <xsl:template match="node">
      <DIV class="nodeheader">
      	<xsl:attribute name="id">Node<xsl:value-of select="@id"/></xsl:attribute>
      	<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
      	
		<!--  '+' or '-' symbols for an open or closed node -->
		<xsl:choose>
			<xsl:when test="@opened[.='1']">
		    	<IMG SRC="images/minus.gif">
		      		<xsl:attribute name="id">image<xsl:value-of select="@id"/></xsl:attribute>
					<xsl:attribute name="onClick">SetNode('<xsl:value-of select="@id"/>');</xsl:attribute>
		    	</IMG>
		    	<IMG SRC="images/open.gif">
		      		<xsl:attribute name="id">nodeimage<xsl:value-of select="@id"/></xsl:attribute>
					<xsl:attribute name="onDblClick">SetNode('<xsl:value-of select="@id"/>');</xsl:attribute>
		    	</IMG>
				
				
		    </xsl:when>
    		<xsl:otherwise>
				<IMG SRC="images/plus.gif">
		      		<xsl:attribute name="id">image<xsl:value-of select="@id"/></xsl:attribute>
					<xsl:attribute name="onClick">SetNode('<xsl:value-of select="@id"/>');</xsl:attribute>
				</IMG>
		    	<IMG SRC="images/closed.gif">
		      		<xsl:attribute name="id">nodeimage<xsl:value-of select="@id"/></xsl:attribute>
					<xsl:attribute name="onDblClick">SetNode('<xsl:value-of select="@id"/>');</xsl:attribute>
		    	</IMG>
		    </xsl:otherwise>
		</xsl:choose>

		<xsl:choose>
			<xsl:when test="@url">
		      <A>
				<xsl:attribute name="HREF"><xsl:value-of select="@url"/></xsl:attribute>
				<xsl:if test="@target">
					<xsl:attribute name="target"><xsl:value-of select="@target"/></xsl:attribute>
				</xsl:if>
		        <xsl:value-of select="@name"/>
		      </A>
 		    </xsl:when>
    		<xsl:otherwise>
		        <xsl:value-of select="@name"/>
		    </xsl:otherwise>
		</xsl:choose>
   
      </DIV>
      
      <DIV class="nodedocuments">
      	<xsl:attribute name="id">documents<xsl:value-of select="@id"/></xsl:attribute>
      
 		<xsl:choose>
			<xsl:when test="@opened[.='1']">
		    	<xsl:attribute name="Style">display: block; Margin-left: 16;</xsl:attribute>
		    </xsl:when>
    		<xsl:otherwise>
		    	<xsl:attribute name="Style">display: none; Margin-left: 16;</xsl:attribute>
		    </xsl:otherwise>
		</xsl:choose>
       	
      	<xsl:apply-templates />
      </DIV>
   </xsl:template>


  <xsl:template match="document">
     <DIV Class="document">
     	<IMG SRC="images/blank.gif" />
     	<IMG SRC="images/document.gif" />
     	
		<xsl:choose>
			<xsl:when test="@url">
		      <A>
				<xsl:attribute name="HREF"><xsl:value-of select="@url"/></xsl:attribute>
				<xsl:if test="@target">
					<xsl:attribute name="target"><xsl:value-of select="@target"/></xsl:attribute>
				</xsl:if>
		        <xsl:apply-templates />
		      </A>
 		    </xsl:when>
    		<xsl:otherwise>
		        <xsl:apply-templates />
		    </xsl:otherwise>
		</xsl:choose>
     	
     </DIV>
  </xsl:template>
  
  <xsl:template match="text()">
  	<xsl:value-of />
  </xsl:template>

</xsl:stylesheet>

