
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 

<!-- SAPI2HTML by James Matthews (v0.9 - 5/4/03) -->

<xsl:output method="html" indent="yes"/>
<xsl:template match="/">

<html>
<head>
<title>Sapi2HTML</title>
<style>
  .optional			{ color:darkgray;font-family:Verdana;font-size:8pt; }
  .optional table	{ color:darkgray; }
  .main				{ font-family:Verdana;font-size:8pt;border:1 solid black; }
  .embedded			{ font-family:Verdana;font-size:8pt;border:1 solid lightgray; }
  A.silent			{ color:darkgray;text-decoration:none; }
  A.silent:Hover	{ color:black;text-decoration:underline; }
</style>
</head>
<body>

<xsl:for-each select="GRAMMAR/RULE">

  <xsl:variable name="RuleID"><xsl:value-of select="@ID"/></xsl:variable>

  <xsl:text disable-output-escaping="yes">&#60;a name="</xsl:text>
    <xsl:copy-of select="$RuleID"/>
  <xsl:text disable-output-escaping="yes">"&#62;&#60;/a&#62;</xsl:text>

  <table width="400" cellpadding="3" cellspacing="0" class="main">
    <tr>
	  <td bgcolor="#efefef" width="100%">
      <b><xsl:copy-of select="$RuleID"/></b>
      </td>
	  <td width="40" align="right" bgcolor="#efefef">

  <xsl:value-of select="/GRAMMAR/DEFINE/ID[@NAME=$RuleID]/@VAL"/>
  
      </td>
	</tr>
    <tr>
	  <td colspan="2" class="larger">
        <xsl:apply-templates select="*"/>
      </td>
	</tr>
  </table>
  <br/>
</xsl:for-each>

<div class="optional">- Converted by Sapi2HTML by J.Matthews (<A TARGET="_Blank" HREF="http://www.generation5.org/" CLASS="Silent">http://www.generation5.org/</A>)</div>
</body>
</html>

</xsl:template>

<xsl:template match="RULEREF">
  <xsl:variable name="RefID"><xsl:value-of select="@REFID"/></xsl:variable>
  
  <xsl:text disable-output-escaping="yes">&#60;a href="#</xsl:text>
    <xsl:copy-of select="$RefID"/>
  <xsl:text disable-output-escaping="yes">"&#62;</xsl:text>
    <xsl:copy-of select="$RefID"/>
  <xsl:text disable-output-escaping="yes">&#60;/a&#62;</xsl:text> 
  <xsl:text> </xsl:text>

  <xsl:apply-templates select="*"/>

</xsl:template>

<xsl:template match="P|PHRASE">
  <xsl:text disable-output-escaping="yes">&#60;span title="</xsl:text>
<xsl:if test="@MIN"><xsl:text>PMIN = </xsl:text><xsl:value-of select="@MIN"/></xsl:if><xsl:text> </xsl:text>
<xsl:if test="@MAX"><xsl:text>PMAX = </xsl:text><xsl:value-of select="@MAX"/></xsl:if><xsl:text> </xsl:text>
<xsl:if test="@PROPNAME"><xsl:text>PPROPNAME = </xsl:text><xsl:value-of select="@PROPNAME"/></xsl:if>
  <xsl:text disable-output-escaping="yes">"&#62;</xsl:text>
  <xsl:copy use-attribute-sets="br">
    <xsl:text> </xsl:text>
	<xsl:apply-templates/>
	<xsl:text> </xsl:text>
  </xsl:copy>
  <xsl:text disable-output-escaping="yes">&#60;/span&#62;</xsl:text>
</xsl:template>

<xsl:template match="O|OPT">
  <span class="optional">
	<xsl:copy>
      <xsl:apply-templates/>
	</xsl:copy>
  </span><xsl:text> </xsl:text>
</xsl:template>

<xsl:template match="L|LIST">
  <xsl:text disable-output-escaping="yes">&#60;table width="100%" class="embedded" </xsl:text>
    <xsl:if test="@PROPID">
	  <xsl:text>title="LPROPID = </xsl:text><xsl:value-of select="@PROPID"/><xsl:text>"</xsl:text>
	</xsl:if>
  <xsl:text disable-output-escaping="yes">&#62;</xsl:text>

  <xsl:for-each select="P|PHRASE|RULEREF">
    
	<xsl:if test="name() = 'P' or name() = 'PHRASE'">
	<xsl:variable name="ItemVal"><xsl:value-of select="@VAL"/></xsl:variable>
    <tr>
	  <td width="66%">- <xsl:value-of select="text()"/></td>
	  <td><xsl:copy-of select="$ItemVal"/></td>
	  <td><xsl:value-of select="/GRAMMAR/DEFINE/ID[@NAME=$ItemVal]/@VAL"/></td>
	</tr>
	</xsl:if>
	
	<xsl:if test="name() = 'RULEREF'">
	<xsl:variable name="ItemVal"><xsl:value-of select="@VAL"/></xsl:variable>
    <tr>
	  <td width="66%">
	  <xsl:variable name="RefID2"><xsl:value-of select="@REFID"/></xsl:variable>
	  <xsl:text disable-output-escaping="yes">&#60;a href="#</xsl:text>
		<xsl:copy-of select="$RefID2"/>
	  <xsl:text disable-output-escaping="yes">"&#62;</xsl:text>
		<xsl:copy-of select="$RefID2"/>
	  <xsl:text disable-output-escaping="yes">&#60;/a&#62;</xsl:text> 
	  <xsl:text> </xsl:text>
	  </td>
	  <xsl:variable name="PropID2"><xsl:value-of select="@PROPID"/></xsl:variable>
	  <td><xsl:copy-of select="$PropID2"/></td>
	  <td><xsl:value-of select="/GRAMMAR/DEFINE/ID[@NAME=$PropID2]/@VAL"/></td>
	</tr>
	</xsl:if>

  </xsl:for-each>
  <xsl:text disable-output-escaping="yes">
    &#60;/table&#62;
  </xsl:text>

</xsl:template>

<xsl:attribute-set name="br"> 
     <xsl:attribute name="style">display:inline;</xsl:attribute> 
</xsl:attribute-set>

</xsl:stylesheet>

