OSDN Git Service

* new files for XML documentation.
authorbje <bje>
Fri, 3 Aug 2001 05:43:34 +0000 (05:43 +0000)
committerbje <bje>
Fri, 3 Aug 2001 05:43:34 +0000 (05:43 +0000)
sid/component/component.dtd [new file with mode: 0644]
sid/component/component_html.xsl [new file with mode: 0644]

diff --git a/sid/component/component.dtd b/sid/component/component.dtd
new file mode 100644 (file)
index 0000000..5156f5b
--- /dev/null
@@ -0,0 +1,107 @@
+<?xml version="1.0" ?>
+
+<!-- this is the SID component documentation format.              -->
+<!-- it's indended for translation to docbook, and also           -->
+<!-- for interpretation by SID configuration systems.             -->
+
+
+<!-- basic "human consumption" inline content                     -->
+<!ENTITY % inline "name|title|em|tt|a|complib|component|pin|bus|attribute|accessor">
+
+<!-- convenience hyperlink + formatting tags -->
+<!ELEMENT bus (#PCDATA)>
+<!ELEMENT pin (#PCDATA)>
+<!ELEMENT attribute (#PCDATA)>
+<!ELEMENT accessor (#PCDATA)>
+<!ELEMENT component (#PCDATA)>
+<!ELEMENT complib (#PCDATA)>
+
+<!ELEMENT name (#PCDATA)>
+<!ELEMENT title (%inline;)*>
+<!ELEMENT em (%inline;)*>
+<!ELEMENT tt (%inline;)*>
+<!ELEMENT code (#PCDATA)*>
+
+<!-- hyperlinking is very important for this stuff, so we extend  -->
+<!-- the HTML linking model slightly with typed external links.   -->
+
+<!ELEMENT a (%inline;)*>
+<!ATTLIST a type (url|techdoc) "url">
+<!ATTLIST a href CDATA #REQUIRED>
+
+
+
+<!-- basic "human consumption" structural content                 -->
+<!ENTITY % block "title?,(%inline;|p|ul|ol|table|code)*">
+<!ELEMENT p (%block;)>
+<!ELEMENT ul (title?,li*)>
+<!ELEMENT ol (title?,li*)>
+<!ELEMENT li (%block;)>
+<!ELEMENT table (tr*)>
+<!ELEMENT tr (th|td)*>
+<!ELEMENT th (%inline;)*>
+<!ELEMENT td (%inline;)*>
+
+
+<!-- the main structure of the document is as such                -->
+<!ELEMENT defcomplib (defcomponent,synop,func,env,refs?)>
+<!ATTLIST defcomplib lib CDATA #REQUIRED>
+<!ATTLIST defcomplib dlsym CDATA #REQUIRED>
+
+<!ELEMENT synop (%block;)>
+<!ELEMENT env (%block;)>
+<!ELEMENT refs (%block;)>
+
+<!-- the functionality section includes some machine-indexable    -->
+<!-- material, such as names of behaviors and conventions        -->
+<!-- but there's plenty of room for human annotation              -->
+
+<!ELEMENT func (modelling,behavior*,convention*)>
+<!ELEMENT modelling (%block;)>
+
+<!-- conventions and behaviors must be named for purposes of     -->
+<!-- indexing & xref, but may have comments (a block) inside      -->
+
+<!ELEMENT behavior (%block;)>
+<!ATTLIST behavior name CDATA #REQUIRED>
+
+<!ELEMENT convention (%block;)>
+<!ATTLIST convention name CDATA #REQUIRED>
+<!ATTLIST convention supported (true|false) "true">
+
+
+
+<!-- the parts of the document which may be interesting to a      -->
+<!-- SID configuration processor                                  -->
+
+<!ELEMENT defcomponent ((defpin|defbus|defattribute|defaccessor)*,variants?)>
+<!ATTLIST defcomponent name CDATA #REQUIRED>
+<!ATTLIST defcomponent type (abstract|concrete) "concrete">
+
+<!ELEMENT variants (defcomponent+)>
+
+<!ELEMENT defpin EMPTY>
+<!ATTLIST defpin name CDATA #REQUIRED>
+<!ATTLIST defpin direction (in|out|inout) #REQUIRED>
+<!ATTLIST defpin legalvalues CDATA #IMPLIED>
+<!ATTLIST defpin behaviors CDATA #REQUIRED>
+
+<!ELEMENT defbus EMPTY>
+<!ATTLIST defbus name CDATA #REQUIRED>
+<!ATTLIST defbus addresses CDATA #IMPLIED>
+<!ATTLIST defbus accesses CDATA #IMPLIED>
+<!ATTLIST defbus behaviors CDATA #REQUIRED>
+
+<!ELEMENT defattribute EMPTY>
+<!ATTLIST defattribute name CDATA #REQUIRED>
+<!ATTLIST defattribute category CDATA #IMPLIED>
+<!ATTLIST defattribute legalvalues CDATA #REQUIRED>
+<!ATTLIST defattribute defaultvalue CDATA #IMPLIED>
+<!ATTLIST defattribute behaviors CDATA #REQUIRED>
+
+<!ELEMENT defaccessor EMPTY>
+<!ATTLIST defaccessor name CDATA #REQUIRED>
+<!ATTLIST defaccessor accesses CDATA #IMPLIED>
+<!ATTLIST defaccessor behaviors CDATA #REQUIRED>
+
+
diff --git a/sid/component/component_html.xsl b/sid/component/component_html.xsl
new file mode 100644 (file)
index 0000000..ec6192c
--- /dev/null
@@ -0,0 +1,327 @@
+<xsl:stylesheet version="1.0"
+               xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+               xmlns="http://www.w3.org/TR/xhtml1/strict">
+
+  <!-- call this with a result-tree-fragment -->
+  <xsl:template name="maybecell-copy">
+    <td>
+      <xsl:param name="body"></xsl:param>
+      <xsl:choose>
+       <xsl:when test="count($body)=0">-</xsl:when>
+       <xsl:otherwise>
+         <xsl:copy-of select="$body"/>
+       </xsl:otherwise>
+      </xsl:choose>
+    </td>
+  </xsl:template>
+
+  <!-- call this with a node-set or expression value -->
+  <xsl:template name="maybecell">
+    <td>
+      <xsl:param name="body"></xsl:param>
+      <xsl:choose>
+       <xsl:when test="count($body)=0">-</xsl:when>
+       <xsl:otherwise>
+         <xsl:apply-templates select="$body"/>
+       </xsl:otherwise>
+      </xsl:choose>
+    </td>
+  </xsl:template>
+
+
+  
+  <xsl:template match="defcomponent">
+
+    <h3>
+      <a name='component-{normalize-space(translate(@name,"/","_"))}'>
+       <xsl:choose>
+         <xsl:when test="../../variants">Variant: </xsl:when>
+         <xsl:otherwise>Component: </xsl:otherwise>
+       </xsl:choose>
+       <xsl:value-of select="@name" /> 
+       <xsl:if test="@type='abstract'"> (Abstract)</xsl:if>
+       </a>
+    </h3>
+
+    <xsl:choose>
+      <xsl:when test="count(./*) = 0">
+       <p>
+         <xsl:choose>
+           <xsl:when test="../../../defcomponent">Same as <xsl:value-of select="../../../defcomponent/attribute::name"/></xsl:when>
+           <xsl:otherwise>Unspecified</xsl:otherwise>
+         </xsl:choose>
+       </p>
+      </xsl:when>
+
+      <xsl:otherwise>
+       <xsl:if test="count(./defpin)">
+         <p>
+           <table cellpadding="10" cellspacing="0" border="1" width="70%">
+             <tr><th colspan="4" bgcolor="eeeeee">pins</th></tr>
+             <tr><th>name</th><th>direction</th><th>legalvalues</th><th>behaviors</th></tr>
+             <xsl:apply-templates select="./defpin"/>
+           </table>
+         </p>
+       </xsl:if>
+
+       <xsl:if test="count(./defbus)">
+         <p>
+           <table cellpadding="10" cellspacing="0" border="1" width="70%">
+             <tr><th colspan="4" bgcolor="eeeeee">buses</th></tr>
+             <tr><th>name</th><th>addresses</th><th>accesses</th><th>behaviors</th></tr>
+             <xsl:apply-templates select="./defbus"/>
+           </table>
+         </p>
+       </xsl:if>
+       
+       <xsl:if test="count(./defattribute)">
+         <p>
+           <table cellpadding="10" cellspacing="0" border="1" width="70%">
+             <tr><th colspan="6" bgcolor="eeeeee">attributes</th></tr>
+             <tr><th>name</th><th>category</th><th>legal values</th><th>default value</th><th>behaviors</th></tr>
+             <xsl:apply-templates select="./defattribute"/>
+           </table>
+         </p>
+       </xsl:if>
+       
+       <xsl:if test="count(./defaccessor)">
+         <p>
+           <table cellpadding="10" cellspacing="0" border="1" width="70%">
+             <tr><th colspan="3" bgcolor="eeeeee">accessors</th></tr>
+             <tr><th>name</th><th>accesses</th><th>behaviors</th></tr>
+             <xsl:apply-templates select="./defaccessor"/>
+           </table>
+         </p>
+       </xsl:if>
+
+      </xsl:otherwise>
+    </xsl:choose>
+
+    <xsl:apply-templates select="./variants"/>
+
+  </xsl:template>
+  
+  <xsl:template match="defpin">
+    <tr>
+      <xsl:call-template name="maybecell-copy">
+       <xsl:with-param name="body">
+         <a name="pin-{normalize-space(@name)}"><xsl:value-of select="@name"/></a>
+       </xsl:with-param>
+      </xsl:call-template>
+      <xsl:call-template name="maybecell"><xsl:with-param name="body" select="@direction"/></xsl:call-template>
+      <xsl:call-template name="maybecell"><xsl:with-param name="body" select="@legalvalues"/></xsl:call-template>
+      <xsl:call-template name="maybecell-copy">
+       <xsl:with-param name="body">
+         <a href="#behavior-{@behaviors}"><xsl:value-of select="@behaviors"/></a>
+       </xsl:with-param>
+      </xsl:call-template>
+    </tr>
+  </xsl:template>
+
+  <xsl:template match="defbus">
+    <tr>
+      <xsl:call-template name="maybecell-copy">
+       <xsl:with-param name="body">
+         <a name="bus-{normalize-space(@name)}"><xsl:value-of select="@name"/></a>
+       </xsl:with-param>
+      </xsl:call-template>
+      <xsl:call-template name="maybecell"><xsl:with-param name="body" select="@addresses"/></xsl:call-template>
+      <xsl:call-template name="maybecell"><xsl:with-param name="body" select="@accesses"/></xsl:call-template>
+      <xsl:call-template name="maybecell-copy">
+       <xsl:with-param name="body">
+         <a href="#behavior-{@behaviors}"><xsl:value-of select="@behaviors"/></a>
+       </xsl:with-param>
+      </xsl:call-template>
+    </tr>
+  </xsl:template>
+
+  <xsl:template match="defattribute">
+    <tr>
+      <xsl:call-template name="maybecell-copy">
+       <xsl:with-param name="body">
+         <a name="attribute-{normalize-space(@name)}"><xsl:value-of select="@name"/></a>
+       </xsl:with-param>
+      </xsl:call-template>
+      <xsl:call-template name="maybecell"><xsl:with-param name="body" select="@category"/></xsl:call-template>
+      <xsl:call-template name="maybecell"><xsl:with-param name="body" select="@legalvalues"/></xsl:call-template>
+      <xsl:call-template name="maybecell"><xsl:with-param name="body" select="@defaultvalue"/></xsl:call-template>
+      <xsl:call-template name="maybecell-copy">
+       <xsl:with-param name="body">
+         <a href="#behavior-{@behaviors}"><xsl:value-of select="@behaviors"/></a>
+       </xsl:with-param>
+      </xsl:call-template>
+    </tr>
+  </xsl:template>
+
+  <xsl:template match="defaccessor">
+    <tr>
+      <xsl:call-template name="maybecell-copy">
+       <xsl:with-param name="body">
+         <a name="accessor-{normalize-space(@name)}"><xsl:value-of select="@name"/></a>
+       </xsl:with-param>
+      </xsl:call-template>
+      <xsl:call-template name="maybecell"><xsl:with-param name="body" select="@accesses"/></xsl:call-template>
+      <xsl:call-template name="maybecell-copy">
+       <xsl:with-param name="body">
+         <a href="#behavior-{@behaviors}"><xsl:value-of select="@behaviors"/></a>
+       </xsl:with-param>
+      </xsl:call-template>
+    </tr>
+  </xsl:template>
+
+
+  <xsl:template match="defcomplib">
+    <xsl:variable name="cname">
+      <xsl:value-of select="./defcomponent/attribute::name" />
+    </xsl:variable>
+
+    <xsl:variable name="title">
+      <xsl:value-of select="./defcomponent/attribute::name" />
+      <xsl:if test="count(./defcomponent/variants//defcomponent) > 1">
+       (<xsl:for-each select="./defcomponent/variants//defcomponent">
+         <xsl:text> </xsl:text>
+         <xsl:value-of select="./@name" /> 
+         <xsl:text> </xsl:text>
+       </xsl:for-each>)
+      </xsl:if>
+    </xsl:variable>
+
+    <html>
+      <head>
+       <title><xsl:copy-of select="$title" /></title>  
+      </head>
+      <body bgcolor="ffffff">
+       <h1><xsl:value-of select="$cname" /> (<xsl:value-of select="@lib" /> :: <xsl:value-of select="@dlsym" />)</h1>
+
+       <h2>Synopsis:</h2>
+       <xsl:apply-templates select="./synop"/>
+
+       <hr noshade="true"/>
+       <h2>Functionality:</h2>
+       <xsl:apply-templates select="./func"/>
+
+       <hr noshade="true"/>
+       <h2>Environment:</h2>
+       <xsl:apply-templates select="./env"/>
+
+       <hr noshade="true"/>
+       <h2>Component Reference:</h2>
+       <xsl:apply-templates select="./defcomponent"/>
+
+       <xsl:if test="./refs">
+         <hr noshade="true"/>  
+         <h2>References:</h2>  
+         <xsl:apply-templates select="./refs"/>
+       </xsl:if>
+
+      </body>
+    </html>
+  </xsl:template>  <!-- end defcomplib -->
+  
+
+  <xsl:template match="pin|bus|attribute|accessor">
+    <a href="#{local-name()}-{normalize-space(string(.))}"><tt><xsl:apply-templates/></tt></a>
+  </xsl:template>
+
+  <xsl:template match="component">
+    <a href='#component-{normalize-space(translate(string(.),"/","_"))}'><tt><xsl:apply-templates/></tt></a>
+  </xsl:template>
+
+  <xsl:template match="complib">
+    <a href="{string(.)}.html"><tt><xsl:apply-templates/></tt></a>
+  </xsl:template>
+
+  <xsl:template match="name">"<tt><xsl:apply-templates/></tt>"</xsl:template>
+    
+  <xsl:template match="table">
+    <table border="1" cellspacing="0" cellpadding="5">
+      <xsl:apply-templates />
+    </table>
+  </xsl:template>
+
+  <xsl:template match="th">
+    <th align="left">
+      <xsl:apply-templates />
+    </th>
+  </xsl:template>
+
+
+  <xsl:template match="em|tt|p|li|tr|td">
+    <xsl:element name="{local-name()}">
+      <xsl:apply-templates />
+    </xsl:element>
+  </xsl:template>
+
+  <xsl:template match="code">
+    <tt><pre><xsl:apply-templates /></pre></tt>
+  </xsl:template>
+
+  <xsl:template match="title">
+    <font size="+1"><U><xsl:apply-templates /></U></font> <br />
+  </xsl:template>
+
+  <xsl:template match="a">
+    <xsl:variable name="link">
+      <xsl:choose>
+       <xsl:when test="@type='url'"><xsl:value-of select="@href" /></xsl:when>
+       <xsl:when test="@type='techdoc'">
+         http://sources.redhat.com/sid/techdoc.cgi?<xsl:value-of select="@href" />
+       </xsl:when>
+       <xsl:when test="@type='component'">
+         http://sources.redhat.com/sid/component.cgi?<xsl:value-of select="@href" />
+       </xsl:when>     
+      </xsl:choose>
+    </xsl:variable>
+    <a href="{$link}"><xsl:apply-templates /></a>
+  </xsl:template>
+  
+  <xsl:template match="synop|env|refs|behavior|convention|modelling">
+    <p><xsl:apply-templates /></p>
+  </xsl:template>
+
+  <xsl:template match="func">
+    <h3>Modelling:</h3>
+    <xsl:apply-templates select="./modelling"/>
+
+    <xsl:if test="count(./behavior) != 0">
+      <p>
+       <table cellspacing="0" cellpadding="10" border="1" width="70%">
+         <tr><th colspan="2" bgcolor="eeeeee">Behaviors</th></tr>
+         <xsl:for-each select="./behavior">
+           <tr>
+             <td align="right" valign="top"><a name="behavior-{@name}"><xsl:value-of select="@name"/></a></td>
+             <td align="left" valign="top"><xsl:apply-templates/></td>
+           </tr>
+         </xsl:for-each>
+       </table>
+      </p>
+    </xsl:if>
+
+    <xsl:if test="count(./convention) != 0">
+      <p>
+       <table cellpadding="10" cellspacing="0" border="1" width="70%">
+         <tr><th colspan="3" bgcolor="eeeeee">SID Conventions</th></tr>
+         <xsl:for-each select="./convention">
+           <tr>
+             <td align="right" valign="top"><a name="convention-{@name}"><xsl:value-of select="@name"/></a></td>
+             <td align="left" valign="top">
+               <xsl:if test="@supported='false'">not </xsl:if> supported
+             </td>
+             <xsl:call-template name="maybecell"><xsl:with-param name="body" select="./*"/></xsl:call-template>
+           </tr>
+         </xsl:for-each>
+       </table>
+      </p>
+    </xsl:if>
+  </xsl:template>
+
+
+  <xsl:template match="ul|ol">
+    <xsl:apply-templates select="./title"/>    
+    <xsl:element name="{local-name()}">
+      <xsl:apply-templates select="./li"/>
+    </xsl:element>
+  </xsl:template>
+    
+
+</xsl:stylesheet>