<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fx="http://www.asam.net/xml/fbx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ho="http://www.asam.net/xml" xmlns:flexray="http://www.asam.net/xml/fbx/flexray">

  <xsl:output method="html" version="1.0" encoding="UTF-8" indent="no"/>

  <xsl:template match="/" priority="1.0">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <style type="text/css">
          body.{font-size:11;}
          body.{margin:+5px};
        </style>
      </head>
      <body>
        <font face="Arial">
          <xsl:apply-templates select="*"/>
        </font>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="fx:FIBEX" priority="1.0">
    <xsl:param name="indent" select="0"/>
    <xsl:call-template name="openElement">
      <xsl:with-param name="currentNode" select="."/>
    </xsl:call-template>
    <xsl:apply-templates select="*">
      <xsl:with-param name="indent" select="$indent + 2"/>
    </xsl:apply-templates>
    <br/>
    <xsl:call-template name="closeElement">
      <xsl:with-param name="currentNode" select="."/>
    </xsl:call-template>
  </xsl:template>

  <!-- Element is created internally, due the fact that text nodes are not allow directly under the document node -->
  <xsl:template match="FIBEXFragment" priority="1.0">
    <xsl:param name="indent" select="0"/>
    <b>(Extract of the selected element)</b>
    <br/>
    <xsl:apply-templates select="*">
      <xsl:with-param name="indent" select="$indent"/>
    </xsl:apply-templates>
    <br/>
    <b>(For more detailed information switch to FIBEX View)</b>
  </xsl:template>

  <!-- Element is created internally, due the fact that text nodes are not allow directly under the document node -->
  <xsl:template match="XPATHRESULT" priority="1.0">
    <xsl:param name="indent" select="0"/>
    <b>(FIBEX elements matching the XPATH expression)</b>
    <br/>
    <b>Press the upper right button 'FIBEX document' to switch to the complete FIBEX document!</b>
    <br/>
    <xsl:apply-templates select="*">
      <xsl:with-param name="indent" select="$indent"/>
    </xsl:apply-templates>
    <br/>
  </xsl:template>

  <xsl:template match="LineBreak" priority="1.0">
    <xsl:param name="indent" select="0"/>
    <br/>
    <xsl:apply-templates select="*">
      <xsl:with-param name="indent" select="$indent"/>
    </xsl:apply-templates>
  </xsl:template>

  <!-- 
    Dummy element for generating '...' in the HTML document 
    Note, the fx:Eclipse is part of a previous transformation, therefore
    the namespace is needed in contrast to 'FIBEXFragment' and 'XPATHRESULT'.
  -->

  <xsl:template match="fx:Eclipse" priority="1.0">
    <xsl:param name="indent" select="0"/>
    <br/>
    <xsl:call-template name="doIndent">
      <xsl:with-param name="indent" select="$indent"/>
    </xsl:call-template>
    <xsl:choose>
      <xsl:when test="@style = 'plain'">...</xsl:when>
      <xsl:otherwise>
        <b>...</b>
      </xsl:otherwise>
    </xsl:choose>
    <xsl:apply-templates select="*">
      <xsl:with-param name="indent" select="$indent + 2"/>
    </xsl:apply-templates>
  </xsl:template>


  <!-- This rule applies only to FlexRay cluster -->
  <xsl:template match="fx:CLUSTER[./fx:PROTOCOL/text() = 'FlexRay']" priority="1.0">
    <xsl:param name="indent" select="0"/>

    <br/>
    <xsl:call-template name="doIndent">
      <xsl:with-param name="indent" select="$indent"/>
    </xsl:call-template>
    <xsl:call-template name="openElement">
      <xsl:with-param name="currentNode" select="."/>
    </xsl:call-template>
    <xsl:choose>
      <xsl:when test="fx:PROTOCOL/text() ='FlexRay'">
        <br/>
        <xsl:call-template name="doIndent">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:call-template>
        <font color="#0000FF">
          <b>... General Properties ...</b>
        </font>

        <xsl:apply-templates select="ho:SHORT-NAME">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="ho:LONG-NAME">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="ho:DESC">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>

        <xsl:apply-templates select="fx:ELEMENT-REVISIONS">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="fx:PRODUCT-REF">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>

        <xsl:apply-templates select="fx:SPEED">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="fx:IS-HIGH-LOW-BIT-ORDER">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="fx:BIT-COUNTING-POLICY">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="fx:PROTOCOL">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="fx:PROTOCOL-VERSION">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="fx:CHANNEL-REFS">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="fx:MEDIUM">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="fx:NUMBER-OF-CYCLES">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="fx:MAX-FRAME-LENGTH">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="fx:MANUFACTURER-EXTENSION">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>

        <br/>
        <xsl:call-template name="doIndent">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:call-template>

        <font color="#0000FF">
          <b>... Cycle Parameters ...</b>
        </font>

        <xsl:apply-templates select="flexray:CYCLE">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:BIT">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:SAMPLE-CLOCK-PERIOD">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:MACROTICK">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:MACRO-PER-CYCLE">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:NUMBER-OF-STATIC-SLOTS">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:STATIC-SLOT">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:ACTION-POINT-OFFSET">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:T-S-S-TRANSMITTER">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:PAYLOAD-LENGTH-STATIC">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:NUMBER-OF-MINISLOTS">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:MINISLOT">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:MINISLOT-ACTION-POINT-OFFSET">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:DYNAMIC-SLOT-IDLE-PHASE">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:SYMBOL-WINDOW">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:N-I-T">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:SYNC-NODE-MAX">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:NETWORK-MANAGEMENT-VECTOR-LENGTH">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:OFFSET-CORRECTION-MAX">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>

        <br/>
        <xsl:call-template name="doIndent">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:call-template>

        <font color="#0000FF">
          <b>... Wakeup &amp; Startup Parameters ...</b>
        </font>

        <xsl:apply-templates select="flexray:LISTEN-NOISE">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:COLD-START-ATTEMPTS">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:CAS-RX-LOW-MAX">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:CAS-RX-LOW-MIN">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:WAKE-UP">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:MAX-INITIALIZATION-ERROR">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>

        <br/>
        <xsl:call-template name="doIndent">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:call-template>

        <font color="#0000FF">
          <b>... Clock Correction Parameters ...</b>
        </font>

        <xsl:apply-templates select="flexray:CLUSTER-DRIFT-DAMPING">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:OFFSET-CORRECTION-START">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:MAX-WITHOUT-CLOCK-CORRECTION-FATAL">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:MAX-WITHOUT-CLOCK-CORRECTION-PASSIVE">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
      </xsl:when>
      <xsl:otherwise>
        <xsl:copy>
          <xsl:apply-templates select="*|@*">
            <xsl:with-param name="indent" select="$indent + 2"/>
          </xsl:apply-templates>
        </xsl:copy>
      </xsl:otherwise>
    </xsl:choose>
    <br/>
    <xsl:call-template name="doIndent">
      <xsl:with-param name="indent" select="$indent"/>
    </xsl:call-template>
    <xsl:call-template name="closeElement">
      <xsl:with-param name="currentNode" select="."/>
    </xsl:call-template>
  </xsl:template>

  <xsl:template match="fx:CONTROLLER" priority="1.0">
    <xsl:param name="indent" select="0"/>

    <br/>
    <xsl:call-template name="doIndent">
      <xsl:with-param name="indent" select="$indent"/>
    </xsl:call-template>
    <xsl:call-template name="openElement">
      <xsl:with-param name="currentNode" select="."/>
    </xsl:call-template>
    <xsl:choose>
      <xsl:when test="@xsi:type='flexray:CONTROLLER-TYPE'">

        <br/>
        <xsl:call-template name="doIndent">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:call-template>

        <font color="#0000FF">
          <b>... General Properties ...</b>
        </font>

        <xsl:apply-templates select="ho:SHORT-NAME">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="ho:LONG-NAME">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="ho:DESC">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>

        <xsl:apply-templates select="fx:VENDOR-NAME">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="fx:CHIP-NAME">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="fx:TERMINATION-IMPEDANCE">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="fx:TRANSCEIVER">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="fx:MANUFACTURER-EXTENSION">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>

        <br/>
        <xsl:call-template name="doIndent">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:call-template>

        <font color="#0000FF">
          <b>... Cycle Parameters ...</b>
        </font>

        <xsl:apply-templates select="flexray:MICRO-PER-CYCLE">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:MICRO-PER-MACRO-NOM">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:MICROTICK">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:SAMPLES-PER-MICROTICK">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>

        <br/>
        <xsl:call-template name="doIndent">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:call-template>

        <font color="#0000FF">
          <b>... Wakeup &amp; Startup Parameters...</b>
        </font>

        <xsl:apply-templates select="flexray:MAX-DRIFT">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:WAKE-UP-PATTERN">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:LISTEN-TIMEOUT">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:ACCEPTED-STARTUP-RANGE">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:MACRO-INITIAL-OFFSET-A">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:MACRO-INITIAL-OFFSET-B">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:MICRO-INITIAL-OFFSET-A">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:MICRO-INITIAL-OFFSET-B">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>

        <br/>
        <xsl:call-template name="doIndent">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:call-template>

        <font color="#0000FF">
          <b>... Clock Correction Parameters ...</b>
        </font>

        <xsl:apply-templates select="flexray:KEY-SLOT-USAGE">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:KEY-SLOT-ID">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:SINGLE-SLOT-ENABLED">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:CLUSTER-DRIFT-DAMPING">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:DECODING-CORRECTION">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:DELAY-COMPENSATION-A">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:DELAY-COMPENSATION-B">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:OFFSET-CORRECTION-OUT">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:EXTERN-RATE-CORRECTION">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:RATE-CORRECTION-OUT">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:EXTERN-OFFSET-CORRECTION">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:ALLOW-HALT-DUE-TO-CLOCK">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:ALLOW-PASSIVE-TO-ACTIVE">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>

        <br/>
        <xsl:call-template name="doIndent">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:call-template>

        <font color="#0000FF">
          <b>... Latest Tx ...</b>
        </font>

        <xsl:apply-templates select="flexray:LATEST-TX">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <xsl:apply-templates select="flexray:MAX-DYNAMIC-PAYLOAD-LENGTH">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
      </xsl:when>
      <xsl:otherwise>
        <xsl:copy>
          <xsl:apply-templates select="*|@*">
            <xsl:with-param name="indent" select="$indent + 2"/>
          </xsl:apply-templates>
        </xsl:copy>
      </xsl:otherwise>
    </xsl:choose>
    <br/>
    <xsl:call-template name="doIndent">
      <xsl:with-param name="indent" select="$indent"/>
    </xsl:call-template>
    <xsl:call-template name="closeElement">
      <xsl:with-param name="currentNode" select="."/>
    </xsl:call-template>
  </xsl:template>

  <xsl:template match="fx:MANUFACTURER-EXTENSION" priority="1.0">
    <xsl:param name="indent" select="0"/>

    <font color="#008080">
      <br/>
      <xsl:call-template name="doIndent">
        <xsl:with-param name="indent" select="$indent"/>
      </xsl:call-template>
      <xsl:call-template name="openManufacturerElement">
        <xsl:with-param name="currentNode" select="."/>
      </xsl:call-template>
      <xsl:apply-templates select="*" mode="manufacturer">
        <xsl:with-param name="indent" select="$indent + 2"/>
      </xsl:apply-templates>
      <br/>
      <xsl:call-template name="doIndent">
        <xsl:with-param name="indent" select="$indent"/>
      </xsl:call-template>
      <xsl:call-template name="closeManufacturerElement">
        <xsl:with-param name="currentNode" select="."/>
      </xsl:call-template>
    </font>
  </xsl:template>

  <xsl:template match="processing-instruction()">
    <copy/>
  </xsl:template>

  <xsl:template match="comment()">
    <xsl:param name="indent" select="2"/>
    <br/>
    <xsl:call-template name="doIndent">
      <xsl:with-param name="indent" select="$indent"/>
    </xsl:call-template>
    <font color="#0000FF">
      <xsl:text>&lt;!--</xsl:text>
    </font>
    <font color="#808080">
      <xsl:value-of select="."/>
    </font>
    <font color="#0000FF">
      <xsl:text>--&gt;</xsl:text>
    </font>
  </xsl:template>

  <xsl:template match="*">
    <xsl:param name="indent" select="0"/>
    <br/>
    <!-- do indent -->
    <xsl:call-template name="doIndent">
      <xsl:with-param name="indent" select="$indent"/>
    </xsl:call-template>
    <!-- do indent -->
    <xsl:choose>
      <xsl:when test="not(./text()) and not(./child::*)">
        <xsl:call-template name="emptyElement">
          <xsl:with-param name="currentNode" select="."/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="./text() and not(./child::*)">
        <!-- show open element -->
        <xsl:call-template name="openElement">
          <xsl:with-param name="currentNode" select="."/>
        </xsl:call-template>
        <!-- continue traversing the tree -->
        <b>
          <xsl:apply-templates>
            <xsl:with-param name="indent" select="$indent + 2"/>
          </xsl:apply-templates>
        </b>
        <!-- show closen element -->
        <xsl:call-template name="closeElement">
          <xsl:with-param name="currentNode" select="."/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <!-- show open element -->
        <xsl:call-template name="openElement">
          <xsl:with-param name="currentNode" select="."/>
        </xsl:call-template>
        <!-- continue traversing the tree -->
        <xsl:apply-templates>
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <br/>
        <xsl:call-template name="doIndent">
          <xsl:with-param name="indent" select="$indent"/>
        </xsl:call-template>
        <!-- show closen element -->
        <xsl:call-template name="closeElement">
          <xsl:with-param name="currentNode" select="."/>
        </xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="*" mode="manufacturer">
    <xsl:param name="indent" select="0"/>
    <br/>
    <!-- do indent -->
    <xsl:call-template name="doIndent">
      <xsl:with-param name="indent" select="$indent"/>
    </xsl:call-template>
    <!-- do indent -->
    <xsl:choose>
      <xsl:when test="not(./text()) and not(./child::*)">
        <xsl:call-template name="emptyManufacturerElement">
          <xsl:with-param name="currentNode" select="."/>
        </xsl:call-template>
      </xsl:when>
      <xsl:when test="./text() and not(./child::*)">
        <!-- show open element -->
        <xsl:call-template name="openManufacturerElement">
          <xsl:with-param name="currentNode" select="."/>
        </xsl:call-template>
        <!-- continue traversing the tree -->
        <b>
          <xsl:apply-templates mode="manufacturer">
            <xsl:with-param name="indent" select="$indent + 2"/>
          </xsl:apply-templates>
        </b>
        <!-- show closen element -->
        <xsl:call-template name="closeManufacturerElement">
          <xsl:with-param name="currentNode" select="."/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <!-- show open element -->
        <xsl:call-template name="openManufacturerElement">
          <xsl:with-param name="currentNode" select="."/>
        </xsl:call-template>
        <!-- continue traversing the tree -->
        <xsl:apply-templates mode="manufacturer">
          <xsl:with-param name="indent" select="$indent + 2"/>
        </xsl:apply-templates>
        <br/>
        <xsl:call-template name="doIndent">
          <xsl:with-param name="indent" select="$indent"/>
        </xsl:call-template>
        <!-- show closen element -->
        <xsl:call-template name="closeManufacturerElement">
          <xsl:with-param name="currentNode" select="."/>
        </xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="@ID" priority="1.0">
    <xsl:variable name="tmp" select="."/>
    <a name="{$tmp}">
      <xsl:text>&#160;</xsl:text>
      <font color="red">
        <xsl:value-of select="name(.)"/>
      </font>
      <font color="#0000FF">="</font>
      <xsl:value-of select="."/>
      <font color="#0000FF">"</font>
    </a>
  </xsl:template>

  <xsl:template match="@ID" priority="1.0" mode="manufacturer">
    <xsl:variable name="tmp" select="."/>
    &#160;
    <a name="{$tmp}">
      <xsl:value-of select="name(.)"/>="<xsl:value-of select="."/>"
    </a>
  </xsl:template>

  <xsl:template match="@ID-REF" priority="1.0">
    <xsl:variable name="tmp" select="."/>
    <xsl:text>&#160;</xsl:text>
    <font color="red">
      <xsl:value-of select="name(.)"/>
    </font>
    <font color="#0000FF">="</font>
    
      <xsl:value-of select="."/>
    
    <font color="#0000FF">"</font>
  </xsl:template>

  
  <xsl:template match="@ID-REF" priority="1.0" mode="manufacturer">
    <xsl:variable name="tmp" select="."/>
    &#160;
    <xsl:value-of select="name(.)"/>="
      <xsl:value-of select="."/>
    "
  </xsl:template>

  <xsl:template match="@style" priority ="1.0"/>

  <xsl:template match="@*">
    <xsl:text>&#160;</xsl:text>
    <font color="red">
      <xsl:value-of select="name(.)"/>
    </font>
    <font color="#0000FF">="</font>
    <xsl:value-of select="."/>
    <font color="#0000FF">"</font>
  </xsl:template>

  <xsl:template match="@*" mode="manufacturer">
    <xsl:text>&#160;</xsl:text>
    <xsl:value-of select="name(.)"/>="<xsl:value-of select="."/>"
  </xsl:template>

  <xsl:template name="doIndent">
    <xsl:param name="indent" select="0"/>
    <xsl:if test="$indent &gt; 0">
      <xsl:text>&#160;</xsl:text>
      <xsl:call-template name="doIndent">
        <xsl:with-param name="indent" select="$indent - 1"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>

  <xsl:template name="openElement">
    <xsl:param name="currentNode" select="false"/>

    <xsl:choose>
      <xsl:when test="@style='bold'">
        <b>
          <font color="#0000FF">&lt;</font>
          <font color="#800000">
            <xsl:value-of select="name($currentNode)"/>
          </font>
          <!-- Attribute axis -->
          <xsl:apply-templates select="@*"/>
          <font color="#0000FF">
            <xsl:text>&gt;</xsl:text>
          </font>
        </b>
      </xsl:when>
      <xsl:otherwise>
        <font color="#0000FF">&lt;</font>
        <font color="#800000">
          <xsl:value-of select="name($currentNode)"/>
        </font>
        <!-- Attribute axis -->
        <xsl:apply-templates select="@*"/>
        <font color="#0000FF">
          <xsl:text>&gt;</xsl:text>
        </font>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="closeElement">
    <xsl:param name="currentNode" select="false"/>

    <xsl:choose>
      <xsl:when test="@style='bold'">
        <b>
          <font color="#0000FF">&lt;/</font>
          <font color="#800000">
            <xsl:value-of select="name($currentNode)"/>
          </font>
          <font color="#0000FF">&gt;</font>
        </b>
      </xsl:when>
      <xsl:otherwise>
        <font color="#0000FF">&lt;/</font>
        <font color="#800000">
          <xsl:value-of select="name($currentNode)"/>
        </font>
        <font color="#0000FF">&gt;</font>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template name="emptyElement">
    <xsl:param name="currentNode" select="false"/>
    <font color="#0000FF">&lt;/</font>
    <font color="#800000">
      <xsl:value-of select="name($currentNode)"/>
    </font>
    <xsl:apply-templates select="@*"/>
    <font color="#0000FF">&gt;</font>
  </xsl:template>

  <xsl:template name="openManufacturerElement">
    <xsl:param name="currentNode" select="false"/>
    &lt;<xsl:value-of select="name($currentNode)"/><xsl:apply-templates select="@*" mode="manufacturer"/>&gt;
  </xsl:template>

  <xsl:template name="closeManufacturerElement">
    <xsl:param name="currentNode" select="false"/>
    &lt;/<xsl:value-of select="name($currentNode)"/>&gt;
  </xsl:template>

  <xsl:template name="emptyManufacturerElement">
    <xsl:param name="currentNode" select="false"/>
    &lt;/<xsl:value-of select="name($currentNode)"/>&gt;
  </xsl:template>

</xsl:stylesheet>
