<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="4.01" encoding="ISO-8859-1"/>


<xsl:template match="SysInfoModel">

  <html>
  <body>
  <h1>Common Model of System Information</h1>
  <h2>Introduction</h2>

  <p>
  You are viewing data described using the CMSI standard 
  (see <a href="http://www.cert-verbund.de/cmsi/documentation/cmsi_first_2005_paper.pdf">here</a> for a general introduction). Additional ressources regarding CMSI are available on 
  the <a href="http://www.cert-verbund.de/cmsi">CMSI homepage</a>.
  </p>
  <p>
  The model you are viewing is stored as an XML-file and rendered using an XSLT-stylesheet. By viewing
  the source directly in your browser or by downloading the XML-file and opening it in an editor,
  you can examine all details. This rendering tries to make viewing and understanding the model
  more comfortable by pretty-printing the information contained in the model.
  </p>
  <p>
  The model contains the following components:
  </p>
  <ul>
   <li>
    <a href="#cat_tree">Category Tree</a>:
    Top-level structure of a model of system information is a category tree.
   </li> 
   <li>
    <a href="#families">Product Families</a>:
    The leaves of the category tree are formed by product families.
   </li> 
   <li>
    Meta Data:
     Meta data is divided into
      <ul>
       <li>
         <a href="#type_defs">Type Definitions</a>: Type definitions can be reused
         when defining product families and node attributes (see below).
       </li>
       <li>
         <a href="#node_attributes">Node Attributes</a>: Node attributes define 
          attributes that have to be filled out for those nodes of the category tree
          and those product families to which they apply. 
       </li>
      </ul>

   </li>
  </ul>

  <h2><a name="cat_tree">Category Tree</a></h2> 
<p>
 The category tree is displayed as unordered list. For each node,
 the machine-readable tag is displayed in brackets. Alternative names
 of a node and node attributes are not shown -- please refer to the
 XML source.
</p>
<p>
 Product families form the leaves of the tree, by clicking on a tree,
 you can jump to the description of each product family.
</p>
  <xsl:apply-templates select="CategoryTree"/>
  <h2><a name="families">Families</a></h2> 
<p>
 For each product family, we show 
 <ul>
  <li>its name</li> 
  <li>the machine-readable tags of its parent nodes</li>
  <li>the description of the family</li>
  <li>the products of this family</li>
  <li>the values of the node attributes that have been filled out for this family</li>
  <li>the specific attributes for describing products of this family</li>
 </ul>
 Alternative names of the product family or products are not shown -- please refer to
 the XML-source.
 </p>

  <xsl:apply-templates select="Families"/>
  <h2><a name="type_defs">Type Definitions</a></h2> 

<p>
 The following attribute types have been defined for re-use within the model:
 </p>

  <xsl:apply-templates select="TypeDefs"/>

  <h2><a name="node_attributes">Node Attributes</a></h2> 
<p>
 The following node attributes have been defined for the model:
 </p>

  <xsl:apply-templates select="NodeAttributes"/>
  </body>
  </html>

</xsl:template>


<xsl:template match="TypeDefs">
  <ul>
  <xsl:apply-templates select="TypeDef"/>
  </ul>
</xsl:template>


<xsl:template match="TypeDef">
  <li> 
   <code><xsl:value-of select="@id"/></code> of kind
   <em><xsl:value-of select="@kind"/></em><br/>

   <xsl:apply-templates select="Description"/>  
   <xsl:if test="@kind = 'grammar'">
     Grammar:
     <xsl:apply-templates select="Grammar"/>
   </xsl:if>    

   <xsl:if test="@kind = 'LOV'">
     Values: <xsl:apply-templates select="ValueList"/>
   </xsl:if>    
  </li>
</xsl:template>


<xsl:template match="ValueList">
 <form>
  <select>
   <xsl:for-each select="ListElement">
     <xsl:apply-templates select="."/>
   </xsl:for-each>
  </select>
 </form>
</xsl:template>

<xsl:template match="ListElement">
 <option><xsl:value-of select="@name"/> (<xsl:value-of select="@tag"/>)</option>
</xsl:template>


<xsl:template match="Grammar">

   <code><xsl:value-of select="."/></code>

</xsl:template>



<xsl:template match="NodeAttributes">
  <ul>
   <xsl:apply-templates select="NodeAttribute"/>
  </ul>
</xsl:template>

<xsl:template match="NodeAttribute">
  <li> 
   <xsl:value-of select="@name"/>
   (<code><xsl:value-of select="@id"/></code>)
   <xsl:apply-templates select="Description"/>
   <em>Type Description:</em><br/>
   <xsl:call-template name="display_type">
    <xsl:with-param name="type_id" 
      select="@type_id"/>
   </xsl:call-template>
  </li>
</xsl:template>


<xsl:template match="Families">

   <xsl:apply-templates select="Family"/>
</xsl:template>


<xsl:template match="Family">
  <table border="1" width = "100%" bgcolor="#eeeeee">
   <tr>
    <td>
     <xsl:element name = 'a'>
      <xsl:attribute name = 'name'>
       <xsl:value-of select="@tag"/>
      </xsl:attribute>
      <b><xsl:apply-templates select="Names"/></b>
     </xsl:element>
     (<code><xsl:value-of select="@tag"/></code>)
    </td>
    <td>
     <xsl:apply-templates select="Parents"/>
    </td>
   </tr>
   <tr>
    <td colspan = "2"> 
     <xsl:apply-templates select="Description"/>
    </td>
   </tr>
   <tr>
    <td colspan = "2"> 	
      <xsl:apply-templates select="Products"/>
    </td>
   </tr>
   <tr>
    <td colspan = "2"> 	
      <xsl:apply-templates select="AttributeValues"/>
    </td>
   </tr>
   <tr>
    <td colspan = "2"> 	
      <xsl:apply-templates select="ProductAttributes"/>
    </td>
   </tr>
  </table>
  <br/>
</xsl:template>


<xsl:template match="Parents">
   <b>Parents:</b>

   <xsl:apply-templates select="Parent"/>
</xsl:template>

<xsl:template match="Parent">
     <xsl:text>  </xsl:text>
     <xsl:element name = 'a'>
      <xsl:attribute name = 'href'>
       <xsl:value-of select="concat('#',@tag)"/>
      </xsl:attribute>
      <code><xsl:value-of select="@tag"/></code>
     </xsl:element>

</xsl:template>

<xsl:template match="Products">
 <b>Products</b>
  <ul>
   <xsl:apply-templates select="Product"/>
  </ul>
</xsl:template>

<xsl:template match="Product">
  <li> 
   (<code><xsl:value-of select="@tag"/></code>)
   <xsl:apply-templates select="Names"/>
   <xsl:apply-templates select="Description"/>
  </li>
</xsl:template>

<xsl:template match="ProductAttributes">
 <b>Product Attributes</b>
  <ul>
   <xsl:apply-templates select="ProductAttribute"/>
  </ul>
</xsl:template>

<xsl:template match="ProductAttribute">
  <li> 
   <xsl:value-of select="@name"/>
   (<code><xsl:value-of select="@tag"/></code>)
   <xsl:apply-templates select="Description"/>

   <xsl:call-template name="display_type">
    <xsl:with-param name="type_id" 
      select="@type_id"/>
   </xsl:call-template>
  </li>
</xsl:template>


<xsl:template match="AttributeValues">
 <b>Attribute Values</b>
  <ul>
   <xsl:apply-templates select="AttributeValue"/>
  </ul>
</xsl:template>

<xsl:template match="AttributeValue">
  <li> 
   <xsl:call-template name="display_attribute">
    <xsl:with-param name="attribute_id" 
      select="@attribute_id"/>
   </xsl:call-template>
   <xsl:for-each select="Value">
    <code><xsl:value-of select="."/></code><xsl:text>  </xsl:text>
   </xsl:for-each>
  </li>
</xsl:template>


<xsl:template name="display_attribute">
 <xsl:param name="attribute_id"/>
 <xsl:for-each select="/SysInfoModel/NodeAttributes/NodeAttribute">
  <xsl:if test="$attribute_id = @id">
   <xsl:value-of select="@name"/>:
  </xsl:if>
 </xsl:for-each>
</xsl:template>




<xsl:template name="display_type">
 <xsl:param name="type_id"/>
 <xsl:for-each select="/SysInfoModel/TypeDefs/TypeDef">
  <xsl:if test="$type_id = @id">
     <small>
     <xsl:apply-templates select="Description"/>  
     <xsl:if test="@kind = 'grammar'">
       Grammar:
       <xsl:apply-templates select="Grammar"/>
     </xsl:if>    

     <xsl:if test="@kind = 'LOV'">
      Values:
      <xsl:apply-templates select="ValueList"/>
     </xsl:if>
     </small>
    </xsl:if>

 </xsl:for-each>
</xsl:template>


<xsl:template name="find_families">
 <xsl:param name="node_id"/>
 <xsl:for-each select="/SysInfoModel/Families/Family">
  <xsl:for-each select="Parents/Parent">
   <xsl:if test="$node_id = @tag">
    <li>
    <xsl:element name = 'a'>
     <xsl:attribute name = 'href'>
      <xsl:value-of select="concat('#',../../@tag)"/>
     </xsl:attribute>

     <em>
      <xsl:apply-templates select="../../Names"/>  
     </em>
    </xsl:element>

    </li>
   </xsl:if>
  </xsl:for-each>
 </xsl:for-each>
</xsl:template>






<xsl:template match="CategoryTree">

  <ul>
  <xsl:apply-templates select="CategoryNode"/>
  </ul>
</xsl:template>

<xsl:template match="CategoryNode">
  <li>
    
   <xsl:apply-templates select="Names"/>   
     <xsl:element name = 'a'>
      <xsl:attribute name = 'name'>
       <xsl:value-of select="@tag"/>
      </xsl:attribute>
      (<code><xsl:value-of select="@tag"/></code>)
     </xsl:element>

   <!--xsl:apply-templates select="Description"/-->    
   <ul>
    <xsl:apply-templates select="Children/CategoryNode"/>
    <xsl:call-template name="find_families">
     <xsl:with-param name="node_id" 
       select="@tag"/>
    </xsl:call-template>
   </ul>
  </li>
</xsl:template>

<xsl:template match="Names">
  <big><b><xsl:value-of select="Name"/></b></big>
</xsl:template>

<xsl:template match="Description">
  <xsl:value-of select="."/><br/>
</xsl:template>





</xsl:stylesheet>

