<?xml version="1.0" encoding="windows-1250"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">

<!-- David Cuyler, Sandia National Laboratories -->
<!-- Generic XSL Stylesheet to display Repository Output XML (XMI) as HTML -->
<!-- Written for interpretation by MS Internet Explorer Version: 5.00.2314.1003 -->

   <!-- The template for root - forms the HTML start and end tags -->
   <xsl:template match="/">
      <HTML>
      <HEAD>
      <META http-equiv="Content-Style-Type" content="text/css" />
      <title>XMI Viewer</title>
      <!-- <LINK rel="stylesheet" href="xml.css" /> -->
      <STYLE>
         BODY { color:navy; background:white; font-family:sans-serif }
         .root { color:navy; margin-left:5 }
         .node { color:navy; margin-left:8 }
         .textnode { color:green; margin-left:15 }
         .attribute { font-size:xx-small; color:gray; margin-left:15 }
         .stname { font-size:xx-small }
         .textval { font-weight:bold }
         .attrval { font-weight:bold }
         .divider { height:1px }
         .header { color:navy; margin-left:5 }
         .collection { color:teal; margin-left:5 }
         .element { color:navy; margin-left:5 }
         .majorelement { color:navy; margin-left:5; border:thin ridge lightcyan }
         .ownerelement { color:navy; margin-left:5; border:thin ridge lightcyan }
         .tvcollection { font-size:xx-small; color:teal; margin-left:20 }
         .fact { margin-left:20 }
         .factlist { font-size:small; margin-left:20 }
         .generalization { margin-left:20 }
         .classifier { margin-left:20 }
         .abstract { font-style:italic }
         .taggedvalue { font-size:xx-small; color:navy }
         .regular { color:navy; margin-left:15 }
         .elemref { color:navy; margin-left:15 }
         .subtype { background-color:#E0E0E0 }
         .supertype { background-color:#E0E0E0 }
      </STYLE>
      </HEAD>
      <BODY>
      <DIV class="header">
         <a> <xsl:attribute name="name"><xsl:eval>formatNumber(uniqueID(this), "#")</xsl:eval></xsl:attribute>
         <h2>XMI Viewer</h2></a>
         <xsl:apply-templates select="/*"/>
      </DIV>
      </BODY>
      </HTML>
   </xsl:template>

   <!-- generic template for any object not covered by the rest (won't be used much, if at all) -->
   <xsl:template match="*">
      <xsl:apply-templates select="./*"/>
   </xsl:template>

   <!-- template for nodes with unrecognized attributes  -->
   <xsl:template match="*[@name|@xmi.name|@XMI.name]">
      <DIV class="node">
      <xsl:node-name />
      <!-- display node attributes  -->
      <xsl:for-each select="./attribute()">
         <SPAN class="attribute">
         <xsl:node-name />=<SPAN class="attrval">"<xsl:value-of />"</SPAN>
         </SPAN>
      </xsl:for-each>
      <xsl:apply-templates select="./*"/>
      </DIV>
   </xsl:template>
   
   <!-- template for miscellaneous attributes  -->
   <!--
   <xsl:template match="(@*)">
         <SPAN class="attribute">
         <xsl:node-name />=<SPAN class="attrval">"<xsl:value-of />" </SPAN>
         </SPAN>
   </xsl:template>
   -->
   
   <!-- template for name attributes  -->
   <!--
   <xsl:template match="(@name|@xmi.name|@XMI.name)">
         <SPAN class="attribute">
         name=<SPAN class="attrval">"<xsl:value-of />" </SPAN>
         </SPAN>
   </xsl:template>
   -->
   
   <!-- process the various link types -->
   <xsl:template match="(@xmi.idref|@XMI.idref)">
      <xsl:if match=".[../(@xmi.id|@XMI.id)]">
         <xsl:attribute name="name"><xsl:value-of select="../(@xmi.id|@XMI.id)"/></xsl:attribute>
      </xsl:if>
      <xsl:attribute name="href">
      <xsl:choose> <!-- internal or external link -->
         <xsl:when match="(@xmi.idref|@XMI.idref)">#<xsl:value-of /></xsl:when>
         <xsl:otherwise><xsl:value-of /></xsl:otherwise>
      </xsl:choose>
      </xsl:attribute>
      <SPAN class="ref">
      <xsl:choose> <!-- in priority order for the displayed text of the link -->
         <xsl:when match=".[../@title>'']"><xsl:value-of select="../@title"/></xsl:when>
         <xsl:when match=".[../@content-title>'']"><xsl:value-of select="../@content-title"/></xsl:when>
         <xsl:when match=".[../(@xmi.name|@XMI.name)>'']"><xsl:value-of select="../(@xmi.name|@XMI.name)"/></xsl:when>
         <xsl:when match=".[../@name>'']"><xsl:value-of select="../@name"/></xsl:when>
         <xsl:when match=".[../@role>'']"><xsl:value-of select="../@role"/>.<xsl:value-of select="../(@xmi.idref|@href|@XMI.idref|@target)"/></xsl:when>
         <xsl:otherwise>
            <xsl:for-each select="//*[(@xmi.id|@XMI.id)=context()]">
               <xsl:choose>
                  <xsl:when match=".[UML:ModelElement.name > '   ']"><xsl:value-of select="UML:ModelElement.name"/></xsl:when>
                  <xsl:otherwise>ref <xsl:value-of select="(@xmi.id|@XMI.id)"/></xsl:otherwise>
               </xsl:choose>
            </xsl:for-each>
         </xsl:otherwise>
      </xsl:choose>
      </SPAN>
   </xsl:template>
   
   <!-- process the various link types -->
   <xsl:template match="(@href|@target)">
      <xsl:if match=".[../(@xmi.id|@XMI.id)]">
         <xsl:attribute name="name"><xsl:value-of select="../(@xmi.id|@XMI.id)"/></xsl:attribute>
      </xsl:if>
      <xsl:attribute name="href">
      <xsl:choose> <!-- internal or external link -->
         <xsl:when match="(@xmi.idref|@XMI.idref)">#<xsl:value-of /></xsl:when>
         <xsl:otherwise><xsl:value-of /></xsl:otherwise>
      </xsl:choose>
      </xsl:attribute>
      <SPAN class="ref">
      <xsl:choose> <!-- in priority order for the displayed text of the link -->
         <xsl:when match=".[../@title>'']"><xsl:value-of select="../@title"/></xsl:when>
         <xsl:when match=".[../@content-title>'']"><xsl:value-of select="../@content-title"/></xsl:when>
         <xsl:when match=".[../(@xmi.name|@XMI.name)>'']"><xsl:value-of select="../(@xmi.name|@XMI.name)"/></xsl:when>
         <xsl:when match=".[../@name>'']"><xsl:value-of select="../@name"/></xsl:when>
         <xsl:when match=".[../@role>'']"><xsl:value-of select="../@role"/>.<xsl:value-of select="../(@xmi.idref|@href|@XMI.idref|@target)"/></xsl:when>
         <xsl:when match=".[../@xmi.idref>'']">Ref<xsl:value-of select="../@xmi.idref"/></xsl:when>
         <xsl:when match=".[../@href>'']">Ref<xsl:value-of select="../@href"/></xsl:when>
         <xsl:when match=".[../@XMI.idref>'']">Ref<xsl:value-of select="../@XMI.idref"/></xsl:when>
         <xsl:when match=".[../@target>'']">Ref<xsl:value-of select="../@target"/></xsl:when>
         <xsl:otherwise><xsl:value-of /></xsl:otherwise>
      </xsl:choose>
      </SPAN>
   </xsl:template>
   
   <xsl:template match="(@xmi.id|@XMI.id)">
      <xsl:attribute name="name"><xsl:value-of /></xsl:attribute>
      <SPAN class="elhead"><b>
      <xsl:choose>
         <xsl:when match=".[../UML:ModelElement.name]">
            <xsl:value-of select="../UML:ModelElement.name"/>
         </xsl:when>
         <xsl:when match=".[../UML:TaggedValue.tag]">
            <xsl:value-of select="../UML:TaggedValue.tag"/>
         </xsl:when>
         <xsl:when match=".[../@xmi.label]">
            <xsl:value-of select="../@xmi.label"/><xsl:value-of />
         </xsl:when>
         <xsl:otherwise>
            <xsl:value-of />
         </xsl:otherwise>
      </xsl:choose>
      </b></SPAN>
   </xsl:template>
   
   <!-- turn elements which reference other elements into internal HREF anchors -->
   <xsl:template match="*[(@xmi.idref|@XMI.idref|@href|@target) $and$ $not$ (@xmi.id|@XMI.id)]">
      <DIV class="elemref">
      <xsl:node-name /> :
      <a><xsl:apply-templates select="./(@xmi.idref|@XMI.idref|@href|@target)"/></a>
      <xsl:apply-templates select="./*"/>
      </DIV>
   </xsl:template>
   
   <!-- display a collection if it's got stuff -->
   <xsl:template match="*[($not$(@xmi.idref|@XMI.idref|@href|@target))$and$($not$(@xmi.id|@XMI.id))]">
      <!-- <xsl:if match=".[*]"> -->
         <DIV class="collection">
         <HR class="divider" />
         <a> <xsl:attribute name="name"><xsl:eval>formatNumber(uniqueID(this), "#")</xsl:eval></xsl:attribute>
            <SPAN class="clhead"><xsl:node-name /></SPAN></a>
         <xsl:for-each select="./attribute()">
            <SPAN class="attribute">
            <xsl:node-name />=<SPAN class="attrval">"<xsl:value-of />"</SPAN>
            </SPAN>
         </xsl:for-each>
         <xsl:apply-templates select="./*"/> 
         </DIV>
      <!-- </xsl:if> -->
   </xsl:template>
   
   <!-- display the value of each text node (not a collection or identified object) as a list item -->
   <xsl:template match="*[textnode() $and$ $not$ (@xmi.id|@XMI.id)]">
      <DIV class="regular">
         <xsl:node-name /> = <SPAN class="textval"><xsl:value-of /></SPAN>
      </DIV>
   </xsl:template>

   <!-- display the value of each value node (not a collection or identified object) as a list item -->
   <xsl:template match="*[(@xmi.value|@XMI.value) $and$ $not$ (@xmi.id|@XMI.id)]">
      <DIV class="regular">
         <xsl:node-name /> = <SPAN class="textval"><xsl:value-of select="@xmi.value|@XMI.value" /></SPAN>
      </DIV>
   </xsl:template>

   <!-- display identified elements which may also reference other elements -->
   <xsl:template match="*[@xmi.id|@XMI.id]">
     <DIV> <xsl:attribute name="class">
            <xsl:choose>
               <xsl:when match=".[$not$ node()]"></xsl:when>
               <xsl:when match="UML:UseCase|UML:Component|UML:Node|UML:Constraint|UML:Stereotype">majorelement</xsl:when>
               <xsl:when match="UML:Package[$not$ ownedElement]">majorelement</xsl:when>
               <!-- <xsl:when match="Package[$not$ ownedElement/*/ownedElement]">ownerelement</xsl:when> -->
               <xsl:otherwise>element</xsl:otherwise>
            </xsl:choose>
         </xsl:attribute>
         <xsl:choose>
            <xsl:when match=".[$not$ node()]"></xsl:when>
            <xsl:when match="UML:UseCase|UML:Component|UML:Node|UML:Constraint|UML:Stereotype"></xsl:when>
            <xsl:when match="UML:Package[$not$ ownedElement]"></xsl:when>
            <!-- <xsl:when match="Package[$not$ ownedElement/*/ownedElement]"></xsl:when> -->
            <xsl:otherwise><HR class="divider" /></xsl:otherwise>
         </xsl:choose>
         <xsl:choose>
            <xsl:when match=".[(@xmi.idref|@XMI.idref|@href|@target)]"> 
               <a><xsl:apply-templates select="./(@xmi.idref|@XMI.idref|@href|@target)"/></a>
            </xsl:when>
            <xsl:otherwise>
               <a><xsl:apply-templates select="./(@xmi.id|@XMI.id)"/></a>
            </xsl:otherwise>
         </xsl:choose>
				 <xsl:choose>
				   <xsl:when test="@stereotype">
             <xsl:apply-templates select="@stereotype"/>
				   </xsl:when>
					 <xsl:otherwise>: <xsl:node-name /> </xsl:otherwise>
         </xsl:choose>
         <xsl:apply-templates select="./*"/>
      </DIV>
   </xsl:template>
   
   <!-- special case: TaggedValues collection - only display if at least one tag has a value -->
   <xsl:template match="UML:ModelElement.taggedValue">
      <xsl:if match=".[$any$ ./UML:TaggedValue/UML:TaggedValue.value $gt$ ' ']">
         <DIV class="tvcollection">
            <HR class="divider" />
            <a> <xsl:attribute name="name"><xsl:eval>formatNumber(uniqueID(this), "#")</xsl:eval></xsl:attribute>Properties</a>
               <table border="1" border-color="gray">
							   <!-- <thead><tr class="taggedvalue"><th>Tag</th><th>Value</th></tr></thead> -->
							   <tbody><xsl:apply-templates select="UML:TaggedValue"/></tbody>
							 </table> 
         </DIV>
      </xsl:if>
   </xsl:template>

   <!-- special case: display a tagged value only if it has an associated value -->
   <!-- and if the Tag is a URL, make it an external href  -->
   <xsl:template match="UML:TaggedValue[$not$ (@xmi.idref|@XMI.idref|@href)]">
      <xsl:if match=".[(UML:TaggedValue.value $ge$ ' ') $and$ (UML:TaggedValue.value $ne$ 'False')]">
			   <tr class="taggedvalue"> 
				    <td><a> <xsl:attribute name="name"><xsl:value-of select="(@xmi.id|@XMI.id)"/></xsl:attribute>
            <xsl:value-of select="UML:TaggedValue.tag"/> </a></td>
            <td><xsl:choose>
               <xsl:when match=".[tag $eq$ 'URL']">
                  <a> <xsl:attribute name="href"><xsl:value-of select="UML:TaggedValue.value"/></xsl:attribute>
                     <SPAN class="ref"><xsl:value-of select="UML:TaggedValue.value"/></SPAN></a>
               </xsl:when>
               <xsl:otherwise>
                  <SPAN class="textval"><xsl:value-of select="UML:TaggedValue.value"/></SPAN>
               </xsl:otherwise>
            </xsl:choose></td>
				 </tr>
      </xsl:if>
   </xsl:template>
   
   <!-- special case: ownedElement collection - only display if at least one tag has a value -->
   <xsl:template match="UML:Namespace.ownedElement">
         <DIV class="collection">
            <xsl:apply-templates select="./*"/> 
         </DIV>
   </xsl:template>

   <!-- special case: Classifier.participant collection  -->
   <xsl:template match="UML:Classifier.participant">
     <DIV class="factlist">
         <HR class="divider" />Roles Played
	  	   <TABLE border="1" border-color="gray">
  		  	 <THEAD>
  	  		   <TR>
	  	  	     <TH>Role</TH><TH>Fact</TH>
  	  	  	 </TR>
		  	   </THEAD>
  		     <TBODY font-size="smaller">
	  	       <xsl:for-each select="UML:AssociationEnd">
    	  		  <TR>
  	    	  	 <xsl:for-each select="//*[@xmi.id=context()/@xmi.idref]">
	  	      	   <TD><a> <xsl:attribute name="href">#<xsl:value-of select="@xmi.id"/></xsl:attribute><xsl:value-of select="UML:ModelElement.name"/></a></TD>
  	  	    	   <TD><a> <xsl:attribute name="href">#<xsl:value-of select="../../@xmi.id"/></xsl:attribute><xsl:value-of select="../../UML:ModelElement.name"/></a></TD>
    	  	  	 </xsl:for-each>
	    		    </TR>
  		    	 </xsl:for-each>
			     </TBODY>
  			 </TABLE>
     </DIV>
   </xsl:template>

   <!-- special case: GeneralizableElement.generalization collection  -->
   <xsl:template match="UML:GeneralizableElement.generalization">
     <DIV class="factlist">
         <HR class="divider" />Supertypes
	  	   <TABLE border="1" border-color="gray">
  		  	 <THEAD>
  	  		   <TR>
	  	  	     <TH>Supertype</TH><TH>Generalization</TH>
  	  	  	 </TR>
		  	   </THEAD>
  		     <TBODY font-size="smaller">
	  	       <xsl:for-each select="UML:Generalization">
    	  		  <TR>
  	    	  	 <xsl:for-each select="//*[@xmi.id=context()/@xmi.idref]">
	  	      	   <TD><a> <xsl:attribute name="href">#<xsl:value-of select="@parent"/></xsl:attribute><xsl:value-of select="//*[@xmi.id=context()/@parent]/UML:ModelElement.name"/></a></TD>
	  	      	   <TD><a> <xsl:attribute name="href">#<xsl:value-of select="@xmi.id"/></xsl:attribute><xsl:value-of select="UML:ModelElement.name"/></a></TD>
    	  	  	 </xsl:for-each>
	    		    </TR>
  		    	 </xsl:for-each>
			     </TBODY>
  			 </TABLE>
     </DIV>
   </xsl:template>

   <!-- special case: Stereotype.extendedElement collection  -->
   <xsl:template match="UML:Stereotype.extendedElement">
     <DIV class="factlist">
         <HR class="divider" />
	  	   <TABLE border="1" border-color="gray">
  		  	 <THEAD>
  	  		   <TR>
	  	  	     <TH>Extended Element</TH>
  	  	  	 </TR>
		  	   </THEAD>
  		     <TBODY font-size="smaller">
	  	       <xsl:for-each select="UML:ModelElement">
    	  		  <TR>
  	    	  	 <xsl:for-each select="//*[@xmi.id=context()/@xmi.idref]">
	  	      	   <TD><a> <xsl:attribute name="href">#<xsl:value-of select="@xmi.id"/></xsl:attribute>
								   <xsl:value-of select="UML:ModelElement.name"/></a>
								 </TD>
    	  	  	 </xsl:for-each>
	    		    </TR>
  		    	 </xsl:for-each>
			     </TBODY>
  			 </TABLE>
     </DIV>
   </xsl:template>

   <!-- special case: Constraint.constrainedElement collection  -->
   <xsl:template match="UML:Constraint.constrainedElement">
     <DIV class="factlist">
         <HR class="divider" />
	  	   <TABLE border="1" border-color="gray">
  		  	 <THEAD>
  	  		   <TR>
	  	  	     <TH>Constrained Element</TH>
  	  	  	 </TR>
		  	   </THEAD>
  		     <TBODY font-size="smaller">
	  	       <xsl:for-each select="UML:ModelElement">
    	  		  <TR>
  	    	  	 <xsl:for-each select="//*[@xmi.id=context()/@xmi.idref]">
	  	      	   <TD><xsl:apply-templates select="./@stereotype"/> 
								   <a> <xsl:attribute name="href">#<xsl:value-of select="@xmi.id"/></xsl:attribute>
								   <xsl:value-of select="UML:ModelElement.name"/></a>
								 </TD>
    	  	  	 </xsl:for-each>
	    		    </TR>
  		    	 </xsl:for-each>
			     </TBODY>
  			 </TABLE>
     </DIV>
   </xsl:template>

   <xsl:template match="UML:Stereotype[(@xmi.idref|@XMI.idref|@href) $and$ $not$ (@xmi.id|@XMI.id)]">
      <SPAN class="stname">&#171;<a><xsl:apply-templates select="./(@xmi.idref|@XMI.idref|@href|@target)"/></a>&#187;</SPAN>
   </xsl:template>
   
   <!-- display Stereotypes with extended elements -->
   <xsl:template match="UML:Stereotype[@xmi.id|@XMI.id]">
      <xsl:if match=".[UML:Stereotype.extendedElement]">
         <DIV class="majorelement">Stereotype: &#171;
            <xsl:apply-templates select="./@stereotype"/>
            <xsl:choose>
               <xsl:when match=".[(@xmi.idref|@XMI.idref|@href|@target)]"> 
                  <a><xsl:apply-templates select="./(@xmi.idref|@XMI.idref|@href|@target)"/></a>
               </xsl:when>
               <xsl:otherwise>
                  <a><xsl:apply-templates select="./(@xmi.id|@XMI.id)"/></a>
               </xsl:otherwise>
            </xsl:choose>&#187;
            <br/>Base Class: <xsl:value-of select="UML:Stereotype.baseClass" />
            <xsl:apply-templates select="./UML:ModelElement.taggedValue"/>
            <xsl:apply-templates select="UML:Stereotype.extendedElement"/>
         </DIV>
      </xsl:if>
   </xsl:template>
   
   <!-- display Generalizations -->
   <xsl:template match="UML:Generalization[@xmi.id|@XMI.id]">
      <DIV class="majorelement">Generalization:
         <xsl:apply-templates select="./@stereotype"/>
         <xsl:choose>
            <xsl:when match=".[(@xmi.idref|@XMI.idref|@href|@target)]">
               <a><xsl:apply-templates select="./(@xmi.idref|@XMI.idref|@href|@target)"/></a>
            </xsl:when>
            <xsl:otherwise>
               <a><xsl:apply-templates select="./(@xmi.id|@XMI.id)"/></a>
            </xsl:otherwise>
         </xsl:choose>
         <!-- : <xsl:node-name /> -->
         <xsl:apply-templates select="./UML:ModelElement.taggedValue"/>
         <DIV class="generalization">
            <a><xsl:apply-templates select="@child"/></a>
             --&gt;
            <a><xsl:apply-templates select="@parent"/></a>
         </DIV>
         <!-- <xsl:apply-templates select="./*"/> -->
      </DIV>
   </xsl:template>
   
   <!-- display Dependencies -->
   <xsl:template match="UML:Dependency[@xmi.id|@XMI.id]">
      <DIV class="majorelement">
         <xsl:apply-templates select="./@stereotype"/>
         <xsl:choose>
            <xsl:when match=".[(@xmi.idref|@XMI.idref|@href|@target)]">
               <a><xsl:apply-templates select="./(@xmi.idref|@XMI.idref|@href|@target)"/></a>
            </xsl:when>
            <xsl:otherwise>
               <a><xsl:apply-templates select="./(@xmi.id|@XMI.id)"/></a>
            </xsl:otherwise>
         </xsl:choose>
         <xsl:apply-templates select="./UML:ModelElement.taggedValue"/>
         <DIV class="generalization">
            <a><xsl:apply-templates select="./client/*/(@xmi.idref|@XMI.idref|@href|@target)"/></a>
             ----&gt;
            <a><xsl:apply-templates select="./supplier/*/(@xmi.idref|@XMI.idref|@href|@target)"/></a>
         </DIV>
         <!-- <xsl:apply-templates select="./*"/> -->
      </DIV>
   </xsl:template>
	 
   <!-- display UML Associations -->
   <xsl:template match="(UML:Association|UML:AssociationClass)[@xmi.id|@XMI.id]">
      <DIV class="majorelement">
				 <xsl:apply-templates select="./@stereotype"/>
         <xsl:choose>
            <xsl:when match=".[(@xmi.idref|@XMI.idref|@href|@target)]">
               <a><xsl:apply-templates select="./(@xmi.idref|@XMI.idref|@href|@target)"/></a>
            </xsl:when>
            <xsl:otherwise>
               <a><xsl:apply-templates select="./(@xmi.id|@XMI.id)"/></a>
            </xsl:otherwise>
         </xsl:choose> 
         <xsl:apply-templates select="./UML:ModelElement.taggedValue"/>

         <xsl:if test="./*">
				 <DIV class="fact">Roles and Examples
         <TABLE BORDER="2" CELLSPACING="0" bgcolor="white" bordercolor="#C0C0C0">
         <TBODY>
         <TR>
         <xsl:for-each select="./UML:Association.connection/UML:AssociationEnd">
            <TH><xsl:apply-templates select="@stereotype"/><br />
						<a> <xsl:attribute name="name"><xsl:value-of select="@xmi.id" /></xsl:attribute><xsl:value-of select="UML:ModelElement.name" /></a></TH>
         </xsl:for-each>
         </TR>
         <TR>
         <xsl:for-each select="./UML:Association.connection/UML:AssociationEnd">
            <TD>[<xsl:value-of select="@multiplicity"/>]</TD>
         </xsl:for-each>
         </TR>
         <TR bordercolor="#800000">
         <xsl:for-each select="./UML:Association.connection/UML:AssociationEnd">
            <TH><xsl:apply-templates select="@type"/></TH>
         </xsl:for-each>
         </TR>
         <xsl:for-each select="./UML:Association.link/UML:Link">
            <TR> <a> <xsl:attribute name="name"><xsl:value-of select="(@xmi.id|@XMI.id)"/></xsl:attribute>
            <xsl:for-each select="./UML:Link.connection/UML:LinkEnd">
               <TD><a> <xsl:attribute name="name"><xsl:value-of select="(@xmi.id|@XMI.id)"/></xsl:attribute>
                  <xsl:value-of select="UML:LinkEnd.instance/UML:Instance/UML:ModelElement.name"/></a></TD>
            </xsl:for-each>
            </a></TR>
         </xsl:for-each>
         </TBODY>
         </TABLE>
         </DIV>
				 </xsl:if>
         <!-- <xsl:apply-templates select="./*"/> -->
      </DIV>
   </xsl:template>
   
   <!-- display UML Classifiers -->
   <xsl:template match="(UML:Classifier|UML:Class|UML:DataType|UML:Enumeration|UML:Interface)[@xmi.id|@XMI.id]">
      <DIV class="majorelement">
         <xsl:apply-templates select="./@stereotype"/>
         <xsl:choose>
            <xsl:when match=".[(@xmi.idref|@XMI.idref|@href|@target)]">
               <a><xsl:apply-templates select="./(@xmi.idref|@XMI.idref|@href|@target)"/></a>
            </xsl:when>
            <xsl:otherwise>
               <a><xsl:apply-templates select="./(@xmi.id|@XMI.id)"/></a>
            </xsl:otherwise>
         </xsl:choose>
         
         <DIV class="classifier">
         <TABLE BORDER="2" CELLSPACING="0" bgcolor="white" bordercolor="navy">
         <TBODY>
         <TR bordercolor="navy"><TH> <xsl:if match=".[@isAbstract='true']"><xsl:attribute name="class">abstract</xsl:attribute></xsl:if>
            <xsl:apply-templates select="./@stereotype"/><br />
            <xsl:value-of select="UML:ModelElement.name" />
         </TH></TR>   
         <TR bordercolor="navy"><TD>
         <xsl:apply-templates select="./UML:Classifier.feature/UML:Attribute"/>
         </TD></TR>
         <TR bordercolor="navy"><TD>
         <xsl:apply-templates select="./UML:Classifier.feature/UML:Operation"/>
         </TD></TR>
         </TBODY>
         </TABLE>
         </DIV>
         
         <xsl:apply-templates select="./UML:ModelElement.taggedValue"/>
         <xsl:apply-templates select="./UML:Classifier.participant"/>
         <xsl:apply-templates select="./UML:GeneralizableElement.generalization"/>
      </DIV>
   </xsl:template>
   
   <!-- display UML Constraints -->
   <xsl:template match="(UML:Constraint)[@xmi.id|@XMI.id]">
      <DIV class="majorelement">
         <xsl:apply-templates select="./@stereotype"/>
         <xsl:choose>
            <xsl:when match=".[(@xmi.idref|@XMI.idref|@href|@target)]">
               <a><xsl:apply-templates select="./(@xmi.idref|@XMI.idref|@href|@target)"/></a>
            </xsl:when>
            <xsl:otherwise>
               <a><xsl:apply-templates select="./(@xmi.id|@XMI.id)"/></a>
            </xsl:otherwise>
         </xsl:choose>
         
         <DIV class="classifier">
         <TABLE BORDER="2" CELLSPACING="0" bgcolor="white" bordercolor="lightblue">
         <TBODY>
         <TR bordercolor="lightblue"><TH>
            <xsl:apply-templates select="@stereotype"/><br />
            {<xsl:value-of select="@body"/>}
         </TH></TR>   
         <TR bordercolor="lightblue"><TD>
         <!-- Constrained Elements:<br/> -->
         </TD></TR>
         </TBODY>
         </TABLE>
         </DIV>
         <xsl:apply-templates select="./UML:Constraint.constrainedElement"/>
         <xsl:apply-templates select="./UML:ModelElement.taggedValue"/>
      </DIV>
   </xsl:template>
   
   <xsl:template match="(UML:Attribute|Property)[@xmi.id|@XMI.id]">
      <xsl:choose>
      <xsl:when match="Property"><SPAN class="stname">&lt;&lt;property&gt;&gt;</SPAN></xsl:when>
      <xsl:otherwise><xsl:apply-templates select="@stereotype"/></xsl:otherwise>
      </xsl:choose>
      <a> <xsl:attribute name="name"><xsl:value-of select="(@xmi.id|@XMI.id)"/></xsl:attribute>
      <xsl:value-of select="UML:ModelElement.name"/></a>  : 
      <xsl:choose>
         <xsl:when match=".[@type]">
            <xsl:apply-templates select="@type"/>
         </xsl:when>
         <xsl:otherwise>--</xsl:otherwise>
      </xsl:choose>
      <BR />
   </xsl:template>
      
   <xsl:template match="UML:Operation[@xmi.id|@XMI.id]">
      <a> <xsl:attribute name="name"><xsl:value-of select="(@xmi.id|@XMI.id)"/></xsl:attribute>
      <xsl:value-of select="UML:ModelElement.name"/></a>
         (<xsl:apply-templates select="./UML:Operation.parameter/UML:Parameter[kind/(@xmi.value|@XMI.value)='in']"/>)
         <xsl:if match=".[UML:Operation.parameter/UML:Parameter/kind/(@xmi.value|@XMI.value)='return']">: 
         <xsl:apply-templates select="./UML:Operation.parameter/UML:Parameter[kind/(@xmi.value|@XMI.value)='return']"/></xsl:if> <BR />
   </xsl:template>
   
   <xsl:template match="UML:Parameter[@xmi.id|@XMI.id]">
      <a> <xsl:attribute name="name"><xsl:value-of select="(@xmi.id|@XMI.id)"/></xsl:attribute>
      <xsl:if match=".[$not$ name='return']"><xsl:value-of select="name"/>:</xsl:if></a> 
      <xsl:choose>
         <xsl:when match=".[@type]">
            <xsl:apply-templates select="@type"/>
         </xsl:when>
         <xsl:when match=".[type/XMI.sequence]"><xsl:apply-templates select="./type/XMI.sequence[*]"/></xsl:when>
         <xsl:otherwise>--</xsl:otherwise>
      </xsl:choose><xsl:if match="context()[not(end())]">, </xsl:if>
   </xsl:template>
   
	 <xsl:template match="@stereotype">
      <SPAN class="stname">&#171;<a> <xsl:attribute name="href">#<xsl:value-of /></xsl:attribute><xsl:value-of select="//*[@xmi.id=context()]/UML:ModelElement.name"/></a>&#187;</SPAN>
	 </xsl:template>
   
	 <xsl:template match="@type|@child|@parent">
      <SPAN class="ref">
			   <xsl:for-each select="//*[@xmi.id=context()]">
            <xsl:choose>
						  <xsl:when test="UML:ModelElement.name">
				      <a> 
			          <xsl:attribute name="href">#<xsl:value-of select="@xmi.id" /></xsl:attribute><xsl:value-of select="UML:ModelElement.name"/></a>
							</xsl:when>	
							<xsl:when test="@xmi.idref">
							<a> <xsl:attribute name="href">#<xsl:value-of select="@xmi.idref" /></xsl:attribute><xsl:value-of select="//*[@xmi.id=context()/@xmi.idref]/UML:ModelElement.name"/></a>
							</xsl:when>
							<xsl:otherwise>unknown</xsl:otherwise>
				    </xsl:choose>
					</xsl:for-each>
					</SPAN>
	 </xsl:template>
   
   <xsl:template match="XMI.sequence">
      <a><xsl:apply-templates select="./XMI.seqItem/*/(@xmi.idref|@XMI.idref|@href|@target)"/>[]</a>
   </xsl:template>
   
   <!-- Conceal XMI basis -->
   <xsl:template match="XMI">
      <xsl:apply-templates select="./*"/>
   </xsl:template>
   
   <xsl:template match="XMI.header">
      <!--
      <HR class="divider" />
      <DIV class='header'><h3>Header</h3>
         <xsl:apply-templates select="./*"/>
      </DIV>
      -->
   </xsl:template>
   
   <xsl:template match="XMI.content">
      <HR class="divider" />
      <DIV class='header'><h3>Content</h3>
         <xsl:apply-templates select="./*"/>
      </DIV>
   </xsl:template>

   <xsl:template match="XMI.documentation">
      <DIV class='collection'>Documentation
         <xsl:apply-templates select="./*"/>
      </DIV>
   </xsl:template>

   <xsl:template match="XMI.metamodel">
      <DIV class='collection'>Metamodel
         <xsl:apply-templates select="./@*"/>
         <xsl:apply-templates select="./*"/>
      </DIV>
   </xsl:template>
   
   <xsl:template match="XMI.model">
      <DIV class='collection'>Model
         <xsl:apply-templates select="./*"/>
      </DIV>
   </xsl:template>
   

   <!-- Exclusions (already handled or not useful for output) -->
   <xsl:template match="UML:ModelElement.name" />
   <xsl:template match="UML:Association.link[UML:Link]" />
   <xsl:template match="UML:ModelElement.stereotype[UML:Stereotype]" />
   <xsl:template match="UML:Classifier.feature[UML:Attribute|UML:Operation]" />
   <xsl:template match="XMI.extension[Property]" />
   <xsl:template match="(subtype|supertype)[Class]" />
   <xsl:template match="UML:Association.connection[UML:AssociationEnd]" />
   <xsl:template match="literal[EnumerationLiteral]" />
   <!-- <xsl:template match="UML:AssociationEnd/@type" /> -->
   <xsl:template match="UML:AssociationEnd/@multiplicity" />
   <!-- <xsl:template match="UML:Constraint.constrainedElement[*]" /> -->
   <xsl:template match="visibility" />
   <xsl:template match="Dependency/(supplier|client)[*]" />
   <xsl:template match="*[(@xmi.value|@XMI.value)='false']" />
   <xsl:template match="isAbstract[(@xmi.value|@XMI.value)='true']" />
   <xsl:template match="(XMI.extension|feature)[$not$ *]" />
   
</xsl:stylesheet>  


