<?xml version="1.0" encoding="iso-8859-1" ?>
<!DOCTYPE xsl:stylesheet [
   <!ENTITY % lat1 SYSTEM "xhtml-lat1.ent" >
   %lat1;
]>

  <xsl:stylesheet 
        xmlns:xsl  = "http://www.w3.org/1999/XSL/Transform" 
        xmlns:wsdl = "http://schemas.xmlsoap.org/wsdl/" 
        xmlns:xsd  = "http://www.w3.org/2001/XMLSchema"
	xmlns:soap = "http://schemas.xmlsoap.org/wsdl/soap/"
        version="1.0">
  <xsl:output method="xml" />

  <xsl:template name="showMessage">
    <xsl:param name="message">Message inconnu</xsl:param>
    <xsl:value-of select="substring-after($message, ':')" />:
    <dl>
      <xsl:for-each select="/wsdl:definitions/wsdl:message[@name=substring-after($message, ':')]/wsdl:part" > 
        <dt><xsl:value-of select="@name" /></dt>
        <dd><xsl:value-of select="substring-after(@type, ':')" /></dd>
        </xsl:for-each>
      </dl>
    </xsl:template>

  <xsl:template name="showOperation">
    <xsl:param name="operation">Op&#233;ration inconnue</xsl:param>
    <xsl:param name="dir"      >Direction inconnue</xsl:param>
    <xsl:choose>
      <xsl:when test="$dir='input'">
        <xsl:call-template name="showMessage">
          <xsl:with-param name="message">
            <xsl:value-of 
              select="/wsdl:definitions/wsdl:portType/wsdl:operation[@name=$operation]/wsdl:input/@message" />
            </xsl:with-param>
          </xsl:call-template>
        </xsl:when>
      <xsl:when test="$dir='output'">
        <xsl:call-template name="showMessage">
          <xsl:with-param name="message">
            <xsl:value-of 
              select="/wsdl:definitions/wsdl:portType/wsdl:operation[@name=$operation]/wsdl:output/@message" />
            </xsl:with-param>
          </xsl:call-template>
        </xsl:when>
      </xsl:choose>
    </xsl:template>

  <xsl:template match="wsdl:operation">
    <tbody>
      <tr><th colspan="2">M&#233;thode</th>    <th><xsl:value-of select="@name"                      /></th></tr>
      <tr><th colspan="2">Action SOAP</th><td><xsl:value-of select="soap:operation/@soapAction" /></td></tr>
      <tr><th rowspan="2">Paramètres</th>
          <th>Entr&#233;e</th>                 
          <td>
            <xsl:call-template name="showOperation" >
              <xsl:with-param name="operation"><xsl:value-of select="@name" /></xsl:with-param>
              <xsl:with-param name="dir">input</xsl:with-param>
              </xsl:call-template>
            </td>
          </tr>
      <tr><th>Sortie</th>
          <td>
            <xsl:call-template name="showOperation" >
              <xsl:with-param name="operation"><xsl:value-of select="@name" /></xsl:with-param>
              <xsl:with-param name="dir">output</xsl:with-param>
              </xsl:call-template>
            </td>
          </tr>
      </tbody>
    </xsl:template>

  <!-- Liste des methodes -->
  <xsl:template match="wsdl:definitions/wsdl:binding" >
      <p>Il supporte les m&#233;thodes suivantes:</p>
      <table border="1" rules="groups">
        <xsl:apply-templates select="wsdl:operation" />
        </table>
    </xsl:template>

  <xsl:template match="wsdl:definitions/wsdl:service">
    <p>Le contrat de ce service est d&#233;fini par 
      <xsl:element name="a">
        <xsl:attribute name="href">
          <xsl:value-of select="wsdl:port/soap:address/@location" />
          </xsl:attribute>
        <xsl:value-of select="wsdl:port/soap:address/@location" />
        </xsl:element>
      </p>
    </xsl:template>

  <!-- display value or dot, to avoid empty cells -->
  <xsl:template name="valueordot">
    <xsl:param name="data" />
    <xsl:choose>
      <xsl:when test="$data">
        <xsl:value-of select="$data"/>
        </xsl:when>
      <xsl:otherwise>.</xsl:otherwise>
      </xsl:choose>    
    </xsl:template>
  
  <xsl:template match="/">
    <html>
      <head><title>Description du service <xsl:value-of select="wsdl:definitions/@name" /></title>
        <style type="text/css">
          th { background-color: #adf ; color: #000 ; text-align: left; vertical-align: top}
          dl { margin: 0 0 0 0em }
          dt { width: 10em ; font-weight: bold ; margin: 0 }
          dd { margin: -1em 0 0 10em }
          </style>
        </head>
      <body>
      <h1>D&eacute;finition du service "<xsl:value-of select="wsdl:definitions/@name" />"</h1>
      <xsl:apply-templates select="wsdl:definitions/wsdl:service" />
      <xsl:apply-templates select="wsdl:definitions/wsdl:binding" />
      <p>L'ensemble de cette mise en forme est r&#233;alis&#233;e par une feuille de style XSL, sans code autre.
      Vous pouvez voir cette feuille <a href="wsdl.xsl">ici</a>.</p>
      <p>Merci d'avance de vos <a href="mailto:fgm@osinet.fr">remarques</a>, notamment des exemples de contrats
    qui ne passent pas</p>
      <p>(c) 2002 OSI / FG Marand</p>
      </body>
    </html>
    </xsl:template>
  </xsl:stylesheet>
