home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 October / INTERNET108.ISO / pc / software / windows / building / xmlspy / xmlspyentcomplete5.exe / Data1.cab / _5F1DF1BE9FDC46BD93A7AEE8EBBBE2C8 < prev    next >
Encoding:
Extensible Markup Language  |  2002-09-04  |  9.6 KB  |  325 lines

  1. <?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3.                 xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
  4.                 exclude-result-prefixes="doc"
  5.                 version='1.0'>
  6.  
  7. <!-- ********************************************************************
  8.      $Id: ebnf.xsl,v 1.1.2.1 2002/09/04 13:50:25 jdj Exp $
  9.      ********************************************************************
  10.  
  11.      This file is part of the XSL DocBook Stylesheet distribution.
  12.      See ../README or http://nwalsh.com/docbook/xsl/ for copyright
  13.      and other information.
  14.  
  15.      ******************************************************************** -->
  16.  
  17. <doc:reference xmlns="">
  18. <referenceinfo>
  19. <releaseinfo role="meta">
  20. $Id: ebnf.xsl,v 1.1.2.1 2002/09/04 13:50:25 jdj Exp $
  21. </releaseinfo>
  22. <author><surname>Walsh</surname>
  23. <firstname>Norman</firstname></author>
  24. <copyright><year>1999</year><year>2000</year>
  25. <holder>Norman Walsh</holder>
  26. </copyright>
  27. </referenceinfo>
  28. <title>HTML EBNF Reference</title>
  29.  
  30. <partintro>
  31. <section><title>Introduction</title>
  32.  
  33. <para>This is technical reference documentation for the DocBook XSL
  34. Stylesheets; it documents (some of) the parameters, templates, and
  35. other elements of the stylesheets.</para>
  36.  
  37. <para>This reference describes the templates and parameters relevant
  38. to formatting EBNF markup.</para>
  39.  
  40. <para>This is not intended to be <quote>user</quote> documentation.
  41. It is provided for developers writing customization layers for the
  42. stylesheets, and for anyone who's interested in <quote>how it
  43. works</quote>.</para>
  44.  
  45. <para>Although I am trying to be thorough, this documentation is known
  46. to be incomplete. Don't forget to read the source, too :-)</para>
  47. </section>
  48. </partintro>
  49. </doc:reference>
  50.  
  51. <!-- ==================================================================== -->
  52.  
  53. <xsl:template match="productionset">
  54.   <table width="100%" cellpadding="5">
  55.     <xsl:if test="$ebnf.table.bgcolor != ''">
  56.       <xsl:attribute name="bgcolor">
  57.     <xsl:value-of select="$ebnf.table.bgcolor"/>
  58.       </xsl:attribute>
  59.     </xsl:if>
  60.     <xsl:if test="$ebnf.table.border != 0">
  61.       <xsl:attribute name="border">1</xsl:attribute>
  62.     </xsl:if>
  63.     <xsl:attribute name="class">
  64.       <xsl:value-of select="name(.)"/>
  65.     </xsl:attribute>
  66.     <xsl:attribute name="summary">
  67.       <xsl:text>EBNF</xsl:text>
  68.       <xsl:if test="title">
  69.     <xsl:text> for </xsl:text>
  70.     <xsl:value-of select="title"/>
  71.       </xsl:if>
  72.     </xsl:attribute>
  73.  
  74.     <xsl:if test="title">
  75.       <tr>
  76.     <th align="left" valign="top" class="{name(.)}">
  77.       <xsl:apply-templates select="title"/>
  78.     </th>
  79.       </tr>
  80.     </xsl:if>
  81.     <tr>
  82.       <td>
  83.     <table border="0" width="99%" cellpadding="0">
  84.       <xsl:if test="$ebnf.table.bgcolor != ''">
  85.         <xsl:attribute name="bgcolor">
  86.           <xsl:value-of select="$ebnf.table.bgcolor"/>
  87.         </xsl:attribute>
  88.       </xsl:if>
  89.       <xsl:attribute name="class">
  90.         <xsl:value-of select="name(.)"/>
  91.       </xsl:attribute>
  92.       <xsl:attribute name="summary">EBNF productions</xsl:attribute>
  93.       <xsl:apply-templates select="production|productionrecap"/>
  94.     </table>
  95.       </td>
  96.     </tr>
  97.   </table>
  98. </xsl:template>
  99.  
  100. <xsl:template match="productionset/title">
  101.   <xsl:apply-templates/>
  102. </xsl:template>
  103.  
  104. <xsl:template match="production">
  105.   <xsl:param name="recap" select="false()"/>
  106.   <tr>
  107.     <td align="left" valign="top" width="3%">
  108.       <xsl:text>[</xsl:text>
  109.       <xsl:number count="production" level="any"/>
  110.       <xsl:text>]</xsl:text>
  111.     </td>
  112.     <td align="right" valign="top" width="10%">
  113.       <xsl:choose>
  114.     <xsl:when test="$recap">
  115.       <a>
  116.         <xsl:attribute name="href">
  117.           <xsl:call-template name="href.target">
  118.         <xsl:with-param name="object" select="."/>
  119.           </xsl:call-template>
  120.         </xsl:attribute>
  121.         <xsl:apply-templates select="lhs"/>
  122.       </a>
  123.     </xsl:when>
  124.     <xsl:otherwise>
  125.           <xsl:call-template name="anchor"/>
  126.       <xsl:apply-templates select="lhs"/>
  127.     </xsl:otherwise>
  128.       </xsl:choose>
  129.     </td>
  130.     <td valign="top" width="5%" align="center"><tt>::=</tt></td>
  131.     <td valign="top" width="52%">
  132.       <xsl:apply-templates select="rhs"/>
  133.     </td>
  134.     <td align="left" valign="top" width="30%">
  135.       <xsl:choose>
  136.     <xsl:when test="rhs/lineannotation|constraint">
  137.           <xsl:apply-templates select="rhs/lineannotation" mode="rhslo"/>
  138.           <xsl:apply-templates select="constraint"/>
  139.     </xsl:when>
  140.     <xsl:otherwise>
  141.       <xsl:text> </xsl:text>
  142.     </xsl:otherwise>
  143.       </xsl:choose>
  144.     </td>
  145.   </tr>
  146. </xsl:template>
  147.  
  148. <xsl:template match="productionrecap">
  149.   <xsl:variable name="targets" select="key('id',@linkend)"/>
  150.   <xsl:variable name="target" select="$targets[1]"/>
  151.  
  152.   <xsl:if test="count($targets)=0">
  153.     <xsl:message>
  154.       <xsl:text>Error: no ID for productionrecap linkend: </xsl:text>
  155.       <xsl:value-of select="@linkend"/>
  156.       <xsl:text>.</xsl:text>
  157.     </xsl:message>
  158.   </xsl:if>
  159.  
  160.   <xsl:if test="count($targets)>1">
  161.     <xsl:message>
  162.       <xsl:text>Warning: multiple "IDs" for productionrecap linkend: </xsl:text>
  163.       <xsl:value-of select="@linkend"/>
  164.       <xsl:text>.</xsl:text>
  165.     </xsl:message>
  166.   </xsl:if>
  167.  
  168.   <xsl:apply-templates select="$target">
  169.     <xsl:with-param name="recap" select="true()"/>
  170.   </xsl:apply-templates>
  171. </xsl:template>
  172.  
  173. <xsl:template match="lhs">
  174.   <xsl:apply-templates/>
  175. </xsl:template>
  176.  
  177. <xsl:template match="rhs">
  178.   <xsl:apply-templates/>
  179.   <xsl:if test="following-sibling::rhs">
  180.     <xsl:text> |</xsl:text>
  181.     <br/>
  182.   </xsl:if>
  183. </xsl:template>
  184.  
  185. <xsl:template match="nonterminal">
  186.   <xsl:variable name="linkend">
  187.     <xsl:call-template name="xpointer.idref">
  188.       <xsl:with-param name="xpointer" select="@def"/>
  189.     </xsl:call-template>
  190.   </xsl:variable>
  191.  
  192.   <xsl:call-template name="check.id.unique">
  193.     <xsl:with-param name="linkend" select="$linkend"/>
  194.   </xsl:call-template>
  195.  
  196.   <xsl:call-template name="check.idref.targets">
  197.     <xsl:with-param name="linkend" select="$linkend"/>
  198.     <xsl:with-param name="element-list">production</xsl:with-param>
  199.   </xsl:call-template>
  200.  
  201.   <!-- If you don't provide content, you can't point outside this doc. -->
  202.   <xsl:choose>
  203.     <xsl:when test="*|text()"><!--nop--></xsl:when>
  204.     <xsl:otherwise>
  205.       <xsl:if test="$linkend = ''">
  206.     <xsl:message>
  207.       <xsl:text>Non-terminals with no content must point to </xsl:text>
  208.       <xsl:text>production elements in the current document.</xsl:text>
  209.     </xsl:message>
  210.     <xsl:message>
  211.       <xsl:text>Invalid xpointer for empty nt: </xsl:text>
  212.       <xsl:value-of select="@def"/>
  213.     </xsl:message>
  214.       </xsl:if>
  215.     </xsl:otherwise>
  216.   </xsl:choose>
  217.  
  218.   <xsl:variable name="href">
  219.     <xsl:choose>
  220.       <xsl:when test="$linkend != ''">
  221.     <xsl:variable name="targets" select="key('id',$linkend)"/>
  222.     <xsl:variable name="target" select="$targets[1]"/>
  223.     <xsl:call-template name="href.target">
  224.       <xsl:with-param name="object" select="$target"/>
  225.     </xsl:call-template>
  226.       </xsl:when>
  227.       <xsl:otherwise>
  228.     <xsl:value-of select="@def"/>
  229.       </xsl:otherwise>
  230.     </xsl:choose>
  231.   </xsl:variable>
  232.  
  233.   <a href="{$href}">
  234.     <xsl:choose>
  235.       <xsl:when test="*|text()">
  236.     <xsl:apply-templates/>
  237.       </xsl:when>
  238.       <xsl:otherwise>
  239.     <xsl:choose>
  240.       <xsl:when test="$linkend != ''">
  241.         <xsl:variable name="targets" select="key('id',$linkend)"/>
  242.         <xsl:variable name="target" select="$targets[1]"/>
  243.         <xsl:apply-templates select="$target/lhs"/>
  244.       </xsl:when>
  245.       <xsl:otherwise>
  246.         <xsl:text>???</xsl:text>
  247.       </xsl:otherwise>
  248.     </xsl:choose>
  249.       </xsl:otherwise>
  250.     </xsl:choose>
  251.   </a>
  252. </xsl:template>
  253.  
  254. <xsl:template match="rhs/lineannotation">
  255.   <!--nop-->
  256. </xsl:template>
  257.  
  258. <xsl:template match="rhs/lineannotation" mode="rhslo">
  259.   <xsl:text>/* </xsl:text>
  260.   <xsl:apply-templates/>
  261.   <xsl:text> */</xsl:text>
  262.   <br/>
  263. </xsl:template>
  264.  
  265. <xsl:template match="constraint">
  266.   <xsl:call-template name="check.id.unique">
  267.     <xsl:with-param name="linkend" select="@linkend"/>
  268.   </xsl:call-template>
  269.  
  270.   <xsl:call-template name="check.idref.targets">
  271.     <xsl:with-param name="linkend" select="@linkend"/>
  272.     <xsl:with-param name="element-list">constraintdef</xsl:with-param>
  273.   </xsl:call-template>
  274.  
  275.   <xsl:variable name="href">
  276.     <xsl:variable name="targets" select="key('id',@linkend)"/>
  277.     <xsl:variable name="target" select="$targets[1]"/>
  278.     <xsl:call-template name="href.target">
  279.       <xsl:with-param name="object" select="$target"/>
  280.     </xsl:call-template>
  281.   </xsl:variable>
  282.  
  283.   <xsl:text>[ </xsl:text>
  284.  
  285.   <xsl:choose>
  286.     <xsl:when test="@role">
  287.       <xsl:value-of select="@role"/>
  288.       <xsl:text>: </xsl:text>
  289.     </xsl:when>
  290.     <xsl:otherwise>
  291.       <xsl:variable name="targets" select="key('id',@linkend)"/>
  292.       <xsl:variable name="target" select="$targets[1]"/>
  293.       <xsl:if test="$target/@role">
  294.     <xsl:value-of select="$target/@role"/>
  295.     <xsl:text>: </xsl:text>
  296.       </xsl:if>
  297.     </xsl:otherwise>
  298.   </xsl:choose>
  299.  
  300.   <a href="{$href}">
  301.     <xsl:variable name="targets" select="key('id',@linkend)"/>
  302.     <xsl:variable name="target" select="$targets[1]"/>
  303.     <xsl:apply-templates select="$target" mode="title.markup"/>
  304.   </a>
  305.   <xsl:text> ]</xsl:text>
  306.   <xsl:if test="following-sibling::constraint">
  307.     <br/>
  308.   </xsl:if>
  309. </xsl:template>
  310.  
  311. <xsl:template match="constraintdef">
  312.   <div class="{name(.)}">
  313.     <xsl:call-template name="anchor"/>
  314.     <xsl:apply-templates/>
  315.   </div>
  316. </xsl:template>
  317.  
  318. <xsl:template match="constraintdef/title">
  319.   <p><b><xsl:apply-templates/></b></p>
  320. </xsl:template>
  321.  
  322. <!-- ==================================================================== -->
  323.  
  324. </xsl:stylesheet>
  325.