home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 October / INTERNET108.ISO / pc / software / windows / building / xmlspy / xmlspyentcomplete5.exe / Data1.cab / _F24006F8AA174845AC32971DE3CB86BD < prev    next >
Encoding:
Text File  |  2002-10-21  |  5.6 KB  |  195 lines

  1. <!-- 
  2. TEI XSLT stylesheet family version 1.2
  3. RCS: $Date: 2002/10/21 13:44:20 $, $Revision: 1.1.2.1 $, $Author: jdj $
  4.  
  5. XSL stylesheet to format TEI XML documents to HTML or XSL FO
  6.  
  7.  Copyright 1999-2002 Sebastian Rahtz/Oxford University  <sebastian.rahtz@oucs.ox.ac.uk>
  8.  
  9.  Permission is hereby granted, free of charge, to any person obtaining
  10.  a copy of this software and any associated documentation files (the
  11.  ``Software''), to deal in the Software without restriction, including
  12.  without limitation the rights to use, copy, modify, merge, publish,
  13.  distribute, sublicense, and/or sell copies of the Software, and to
  14.  permit persons to whom the Software is furnished to do so, subject to
  15.  the following conditions:
  16.  
  17.  The above copyright notice and this permission notice shall be included
  18.  in all copies or substantial portions of the Software.
  19. --> 
  20. <xsl:stylesheet
  21.   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  22.  
  23.  
  24. <!-- lists -->
  25.  
  26.  
  27. <xsl:template match="list">
  28. <xsl:if test="head">
  29.   <p><em><xsl:apply-templates select="head"/></em></p>
  30. </xsl:if>
  31. <xsl:choose>
  32.  <xsl:when test="@type='catalogue'">
  33.   <p><dl>
  34.     <xsl:for-each select="item">
  35.        <p/>
  36.        <xsl:apply-templates select="."  mode="gloss"/>
  37.     </xsl:for-each>
  38.   </dl></p>
  39.  </xsl:when>
  40.   <xsl:when test="@type='gloss' and @rend='multicol'">
  41.     <xsl:variable name="nitems">
  42.       <xsl:value-of select="count(item)div 2"/>
  43.     </xsl:variable>
  44.     <p><table>
  45.     <tr>
  46.       <td valign="top">
  47.       <dl>
  48.          <xsl:apply-templates mode="gloss" select="item[position()<=$nitems ]"/>
  49.       </dl>
  50.       </td>
  51.       <td  valign="top">
  52.       <dl>
  53.          <xsl:apply-templates mode="gloss" select="item[position() >$nitems]"/>
  54.       </dl>
  55.       </td>
  56.      </tr>
  57.     </table>
  58.     </p>
  59.   </xsl:when>
  60.  
  61.  <xsl:when test="@type='gloss'">
  62.   <p><dl><xsl:apply-templates mode="gloss" select="item"/></dl></p>
  63.  </xsl:when>
  64.  <xsl:when test="@type='glosstable'">
  65.   <table><xsl:apply-templates mode="glosstable" select="item"/></table>
  66.  </xsl:when>
  67.  <xsl:when test="@type='inline'">
  68.    <xsl:if test="not(item)">None</xsl:if>
  69.   <xsl:apply-templates select="item" mode="inline"/>
  70.  </xsl:when>
  71.  <xsl:when test="@type='runin'">
  72.   <p><xsl:apply-templates select="item" mode="runin"/></p>
  73.  </xsl:when>
  74.  <xsl:when test="@type='unordered'">
  75.   <ul>
  76.   <xsl:choose>
  77.   <xsl:when test="@rend and starts-with(@rend,'class:')">
  78.     <xsl:attribute name="class">
  79.       <xsl:value-of select="substring-after(@rend,'class:')"/>
  80.     </xsl:attribute>
  81.   </xsl:when>
  82.   <xsl:when test="@rend">
  83.     <xsl:attribute name="class"><xsl:value-of select="@rend"/></xsl:attribute>
  84.   </xsl:when>
  85.   </xsl:choose>
  86.   <xsl:apply-templates select="item"/></ul>
  87.  </xsl:when>
  88.  <xsl:when test="@type='bibl'">
  89.   <xsl:apply-templates select="item" mode="bibl"/>
  90.  </xsl:when>
  91.  <xsl:when test="@type='ordered'">
  92.   <ol>
  93.     <xsl:choose>
  94.         <xsl:when test="@rend and starts-with(@rend,'class:')">
  95.     <xsl:attribute name="class">
  96.       <xsl:value-of select="substring-after(@rend,'class:')"/>
  97.     </xsl:attribute>
  98.   </xsl:when>
  99.   <xsl:when test="@rend">
  100.     <xsl:attribute name="class"><xsl:value-of select="@rend"/></xsl:attribute>
  101.   </xsl:when>
  102. </xsl:choose>
  103.   <xsl:apply-templates select="item"/></ol>
  104.  </xsl:when>
  105.  <xsl:otherwise>
  106.   <ul>
  107.     <xsl:choose>
  108.         <xsl:when test="@rend and starts-with(@rend,'class:')">
  109.     <xsl:attribute name="class">
  110.       <xsl:value-of select="substring-after(@rend,'class:')"/>
  111.     </xsl:attribute>
  112.   </xsl:when>
  113.   <xsl:when test="@rend">
  114.     <xsl:attribute name="class"><xsl:value-of select="@rend"/></xsl:attribute>
  115.   </xsl:when>
  116. </xsl:choose>
  117.   <xsl:apply-templates select="item"/></ul>
  118.  </xsl:otherwise>
  119. </xsl:choose>
  120. </xsl:template>
  121.  
  122. <xsl:template mode="bibl" match="item">
  123.  <p>
  124.    <xsl:apply-templates/>
  125.  </p>
  126. </xsl:template>
  127.  
  128. <xsl:template mode="glosstable" match="item">
  129.  <tr>
  130.    <td valign="top"><strong>
  131.      <xsl:apply-templates mode="print" select="preceding-sibling::*[1]"/></strong></td>
  132.    <td><xsl:apply-templates/></td>
  133.  </tr>
  134. </xsl:template>
  135.  
  136. <xsl:template mode="gloss" match="item">
  137.    <dt><strong>
  138.      <xsl:apply-templates mode="print" select="preceding-sibling::label[1]"/>
  139.    </strong>
  140.    </dt>
  141.    <dd><xsl:apply-templates/></dd>
  142. </xsl:template>
  143.  
  144. <xsl:template match="item/label">
  145.     <xsl:choose>
  146.     <xsl:when test="@rend">
  147.           <xsl:call-template name="rendering"/>
  148.     </xsl:when>
  149.         <xsl:otherwise>
  150.           <strong><xsl:apply-templates/></strong>
  151.         </xsl:otherwise>     
  152.     </xsl:choose>
  153. </xsl:template>
  154.  
  155. <xsl:template match="list/label"/>
  156.  
  157. <xsl:template match="item">
  158.  <li><a>
  159.  <xsl:attribute name="name">
  160.      <xsl:choose>
  161.      <xsl:when test="@id">
  162.        <xsl:value-of select="@id"/>
  163.      </xsl:when>
  164.      <xsl:otherwise>
  165.       <xsl:value-of select="generate-id()"/>
  166.      </xsl:otherwise>
  167.     </xsl:choose>
  168.   </xsl:attribute></a>
  169. <xsl:apply-templates/></li>
  170. </xsl:template>
  171.  
  172. <xsl:template match="item" mode="runin">
  173.   • <xsl:apply-templates/> 
  174. </xsl:template>
  175.  
  176. <xsl:template match="item" mode="inline">
  177.   <xsl:if test="preceding-sibling::item">,  </xsl:if>
  178.   <xsl:if test="not(following-sibling::item) and preceding-sibling::item"> and  </xsl:if>   
  179.   <xsl:apply-templates/>
  180. </xsl:template>
  181.  
  182. <xsl:template match="label" mode="print">
  183. <xsl:if test="@id"><a name="{@id}"/></xsl:if>
  184. <xsl:choose>
  185.     <xsl:when test="@rend">
  186.         <xsl:call-template name="rendering"/>
  187.     </xsl:when>
  188.     <xsl:otherwise>
  189.         <xsl:apply-templates/>
  190.     </xsl:otherwise>
  191. </xsl:choose>
  192. </xsl:template>
  193.  
  194. </xsl:stylesheet>
  195.