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

  1.    <!-- 
  2. TEI XSLT stylesheet family version 1.2
  3. RCS: $Date: 2002/10/21 13:44:23 $, $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.  Various bits supplied by Peter Boot <pboot@attglobal.net>
  10.  
  11.  Permission is hereby granted, free of charge, to any person obtaining
  12.  a copy of this software and any associated documentation files (the
  13.  ``Software''), to deal in the Software without restriction, including
  14.  without limitation the rights to use, copy, modify, merge, publish,
  15.  distribute, sublicense, and/or sell copies of the Software, and to
  16.  permit persons to whom the Software is furnished to do so, subject to
  17.  the following conditions:
  18.  
  19.  The above copyright notice and this permission notice shall be included
  20.  in all copies or substantial portions of the Software.
  21. --> 
  22. <xsl:stylesheet
  23.   xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  24.   version="1.0">
  25.  
  26. <!-- rendering. support for multiple rendition elements added
  27. by Nick Nicholas -->
  28.  
  29. <xsl:template name="rendering">
  30. <xsl:call-template name="applyRend">
  31.    <xsl:with-param name="parms" select="concat(@rend,$rendSeparator)"/>
  32. </xsl:call-template>
  33. </xsl:template>
  34.  
  35. <xsl:template name="applyRend">
  36.    <xsl:param name="parms"/>
  37.    <xsl:choose>
  38.    <xsl:when test="not($parms='')">
  39.      <xsl:variable name="thisparm" select="substring-before($parms,
  40. $rendSeparator)"/>
  41.      <xsl:call-template name="renderingInner">
  42.       <xsl:with-param name="rend" select="$thisparm"/>
  43.       <xsl:with-param name="rest" select="substring-after($parms,
  44. $rendSeparator)"/>
  45.      </xsl:call-template>
  46.    </xsl:when>
  47.    <xsl:otherwise>
  48.      <xsl:apply-templates/>
  49.    </xsl:otherwise>
  50.    </xsl:choose>
  51. </xsl:template>
  52.  
  53. <xsl:template name="renderingInner">
  54.  <xsl:param name="rend"/>
  55.  <xsl:param name="rest"/>
  56.  <xsl:choose>
  57.   <xsl:when test="$rend='bold'">
  58.    <b>
  59.      <xsl:call-template name="applyRend">
  60.       <xsl:with-param name="parms" select="$rest"/>
  61.      </xsl:call-template>
  62.    </b>
  63.   </xsl:when>
  64.   <xsl:when test="$rend='center'">
  65.    <center>
  66.      <xsl:call-template name="applyRend">
  67.       <xsl:with-param name="parms" select="$rest"/>
  68.      </xsl:call-template>
  69.    </center>
  70.   </xsl:when>
  71.   <xsl:when test="$rend='code'">
  72.    <b><tt>
  73.      <xsl:call-template name="applyRend">
  74.       <xsl:with-param name="parms" select="$rest"/>
  75.      </xsl:call-template>
  76.    </tt></b>
  77.   </xsl:when>
  78.   <xsl:when test="$rend='ital'">
  79.    <i>
  80.      <xsl:call-template name="applyRend">
  81.       <xsl:with-param name="parms" select="$rest"/>
  82.      </xsl:call-template>
  83.    </i>
  84.   </xsl:when>
  85.   <xsl:when test="$rend='italic'">
  86.    <i>
  87.      <xsl:call-template name="applyRend">
  88.       <xsl:with-param name="parms" select="$rest"/>
  89.      </xsl:call-template>
  90.    </i>
  91.   </xsl:when>
  92.   <xsl:when test="$rend='it'">
  93.    <i>
  94.      <xsl:call-template name="applyRend">
  95.       <xsl:with-param name="parms" select="$rest"/>
  96.      </xsl:call-template>
  97.    </i>
  98.   </xsl:when>
  99.   <xsl:when test="$rend='i'">
  100.    <i>
  101.      <xsl:call-template name="applyRend">
  102.       <xsl:with-param name="parms" select="$rest"/>
  103.      </xsl:call-template>
  104.    </i>
  105.   </xsl:when>
  106.   <xsl:when test="$rend='sc'">
  107. <!--   <small>
  108. <xsl:value-of
  109. select="translate(.,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
  110.    </small>
  111. -->
  112.    <span style="font-variant: small-caps">
  113.      <xsl:call-template name="applyRend">
  114.       <xsl:with-param name="parms" select="$rest"/>
  115.      </xsl:call-template>
  116.    </span>
  117.   </xsl:when>
  118.   <xsl:when test="$rend='plain'">
  119.      <xsl:call-template name="applyRend">
  120.       <xsl:with-param name="parms" select="$rest"/>
  121.      </xsl:call-template>
  122.   </xsl:when>
  123.   <xsl:when test="$rend='quoted'">
  124.    <xsl:text>‘</xsl:text>
  125.      <xsl:call-template name="applyRend">
  126.       <xsl:with-param name="parms" select="$rest"/>
  127.      </xsl:call-template>
  128.    <xsl:text>’</xsl:text>
  129.   </xsl:when>
  130.   <xsl:when test="$rend='sub'">
  131.    <sub>
  132.      <xsl:call-template name="applyRend">
  133.       <xsl:with-param name="parms" select="$rest"/>
  134.      </xsl:call-template>
  135.    </sub>
  136.   </xsl:when>
  137.   <xsl:when test="$rend='sup'">
  138.    <sup>
  139.      <xsl:call-template name="applyRend">
  140.       <xsl:with-param name="parms" select="$rest"/>
  141.      </xsl:call-template>
  142.    </sup>
  143.   </xsl:when>
  144.   <xsl:when test="$rend='important'">
  145.    <span class="important">
  146.      <xsl:call-template name="applyRend">
  147.       <xsl:with-param name="parms" select="$rest"/>
  148.      </xsl:call-template>
  149.    </span>
  150.   </xsl:when>
  151. <!-- NN added -->
  152.   <xsl:when test="$rend='ul'">
  153.    <u>
  154.      <xsl:call-template name="applyRend">
  155.       <xsl:with-param name="parms" select="$rest"/>
  156.      </xsl:call-template>
  157.    </u>
  158.   </xsl:when>
  159. <!-- NN added -->
  160.   <xsl:when test="$rend='interlinMarks'">
  161.    <xsl:text>`</xsl:text>
  162.      <xsl:call-template name="applyRend">
  163.       <xsl:with-param name="parms" select="$rest"/>
  164.      </xsl:call-template>
  165.    <xsl:text>´</xsl:text>
  166.   </xsl:when>
  167.   <xsl:when test="$rend='overbar'">
  168.    <span style="text-decoration:overline">
  169.      <xsl:call-template name="applyRend">
  170.       <xsl:with-param name="parms" select="$rest"/>
  171.      </xsl:call-template>
  172.    </span>
  173.   </xsl:when>
  174.   <xsl:when test="$rend='expanded'">
  175.    <span style="letter-spacing: 0.15em">
  176.      <xsl:call-template name="applyRend">
  177.       <xsl:with-param name="parms" select="$rest"/>
  178.      </xsl:call-template>
  179.    </span>
  180.   </xsl:when>
  181.   <xsl:when test="$rend='strike'">
  182.    <span style="text-decoration: line-through">
  183.      <xsl:call-template name="applyRend">
  184.       <xsl:with-param name="parms" select="$rest"/>
  185.      </xsl:call-template>
  186.    </span>
  187.   </xsl:when>
  188.   <xsl:when test="$rend='small'">
  189.    <span style="font-size: 75%">
  190.      <xsl:call-template name="applyRend">
  191.       <xsl:with-param name="parms" select="$rest"/>
  192.      </xsl:call-template>
  193.    </span>
  194.   </xsl:when>
  195.   <xsl:when test="$rend='large'">
  196.    <span style="font-size: 150%">
  197.      <xsl:call-template name="applyRend">
  198.       <xsl:with-param name="parms" select="$rest"/>
  199.      </xsl:call-template>
  200.    </span>
  201.   </xsl:when>
  202.   <xsl:when test="$rend='smaller'">
  203.    <span style="font-size: 50%">
  204.      <xsl:call-template name="applyRend">
  205.       <xsl:with-param name="parms" select="$rest"/>
  206.      </xsl:call-template>
  207.    </span>
  208.   </xsl:when>
  209.   <xsl:when test="$rend='larger'">
  210.    <span style="font-size: 200%">
  211.      <xsl:call-template name="applyRend">
  212.       <xsl:with-param name="parms" select="$rest"/>
  213.      </xsl:call-template>
  214.    </span>
  215.   </xsl:when>
  216.   <xsl:when test="$rend='calligraphic'">
  217.    <span style="font-family: cursive">
  218.      <xsl:call-template name="applyRend">
  219.       <xsl:with-param name="parms" select="$rest"/>
  220.      </xsl:call-template>
  221.    </span>
  222.   </xsl:when>
  223.   <xsl:when test="$rend='gothic'">
  224.    <span style="font-family: fantasy">
  225.      <xsl:call-template name="applyRend">
  226.       <xsl:with-param name="parms" select="$rest"/>
  227.      </xsl:call-template>
  228.    </span>
  229.   </xsl:when>
  230.   <xsl:when test="$rend='noindex'">
  231.      <xsl:call-template name="applyRend">
  232.       <xsl:with-param name="parms" select="$rest"/>
  233.      </xsl:call-template>
  234.    </xsl:when>
  235.   <xsl:otherwise>
  236.   <xsl:choose>
  237.    <xsl:when test="name(.)='p'">
  238.     <xsl:call-template name="unknownRendBlock">
  239.       <xsl:with-param name="rest" select="$rest"/>
  240.       <xsl:with-param name="rend" select="$rend"/>
  241.     </xsl:call-template>
  242.    </xsl:when>
  243.    <xsl:otherwise>
  244.     <xsl:call-template name="unknownRendInline">
  245.       <xsl:with-param name="rest" select="$rest"/>
  246.       <xsl:with-param name="rend" select="$rend"/>
  247.     </xsl:call-template>
  248.    </xsl:otherwise>
  249.    </xsl:choose>
  250.   </xsl:otherwise>
  251.  </xsl:choose>
  252. </xsl:template>
  253.  
  254.  
  255. <!-- special purpose -->
  256. <xsl:template match="gi">
  257.     <tt><xsl:text><</xsl:text>
  258.         <xsl:apply-templates/>
  259.       <xsl:text>></xsl:text></tt>
  260. </xsl:template>
  261.  
  262. <xsl:template match="code">
  263.     <tt><xsl:apply-templates/></tt>
  264. </xsl:template>
  265.  
  266. <xsl:template match="ident">
  267.    <strong><xsl:apply-templates/></strong>
  268. </xsl:template>
  269.  
  270. <xsl:template  match="label">
  271.       <xsl:apply-templates/>
  272. </xsl:template>
  273.  
  274. <xsl:template match="kw">
  275.     <em><xsl:apply-templates/></em>
  276. </xsl:template>
  277.  
  278. <xsl:template match="eg">
  279.     <pre>
  280. <xsl:if test="$cssFile"><xsl:attribute name="class">eg</xsl:attribute></xsl:if>
  281.       <xsl:apply-templates/>
  282.     </pre>
  283. </xsl:template>
  284.  
  285. <xsl:template name="getQuote">
  286.   <xsl:param name="quote"/>
  287.   <xsl:choose>
  288.     <xsl:when test="$quote='ldquo'">“</xsl:when>
  289.     <xsl:when test="$quote='lsquo'">‘</xsl:when>
  290.     <xsl:when test="$quote='rdquo'">”</xsl:when>
  291.     <xsl:when test="$quote='rsquo'">’</xsl:when>
  292.     <xsl:when test="$quote='ldquor'">„</xsl:when>
  293.     <xsl:when test="$quote='lsquor'">‚</xsl:when>
  294.     <xsl:when test="$quote='laquo'">«</xsl:when>
  295.     <!--<xsl:when test="$quote='lsaquo'"></xsl:when>-->
  296.     <xsl:when test="$quote='raquo'">»</xsl:when>
  297.     <!--<xsl:when test="$quote='rsaquo'"></xsl:when>-->
  298.     <xsl:when test="$quote='mdash'">—</xsl:when>
  299.     <xsl:otherwise>?</xsl:otherwise>
  300.   </xsl:choose>
  301. </xsl:template>
  302.  
  303. <xsl:template match="q">
  304.   <xsl:variable name="pre">
  305.     <xsl:choose>
  306.       <xsl:when test="contains(@rend,'PRE')">
  307.         <xsl:choose>
  308.           <xsl:when test="contains(@rend,'POST')">
  309.             <xsl:call-template name="getQuote">
  310.               <xsl:with-param name="quote" select="normalize-space(substring-before(substring-after(@rend,'PRE'),'POST'))" />
  311.             </xsl:call-template>
  312.           </xsl:when>
  313.           <xsl:otherwise>
  314.             <xsl:call-template name="getQuote">
  315.               <xsl:with-param name="quote" select="normalize-space(substring-after(@rend,'PRE'))" />
  316.             </xsl:call-template>
  317.           </xsl:otherwise>
  318.         </xsl:choose>
  319.       </xsl:when>
  320.       <xsl:otherwise>
  321.         <xsl:value-of select="$preQuote"/>
  322.       </xsl:otherwise>
  323.     </xsl:choose>
  324.   </xsl:variable>
  325.   <xsl:variable name="post">
  326.     <xsl:choose>
  327.       <xsl:when test="contains(@rend,'POST')">
  328.         <xsl:call-template name="getQuote">
  329.           <xsl:with-param name="quote" select="normalize-space(substring-after(@rend,'POST'))"/>
  330.         </xsl:call-template>
  331.       </xsl:when>
  332.       <xsl:otherwise>
  333.         <xsl:value-of select="$postQuote"/>
  334.       </xsl:otherwise>
  335.     </xsl:choose>
  336.   </xsl:variable>
  337.   <xsl:value-of select="$pre"/>
  338.   <xsl:apply-templates/>
  339.   <xsl:value-of select="$post"/>
  340. </xsl:template>
  341.  
  342. <xsl:template match="q[@rend='eg']">
  343.   <pre>
  344. <xsl:if test="$cssFile"><xsl:attribute name="class">eg</xsl:attribute></xsl:if>
  345.   <xsl:apply-templates/>
  346.  </pre>
  347. </xsl:template>
  348.  
  349. <xsl:template match="q[@rend='display']">
  350.  <blockquote>
  351.   <xsl:apply-templates/>
  352.  </blockquote>
  353. </xsl:template>
  354.  
  355. <xsl:template match="emph">
  356.  <xsl:choose>
  357.   <xsl:when test="@rend">
  358.    <xsl:call-template name="rendering"/>
  359.   </xsl:when>
  360.   <xsl:otherwise>
  361.    <em><xsl:apply-templates/></em>
  362.   </xsl:otherwise>
  363.  </xsl:choose>
  364. </xsl:template>
  365.  
  366. <xsl:template match="hi">
  367.  <xsl:choose>
  368.   <xsl:when test="@rend">
  369.    <xsl:call-template name="rendering"/>
  370.   </xsl:when>
  371.   <xsl:otherwise>
  372.    <strong><xsl:apply-templates/></strong>
  373.   </xsl:otherwise>
  374.  </xsl:choose>
  375. </xsl:template>
  376.  
  377. <xsl:template match="epigraph">
  378.  <div class="epigraph">
  379.       <xsl:apply-templates/>
  380.  </div>
  381. </xsl:template>
  382.  
  383.  
  384. <xsl:template match="l">
  385.       <xsl:apply-templates/><br/>
  386. </xsl:template>
  387.  
  388. <xsl:template match="lb">
  389.  <br/>
  390. </xsl:template>
  391.  
  392. <xsl:template match="p[@rend='box']">
  393.  <p class="box"><xsl:apply-templates/></p>
  394. </xsl:template>
  395.  
  396. <!-- quoting -->
  397. <xsl:template match="cit">
  398.   <xsl:apply-templates select="quote"/>
  399. </xsl:template>
  400.  
  401. <xsl:template match="quote[@rend='display']">
  402.  <blockquote>
  403.   <xsl:apply-templates/>
  404.   <xsl:if test="following-sibling::bibl">
  405.    <div align="right"><font size="-1">(<xsl:apply-templates select="following-sibling::bibl"/>)</font></div>
  406.   </xsl:if>
  407.  </blockquote>
  408. </xsl:template>
  409.  
  410. <xsl:template match="quote[@rend='quoted']">
  411.  <xsl:text>`</xsl:text><xsl:apply-templates/><xsl:text>' </xsl:text>
  412.  <xsl:if test="following-sibling::bibl">
  413.   <font size="-1">(<xsl:apply-templates select="following-sibling::bibl"/>)</font>
  414.  </xsl:if>
  415. </xsl:template>
  416.  
  417. <!-- copyOf handling -->
  418. <xsl:template match="l[@copyOf]|lg[@copyOf]">
  419.  <xsl:apply-templates select="id(@copyOf)" mode="Copying"/>
  420. </xsl:template>
  421.  
  422. <xsl:template match="lg" mode="Copying">
  423.  <xsl:apply-templates select="l"/>
  424. </xsl:template>
  425.  
  426. <xsl:template match="l" mode="Copying">
  427.  <xsl:apply-templates/>
  428. </xsl:template>
  429.  
  430.  
  431. <!-- change log -->
  432. <xsl:template name="changes">
  433.  <center>
  434.   <table width="95%" border="1" cols="2" cellspacing="0">
  435.    <tr>
  436.     <td width="15%"><xsl:text>Date</xsl:text></td>
  437.     <td width="85%"><xsl:text>Action</xsl:text></td>
  438.    </tr>
  439.    <xsl:apply-templates select="ancestor::TEI.2/teiHeader/revisionDesc/change"/>
  440.   </table>
  441.  </center>
  442. </xsl:template>
  443.  
  444. <xsl:template match="change">
  445.  <tr>
  446.   <td width="15%" valign="top">
  447.    <xsl:value-of select="./date"/>
  448.   </td>
  449.   <td width="85%"><xsl:value-of select="./item"/>
  450.   </td>
  451.  </tr>
  452. </xsl:template>
  453.  
  454.  
  455. <xsl:template match="name" mode="plain">
  456.  <xsl:variable name="ident">
  457.   <xsl:apply-templates select="." mode="ident"/>
  458.  </xsl:variable>
  459.  <a name="{$ident}"></a><xsl:apply-templates/>
  460. </xsl:template>
  461.  
  462. <xsl:template match="gap">
  463.     [...]<xsl:apply-templates/>
  464. </xsl:template>
  465.  
  466. <xsl:template match="mentioned">
  467.     <xsl:choose>
  468.         <xsl:when test="@rend">
  469.             <xsl:call-template name="rendering"/>
  470.         </xsl:when>
  471.         <xsl:otherwise>
  472.             <xsl:apply-templates/>
  473.         </xsl:otherwise>
  474.     </xsl:choose>
  475. </xsl:template>
  476.  
  477. <xsl:template match="term|title">
  478.     <xsl:choose>
  479.         <xsl:when test="@rend">
  480.             <xsl:call-template name="rendering"/>
  481.         </xsl:when>
  482.         <xsl:otherwise>
  483.             <em><xsl:apply-templates/></em>
  484.         </xsl:otherwise>
  485.     </xsl:choose>
  486. </xsl:template>
  487.  
  488.  
  489. <xsl:template match="soCalled">
  490.     <xsl:choose>
  491.         <xsl:when test="@rend">
  492.             <xsl:call-template name="rendering"/>
  493.         </xsl:when>
  494.         <xsl:otherwise>
  495.         <xsl:text>`</xsl:text><xsl:apply-templates/><xsl:text>'</xsl:text>
  496.         </xsl:otherwise>
  497.     </xsl:choose>
  498. </xsl:template>
  499.  
  500. <xsl:template match="foreign">
  501.  <xsl:choose>
  502.   <xsl:when test="@rend">
  503.    <xsl:call-template name="rendering"/>
  504.   </xsl:when>
  505.   <xsl:otherwise>
  506.      <xsl:apply-templates/>
  507.   </xsl:otherwise>
  508.  </xsl:choose>
  509. </xsl:template>
  510.  
  511. <xsl:template match="address">
  512.  <blockquote>
  513.      <xsl:apply-templates/>
  514.  </blockquote>
  515. </xsl:template>
  516.  
  517. <xsl:template match="addrLine">
  518.      <xsl:apply-templates/><br/>
  519. </xsl:template>
  520.  
  521. <xsl:template match="seg">
  522.      <span class="{@type}"><xsl:apply-templates/></span>
  523. </xsl:template>
  524.  
  525. <xsl:template match="space">
  526.   <xsl:choose>
  527.    <xsl:when test="@extent">
  528.     <xsl:call-template name="space_loop">
  529.    <xsl:with-param name="extent" select="@extent"/>
  530.     </xsl:call-template>
  531. <xsl:apply-templates/>
  532.    </xsl:when>
  533.    <xsl:otherwise>
  534.         <xsl:text> </xsl:text>
  535.    </xsl:otherwise>
  536.   </xsl:choose>
  537. </xsl:template>
  538.  
  539. <xsl:template name="space_loop">
  540.    <xsl:param name="extent"/>
  541.    <xsl:choose>
  542.     <xsl:when test="$extent < 1">
  543.     </xsl:when>
  544.     <xsl:otherwise>
  545.         <xsl:text> </xsl:text>
  546.     <xsl:variable name="newextent">
  547.       <xsl:value-of select="$extent - 1"/>
  548.     </xsl:variable>
  549.     <xsl:call-template name="space_loop">
  550.    <xsl:with-param name="extent" select="$newextent"/>
  551.     </xsl:call-template>
  552.     </xsl:otherwise>
  553.    </xsl:choose>
  554. </xsl:template>
  555.  
  556. <xsl:template name="unknownRendBlock">
  557.  <xsl:param name="rend"/>
  558.  <xsl:param name="rest"/>
  559.    <xsl:message>Unknown rend attribute <xsl:value-of
  560. select="$rend"/></xsl:message>
  561.    <code class="undone">[Unknown rendering: <xsl:value-of
  562. select="$rend"/>]</code>
  563.      <xsl:call-template name="applyRend">
  564.       <xsl:with-param name="parms" select="$rest"/>
  565.      </xsl:call-template>
  566.    <code class="undone">[End rendering]</code>
  567.  </xsl:template>
  568. <xsl:template name="unknownRendInline">
  569.  <xsl:param name="rend"/>
  570.  <xsl:param name="rest"/>
  571.    <xsl:message>Unknown rend attribute <xsl:value-of
  572. select="$rend"/></xsl:message>
  573.    <code class="undone">[Unknown rendering: <xsl:value-of
  574. select="$rend"/>]</code>
  575.      <xsl:call-template name="applyRend">
  576.       <xsl:with-param name="parms" select="$rest"/>
  577.      </xsl:call-template>
  578.    <code class="undone">[End rendering]</code>
  579.  </xsl:template>
  580.  
  581. </xsl:stylesheet>
  582.