home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 October / INTERNET108.ISO / pc / software / windows / building / xmlspy / xmlspyentcomplete5.exe / Data1.cab / _03DB63B8A67F4E2280544289A021A802 < prev    next >
Encoding:
Text File  |  2002-09-24  |  27.0 KB  |  1,055 lines

  1. <!-- XSLT for converting from gcapaper format to HTML + CSS
  2.      Written by Philip Mansfield
  3.      10 November 2001 - Created to handle gcapaper 6.0 (for XML 2001 Conference)
  4.      25 February 2002 - Modified to also handle gcapaper 6.1 (for XML Europe 2002)
  5.      (c) 2001-2 Schema Software Inc.
  6.      You may use, reproduce, modify or redistribute this software under
  7.      the condition that you do not sell it and you include this copyright
  8.      notice in all copies.  For more information, visit
  9.      http://www.schemasoft.com or write to info@schemasoft.com -->
  10. <!-- Slightly modified by Lauren Wood, SoftQuad.
  11.      As per instructions, keywords should not be rendered.
  12.      Included Schemasoft's CSS styling for the HTML in the XSLT -->
  13.  
  14. <xsl:stylesheet version="1.0"
  15.     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  16.  
  17. <xsl:output method="html" doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
  18. doctype-system="http://www.w3.org/TR/html4/loose.dtd" indent="yes"/>
  19.  
  20. <xsl:template match="gcapaper">
  21.    <html>
  22.       <xsl:apply-templates/>
  23.       <xsl:text disable-output-escaping="yes"></body></xsl:text>
  24.    </html>
  25. </xsl:template>
  26.  
  27. <!-- Front matter -->
  28. <xsl:template match="front">
  29.     <head>
  30.         <xsl:apply-templates select="title|keyword[1]|author" mode="head"/>
  31.         <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
  32.         <meta http-equiv="Content-Style-Type" content="text/css"/>
  33.         <style type="text/css">
  34. /* Stylesheet for gca2html output */
  35. /* Produced by Schemasoft (www.schemasoft.com) to go with their XSLT */
  36. body {
  37.   background-color: white;
  38.   color: black;
  39.   font-family: Times, serif;
  40.   margin-left: 2em;
  41.   margin-top: 2em
  42. }
  43. h1, h2, h3, h4, h5, caption { 
  44.   font-family: Arial, Helvetica, sans-serif;
  45.   color: green
  46. }
  47. h1 {
  48.   text-align: center;
  49.   font-size: 1.6em;
  50.   font-weight: bold;
  51.   margin-top: 2em;
  52.   margin-bottom: 2em
  53. }
  54. h2 {
  55.   font-size: 1.3em; 
  56.   margin-top: 4em;
  57.   padding: 2px;
  58.   color: white;
  59.   background-color: green
  60. }
  61. h2.subt {
  62.   text-align: center;
  63.   margin-top: -1.8em;
  64.   margin-bottom: 2em;
  65.   padding: 0px;
  66.   color: green;
  67.   background-color: white;
  68.   font-family: Times, serif
  69. }
  70. h2.abstractHeader, h2.tocHeader {
  71.   text-align: center;
  72.   color: green;
  73.   background-color: white;
  74.   margin-top: 0em;
  75.   margin-bottom: 0em
  76. }
  77. h3 {
  78.   font-size: 1.2em;
  79.   margin-top: 2em
  80. }
  81. h4 {
  82.   font-size: 1.1em;
  83.   margin-top: 2em
  84. }
  85. h5 {
  86.   font-size: 1em; 
  87.   margin-top: 1em; 
  88.   margin-bottom: 0em; 
  89.   background-color: #EEEEEE 
  90. }
  91. dl { margin-top: 2em }
  92. dt {
  93.   margin-top: 0.4em;
  94.   font-family: Arial, Helvetica, sans-serif;
  95.   font-weight: bold;
  96.   font-size: 0.95em
  97. }
  98. dt.bib {
  99.   color: red;
  100.   font-size: 1em
  101. }
  102. dd { margin-top: 0.2em }
  103. dt.termHeading, dd.defHeading { color: red }
  104. code { font-family: monospace }
  105. pre {
  106.   margin-top: 0.5em;
  107.   margin-bottom: 0.5em;
  108.   font-family: monospace
  109. ul li, p { line-height: 1.3em }
  110. .authorName {
  111.   font-family: Arial, Helvetica, sans-serif;
  112.   font-weight: bold
  113. }
  114. p.keyword {
  115.   color: #000099;
  116.   background-color: #DDDDDD
  117. }
  118. p.sectKeyword { color: #000099 }
  119. p.author { margin-top: 1.5em}
  120. p.toc { 
  121.   margin-left: 2em;
  122.   line-height: 1.5em
  123. }
  124. p.abstract {
  125.   margin-left: 2em;
  126.   margin-right: 2em
  127. }
  128. p.figcaptionPara {
  129.   font-size: 0.8em;
  130.   text-align: justify
  131. }
  132. ul.simple { list-style-type: none }
  133. ul.bulleted { list-style-type: disc }
  134. ul.dashed { list-style-type: square }
  135. ol.arabic { list-style-type: decimal }
  136. ol.ualpha { list-style-type: upper-alpha }
  137. ol.uroman { list-style-type: upper-roman }
  138. ol.lalpha { list-style-type: lower-alpha }
  139. ol.lroman { list-style-type: lower-roman }
  140. ol.ftnote {
  141.   list-style-type: decimal;
  142.   font-family: Arial, Helvetica, sans-serif;
  143.   font-size: 0.8em
  144. }
  145. blockquote {
  146.   margin-left: 2em;
  147.   margin-right: 2em;
  148.   background-color: white;
  149.   color: black;
  150.   font-family: Times, serif;
  151.   font-style: normal;
  152.   font-weight: normal;
  153.   font-variant: normal;
  154.   font-size: 1em
  155. }
  156. blockquote.lquote {
  157.   font-family: Arial, Helvetica, sans-serif;
  158.   font-size: 0.8em
  159. }
  160. blockquote.figcaption, blockquote.figurePara, blockquote.figureCodeBlock, blockquote.figureTitle {
  161.   margin-left: 4em;
  162.   margin-right: 4em
  163. }
  164. blockquote.tableHeader {
  165.   margin-top: 1em;
  166.   margin-left: 4em;
  167.   margin-right: 4em;
  168.   margin-bottom: 2em
  169. }
  170. .figure {
  171.   margin-top: 2em;
  172.   margin-bottom: 2em
  173. }
  174. table.note {
  175.   width: 98%;
  176.   border: 1px solid #000099;
  177.   color: #000099
  178. }
  179. table.note td { padding: 0.75em }
  180. .noteHeader {
  181.   font-family: Arial, Helvetica, sans-serif;
  182.   font-weight: bold
  183. }
  184. table.codeBlock {
  185.   width: 98%;
  186.   color: green; 
  187.   background-color: #EEEEEE
  188. }
  189. table.table {
  190.   color: #000099;
  191.   margin-top: 2em;
  192.   empty-cells: show
  193. }
  194. table.table caption {
  195.   caption-side: top;
  196.   margin-left: 4em;
  197.   margin-right: 4em;
  198.   text-align: justify;
  199.   font-size: 0.95em
  200. }
  201. table.table th {
  202.   font-size: 1em;
  203.   font-weight: bold;
  204.   background-color: #000099;
  205.   color: white;
  206.   padding: 0.5em
  207. }
  208. table.table td { padding: 0.5em }
  209. hr { color: #000099 } 
  210. hr.upperBorder {
  211.   margin-top: 2em;
  212.   margin-bottom: 0em
  213. }
  214. hr.lowerBorder {
  215.   margin-top: 0em;
  216.   margin-bottom: 0em
  217. }
  218. cite { color: green }
  219. :link {
  220.   background: none transparent scroll repeat 0% 0%;
  221.   color: #000099
  222. }
  223. :visited {
  224.   background: none transparent scroll repeat 0% 0%;
  225.   color: purple
  226. }
  227. :active {
  228.   background: none transparent scroll repeat 0% 0%;
  229.   color: red
  230. }
  231. @media Screen {
  232. a:hover { background-color: #FFFFCC }
  233. }
  234. a.bibref {
  235.   font-family: Arial, Helvetica, sans-serif  
  236. }
  237. acronym a:link {
  238.   color: black;
  239.   text-decoration: none
  240. }
  241. acronym a:visited {
  242.   color: black;
  243.   text-decoration: none
  244. }
  245. acronym a:active {
  246.   color: black;
  247.   text-decoration: none
  248. }
  249. acronym a:hover {
  250.   color: black;
  251.   background-color: #FFFFCC;
  252.   text-decoration: none
  253. }
  254.             </style>
  255.     </head>
  256.     <xsl:text disable-output-escaping="yes"><body></xsl:text>
  257.     <xsl:apply-templates select="keyword[1]|*[not(self::keyword)]"/>
  258. </xsl:template>
  259.  
  260. <xsl:template match="title" mode="head">
  261.     <title><xsl:value-of select=".//text()"/></title>
  262. </xsl:template>
  263.  
  264. <xsl:template match="keyword[1]" mode="head">
  265.     <meta name="keywords">
  266.         <xsl:attribute name="content">
  267.             <xsl:apply-templates/>
  268.             <xsl:apply-templates select="following-sibling::keyword"/>
  269.         </xsl:attribute>
  270.     </meta>
  271. </xsl:template>
  272.  
  273. <xsl:template match="front/keyword[1]">
  274.     <p class="keyword">
  275.         <i class="keywordHeader"><xsl:text>Keywords: </xsl:text></i>
  276.         <xsl:apply-templates/>
  277.         <xsl:apply-templates select="following-sibling::keyword"/>
  278.     </p>
  279. </xsl:template>
  280.  
  281. <xsl:template match="front/keyword[position()>1]">
  282.     <xsl:text>, </xsl:text>
  283.     <xsl:apply-templates/>
  284. </xsl:template>
  285.  
  286. <xsl:template match="author" mode="head">
  287.     <meta name="author">
  288.         <xsl:attribute name="content">
  289.             <xsl:apply-templates select="fname|surname|suffix"/>
  290.         </xsl:attribute>
  291.     </meta>
  292. </xsl:template>
  293.  
  294. <xsl:template match="surname">
  295.     <xsl:text> </xsl:text>
  296.     <xsl:apply-templates/>
  297. </xsl:template>
  298.  
  299. <xsl:template match="suffix">
  300.     <xsl:text>, </xsl:text>
  301.     <xsl:apply-templates/>
  302. </xsl:template>
  303.  
  304. <xsl:template match="title">
  305.     <h1 class="title"><xsl:apply-templates/></h1>
  306. </xsl:template>
  307.  
  308. <xsl:template match="subt">
  309.     <h2 class="subt"><xsl:apply-templates/></h2>
  310. </xsl:template>
  311.  
  312. <xsl:template match="author">
  313.     <p class="author">
  314.         <span class="authorName"><xsl:apply-templates select="fname|surname|suffix"/></span>
  315.         <xsl:apply-templates select="jobtitle|address"/>
  316.     </p>
  317.     <xsl:apply-templates select="bio"/>
  318. </xsl:template>
  319.  
  320. <xsl:template match="jobtitle">
  321.     <br/><xsl:apply-templates/>
  322. </xsl:template>
  323.  
  324. <xsl:template match="address/*">
  325.     <br/><xsl:apply-templates/>
  326. </xsl:template>
  327.  
  328. <xsl:template match="address/email">
  329.     <br/>
  330.     <a class="email" href="mailto:{text()}">
  331.         <xsl:apply-templates/>
  332.     </a>
  333. </xsl:template>
  334.  
  335. <xsl:template match="address/web">
  336.     <br/>
  337.     <a class="web" href="{text()}">
  338.         <xsl:apply-templates/>
  339.     </a>
  340. </xsl:template>
  341.  
  342. <xsl:template match="bio">
  343.     <p class="bioHeader"><i>Biography</i></p>
  344.     <blockquote class="bio">
  345.         <xsl:apply-templates/>
  346.     </blockquote>
  347. </xsl:template>
  348.  
  349. <xsl:template match="abstract">
  350.     <hr class="upperBorder"/>
  351.     <h2 class="abstractHeader">Abstract</h2>
  352.     <hr class="lowerBorder"/>
  353.     <xsl:apply-templates/>
  354. </xsl:template>
  355.  
  356. <!-- Body -->
  357. <xsl:template match="body">
  358.     <hr class="upperBorder"/>
  359.     <h2 class="tocHeader">Table of Contents</h2>
  360.     <hr class="lowerBorder"/>
  361.     <p class="toc">
  362.         <xsl:apply-templates select=".//title" mode="toc"/>
  363.         <xsl:apply-templates select="/descendant::ftnote[position()=1]" mode="toc"/>
  364.         <xsl:apply-templates select="..//acknowl|..//bibliog" mode="toc"/>
  365.     </p>
  366.     <xsl:apply-templates/>
  367.     <xsl:apply-templates select="/descendant::ftnote[position()=1]" mode="footerStart"/>
  368. </xsl:template>
  369.  
  370. <!-- Rear matter -->
  371. <xsl:template match="acknowl">
  372.     <h2 class="acknowlHeader">
  373.         <a name="S.Acknowledgements">Acknowledgements</a>
  374.     </h2>
  375.     <xsl:apply-templates/>
  376. </xsl:template>
  377.  
  378. <xsl:template match="acknowl/title">
  379.    <h3 class="acknowlTitle">
  380.       <xsl:apply-templates/>
  381.    </h3>
  382. </xsl:template>
  383.  
  384. <xsl:template match="bibliog">
  385.     <h2 class="bibliogHeader">
  386.         <a name="S.Bibliography">Bibliography</a>
  387.     </h2>
  388.     <dl class="bibliog">
  389.         <xsl:apply-templates/>
  390.     </dl>
  391. </xsl:template>
  392.  
  393. <xsl:template match="bib">
  394.     <dt class="bib">
  395.         <xsl:apply-templates select="../@id"/>
  396.         <b>[<xsl:apply-templates/>]</b>
  397.     </dt>
  398. </xsl:template>
  399.  
  400. <xsl:template match="@id">
  401.     <a name="{.}"/>
  402. </xsl:template>
  403.  
  404. <xsl:template match="pub">
  405.     <dd class="pub">
  406.         <xsl:apply-templates/>
  407.     </dd>
  408. </xsl:template>
  409.  
  410. <xsl:template match="bibref">
  411.     <a href="#{@refloc}" class="bibref">
  412.         <b>[<xsl:value-of select="id(@refloc)/bib/text()"/>]</b>
  413.     </a>
  414.     <xsl:text> </xsl:text>
  415. </xsl:template>
  416.  
  417. <!-- Elements that get copied -->
  418. <xsl:template match="b|big|code|i|small|sub|sup|tt">
  419.    <xsl:copy>
  420.       <xsl:apply-templates/>
  421.    </xsl:copy>
  422. </xsl:template>
  423.  
  424. <!-- Paragraphs -->
  425. <xsl:template match="para">
  426.    <p>
  427.       <xsl:apply-templates/>
  428.    </p>
  429. </xsl:template>
  430.  
  431. <xsl:template match="abstract/para">
  432.    <p class="abstract">
  433.       <xsl:apply-templates/>
  434.    </p>
  435. </xsl:template>
  436.  
  437. <xsl:template match="acknowl/para">
  438.    <p class="acknowl">
  439.       <xsl:apply-templates/>
  440.    </p>
  441. </xsl:template>
  442.  
  443. <xsl:template match="li/para">
  444.    <li>
  445.       <xsl:apply-templates/>
  446.    </li>
  447. </xsl:template>
  448.  
  449. <!-- Citations -->
  450. <xsl:template match="cit">
  451.     <cite>
  452.         <xsl:apply-templates/>
  453.     </cite>
  454. </xsl:template>
  455.  
  456. <!-- Quotes -->
  457. <xsl:template match="lquote">
  458.     <blockquote class="lquote">
  459.         <xsl:apply-templates/>
  460.     </blockquote>
  461. </xsl:template>
  462.  
  463. <!-- Acronyms -->
  464. <xsl:template match="acronym">
  465.     <acronym>
  466.         <a>
  467.             <xsl:apply-templates select="@refid"/>
  468.             <xsl:apply-templates/>
  469.         </a>
  470.     </acronym>
  471. </xsl:template>
  472.  
  473. <xsl:template match="acronym/@refid">
  474.     <xsl:attribute name="href">
  475.         <xsl:text>#</xsl:text>
  476.         <xsl:value-of select="."/>
  477.     </xsl:attribute>
  478. </xsl:template>
  479.  
  480. <xsl:template match="acronym.grp/expansion">
  481.     <xsl:apply-templates select="@id"/>
  482.     <xsl:text> (</xsl:text>
  483.         <xsl:apply-templates/>
  484.     <xsl:text>) </xsl:text>
  485. </xsl:template>
  486.  
  487. <!-- Lists -->
  488. <xsl:template match="randlist">
  489.    <ul>
  490.       <xsl:apply-templates select="@style"/>
  491.       <xsl:apply-templates/>
  492.    </ul>
  493. </xsl:template>
  494.  
  495. <xsl:template match="randlist/@style"/>
  496.  
  497. <xsl:template match="randlist/@style[.='simple']">
  498.     <xsl:attribute name="class">simple</xsl:attribute>
  499.     <xsl:attribute name="type">circle</xsl:attribute>
  500. </xsl:template>
  501.  
  502. <xsl:template match="randlist/@style[.='bulleted']">
  503.     <xsl:attribute name="class">bulleted</xsl:attribute>
  504.     <xsl:attribute name="type">disc</xsl:attribute>
  505. </xsl:template>
  506.  
  507. <xsl:template match="randlist/@style[.='dashed']">
  508.     <xsl:attribute name="class">dashed</xsl:attribute>
  509.     <xsl:attribute name="type">square</xsl:attribute>
  510. </xsl:template>
  511.  
  512. <xsl:template match="seqlist">
  513.    <ol>
  514.       <xsl:apply-templates select="@number"/>
  515.       <xsl:apply-templates/>
  516.    </ol>
  517. </xsl:template>
  518.  
  519. <xsl:template match="seqlist/@number"/>
  520.  
  521. <xsl:template match="seqlist/@number[.='arabic']">
  522.     <xsl:attribute name="class">arabic</xsl:attribute>
  523.     <xsl:attribute name="type">1</xsl:attribute>
  524. </xsl:template>
  525.  
  526. <xsl:template match="seqlist/@number[.='ualpha']">
  527.     <xsl:attribute name="class">ualpha</xsl:attribute>
  528.     <xsl:attribute name="type">A</xsl:attribute>
  529. </xsl:template>
  530.  
  531. <xsl:template match="seqlist/@number[.='uroman']">
  532.     <xsl:attribute name="class">uroman</xsl:attribute>
  533.     <xsl:attribute name="type">I</xsl:attribute>
  534. </xsl:template>
  535.  
  536. <xsl:template match="seqlist/@number[.='lalpha']">
  537.     <xsl:attribute name="class">lalpha</xsl:attribute>
  538.     <xsl:attribute name="type">a</xsl:attribute>
  539. </xsl:template>
  540.  
  541. <xsl:template match="seqlist/@number[.='lroman']">
  542.     <xsl:attribute name="class">lroman</xsl:attribute>
  543.     <xsl:attribute name="type">i</xsl:attribute>
  544. </xsl:template>
  545.  
  546. <xsl:template match="deflist">
  547.    <xsl:apply-templates select="title"/>
  548.    <dl>
  549.       <xsl:apply-templates select="*[not(self::title)]"/>
  550.    </dl>
  551. </xsl:template>
  552.  
  553. <xsl:template match="deflist/title">
  554.    <h5 class="deflistTitle">
  555.       <xsl:apply-templates/>
  556.    </h5>
  557. </xsl:template>
  558.  
  559. <xsl:template match="term.heading">
  560.    <dt class="termHeading"><i>
  561.       <xsl:apply-templates/>
  562.    </i></dt>
  563. </xsl:template>
  564.  
  565. <xsl:template match="def.heading">
  566.    <dd class="defHeading"><i>
  567.       <xsl:apply-templates/>
  568.    </i></dd>
  569. </xsl:template>
  570.  
  571. <xsl:template match="def.term">
  572.    <dt>
  573.       <xsl:apply-templates/>
  574.    </dt>
  575. </xsl:template>
  576.  
  577. <xsl:template match="def/para">
  578.    <dd>
  579.         <xsl:apply-templates/>
  580.    </dd>
  581. </xsl:template>
  582.  
  583. <!-- Code blocks -->
  584. <xsl:template match="code.block">
  585.     <table class="codeBlock">
  586.         <tr><td><pre>
  587.             <xsl:apply-templates/>
  588.        </pre></td></tr>
  589.     </table>
  590. </xsl:template>
  591.  
  592. <!-- Notes -->
  593. <xsl:template match="note">
  594.     <table class="note">
  595.         <tr>
  596.             <td>
  597.                 <p>
  598.                     <span class="noteHeader">
  599.                         <xsl:text>NOTE: </xsl:text>
  600.                     </span>
  601.                     <xsl:apply-templates select="para[1]/node()"/>
  602.                 </p>
  603.                 <xsl:apply-templates select="para[position()>1]"/>
  604.            </td>
  605.         </tr>
  606.     </table>
  607. </xsl:template>
  608.  
  609. <!-- Hyperlinks -->
  610. <xsl:template match="a">
  611.     <a href="{@href}">
  612.         <xsl:value-of select="@href"/>
  613.     </a>
  614. </xsl:template>
  615.  
  616. <!-- Footnotes -->
  617. <xsl:template match="fnref">
  618.     <a href="#{@refloc}" class="fnref"><b>
  619.         <xsl:apply-templates select="id(@refloc)" mode="reference"/>
  620.     </b></a>
  621. </xsl:template>
  622.  
  623. <xsl:template match="ftnote" mode="reference">
  624.     <xsl:text>[</xsl:text>
  625.     <xsl:value-of select="count(preceding::ftnote)+count(ancestor::ftnote)+1"/>
  626.     <xsl:text>]</xsl:text>
  627. </xsl:template>
  628.  
  629. <xsl:template match="ftnote"/>
  630.  
  631. <xsl:template match="ftnote" mode="footerStart">
  632.     <h2 class="ftnoteHeader">
  633.         <a name="S.Footnotes">Footnotes</a>
  634.     </h2>
  635.     <ol class="ftnote" type="1">
  636.         <xsl:apply-templates select="//ftnote" mode="footer"/>
  637.     </ol>
  638. </xsl:template>
  639.  
  640. <xsl:template match="ftnote" mode="footer">
  641.     <li>
  642.         <xsl:apply-templates select="@id"/>
  643.         <xsl:apply-templates/>
  644.     </li>
  645. </xsl:template>
  646.  
  647. <!-- Internal links -->
  648. <xsl:template match="xref">
  649.     <a href="#{@refloc}" class="xref"><b>
  650.         <xsl:apply-templates select="id(@refloc)" mode="reference"/>
  651.     </b></a>
  652.     <xsl:text> </xsl:text>
  653. </xsl:template>
  654.  
  655. <xsl:template match="figure" mode="reference">
  656.     <xsl:text>Fig. </xsl:text>
  657.     <xsl:value-of select="count(preceding::figure)+1"/>
  658. </xsl:template>
  659.  
  660. <xsl:template match="table" mode="reference">
  661.     <xsl:text>Table </xsl:text>
  662.     <xsl:value-of select="count(preceding::table)+count(ancestor::table)+1"/>
  663. </xsl:template>
  664.  
  665. <xsl:template match="section" mode="reference">
  666.     <xsl:choose>
  667.         <xsl:when test="/gcapaper/@secnumbers='1'">
  668.             <xsl:text>Chapter </xsl:text>
  669.             <xsl:value-of select="count(preceding::section)+1"/>
  670.         </xsl:when>
  671.         <xsl:otherwise>
  672.             <xsl:value-of select="title//text()"/>
  673.         </xsl:otherwise>
  674.     </xsl:choose>
  675. </xsl:template>
  676.  
  677. <xsl:template match="subsec1|subsec2|subsec3" mode="reference">
  678.     <xsl:choose>
  679.         <xsl:when test="/gcapaper/@secnumbers='1'">
  680.             <xsl:text>Section </xsl:text>
  681.             <xsl:number level="multiple" format="1.1.1.1"
  682.                 count="section|subsec1|subsec2|subsec3"/>
  683.         </xsl:when>
  684.         <xsl:otherwise>
  685.             <xsl:value-of select="title//text()"/>
  686.         </xsl:otherwise>
  687.     </xsl:choose>
  688. </xsl:template>
  689.  
  690. <!-- The table element and its descendants are copied -->
  691. <xsl:template match="table">
  692.     <xsl:apply-templates select="@id"/>
  693.     <div align="center">
  694.         <xsl:copy>
  695.             <xsl:attribute name="class">table</xsl:attribute>
  696.             <xsl:apply-templates select="*|@*|text()" mode="copy"/>
  697.         </xsl:copy>
  698.     </div>
  699.     <blockquote class="tableHeader">
  700.         <div align="center">
  701.             <b>
  702.                 <xsl:text>Table </xsl:text>
  703.                 <xsl:value-of select="count(preceding::table)+count(ancestor::table)+1"/>
  704.             </b>
  705.         </div>
  706.     </blockquote>
  707. </xsl:template>
  708.  
  709. <xsl:template match="td|th|caption" mode="copy">
  710.     <xsl:copy>
  711.         <xsl:apply-templates select="@*" mode="copy"/>
  712.         <!-- Resume normal translation upon exit of table module -->
  713.         <xsl:apply-templates/>
  714.     </xsl:copy>
  715. </xsl:template>
  716.  
  717. <xsl:template match="*|@*|text()" mode="copy">
  718.     <xsl:copy>
  719.         <xsl:apply-templates select="*|@*|text()" mode="copy"/>
  720.     </xsl:copy>
  721. </xsl:template>
  722.  
  723. <!-- Figures -->
  724. <xsl:template match="figure">
  725.     <div class="figure">
  726.         <xsl:apply-templates select="@id"/>
  727.         <xsl:apply-templates select="graphic|code.block|para"/>
  728.         <xsl:apply-templates select="title|figcaption"/>
  729.     </div>
  730. </xsl:template>
  731.  
  732. <xsl:template match="figure/title">
  733.     <blockquote class="figureTitle">
  734.         <div align="center">
  735.             <b>
  736.                 <xsl:text>Fig. </xsl:text>
  737.                 <xsl:value-of select="count(preceding::figure)+1"/>
  738.                 <xsl:text>: </xsl:text>
  739.                 <xsl:apply-templates/>
  740.             </b>
  741.         </div>
  742.     </blockquote>
  743. </xsl:template>
  744.  
  745. <xsl:template match="figcaption">
  746.     <blockquote class="figcaption">
  747.         <xsl:apply-templates/>
  748.     </blockquote>
  749. </xsl:template>
  750.  
  751. <xsl:template match="figcaption/para">
  752.     <p align="justify" class="figcaptionPara">
  753.         <xsl:apply-templates/>
  754.     </p>
  755. </xsl:template>
  756.  
  757. <xsl:template match="figure/para">
  758.     <blockquote class="figurePara">
  759.         <xsl:apply-templates/>
  760.     </blockquote>
  761. </xsl:template>
  762.  
  763. <xsl:template match="figure/code.block">
  764.     <blockquote class="figureCodeBlock">
  765.         <pre>
  766.             <xsl:apply-templates/>
  767.         </pre>
  768.     </blockquote>
  769. </xsl:template>
  770.  
  771. <xsl:template match="graphic">
  772.     <div align="center" class="graphic">
  773.         <xsl:call-template name="Image"/>
  774.     </div>
  775. </xsl:template>
  776.  
  777. <xsl:template name="Image" match="inline.graphic">
  778.     <img>
  779.         <xsl:choose>
  780.             <xsl:when test="boolean(@href)">
  781.                 <!-- If there is an href attribute, use it directly -->
  782.                 <xsl:attribute name="alt">
  783.                     <xsl:value-of select="@href"/>
  784.                 </xsl:attribute>
  785.                 <xsl:attribute name="src">
  786.                     <xsl:value-of select="@href"/>
  787.                 </xsl:attribute>
  788.             </xsl:when>
  789.             <xsl:otherwise>
  790.                 <!-- Otherwise, there is a figname attribute that takes an entity -->
  791.                 <xsl:attribute name="alt">
  792.                     <xsl:value-of select="@figname"/>
  793.                 </xsl:attribute>
  794.                 <xsl:attribute name="src">
  795.                     <!-- Compute the relative URI of the graphic file -->
  796.                     <xsl:call-template name="SubstringAfterLast">
  797.                         <xsl:with-param name="string" select="unparsed-entity-uri(@figname)"/>
  798.                         <xsl:with-param name="token" select="'/'"/>
  799.                     </xsl:call-template>
  800.                 </xsl:attribute>
  801.             </xsl:otherwise>
  802.         </xsl:choose>
  803.         <!-- If scaled, use given height and width numbers as pixels.
  804.                 When height and width are given in CSS units (e.g. "6in"), compute
  805.                 pixels assuming 96dpi. When in unrecognized units, set width="100%" -->
  806.         <xsl:if test="@scalefit='1'">
  807.             <xsl:variable name="pixelWidth">
  808.                 <xsl:call-template name="ConvertToPixels">
  809.                     <xsl:with-param name="length" select="@width"/>
  810.                 </xsl:call-template>
  811.             </xsl:variable>
  812.             <xsl:variable name="pixelHeight">
  813.                 <xsl:call-template name="ConvertToPixels">
  814.                     <xsl:with-param name="length" select="@height"/>
  815.                 </xsl:call-template>
  816.             </xsl:variable>
  817.             <xsl:choose>
  818.                 <xsl:when test="number($pixelWidth) > 0 or number($pixelHeight) > 0">
  819.                     <xsl:if test="number($pixelWidth) > 0">
  820.                         <xsl:attribute name="width">
  821.                             <xsl:value-of select="$pixelWidth"/>
  822.                         </xsl:attribute>
  823.                     </xsl:if>
  824.                     <xsl:if test="number($pixelHeight) > 0">
  825.                         <xsl:attribute name="height">
  826.                             <xsl:value-of select="$pixelHeight"/>
  827.                         </xsl:attribute>
  828.                     </xsl:if>
  829.                 </xsl:when>
  830.                 <xsl:otherwise>
  831.                     <xsl:attribute name="width">100%</xsl:attribute>
  832.                 </xsl:otherwise>
  833.             </xsl:choose>
  834.         </xsl:if>
  835.     </img>
  836. </xsl:template>
  837.  
  838. <!-- Utility function to convert lengths to pixels -->
  839. <xsl:template name="ConvertToPixels">
  840.     <xsl:param name="length"/>
  841.     <xsl:variable name="pixels" select="number(substring-before($length,'px'))"/>
  842.     <xsl:variable name="inches" select="number(substring-before($length,'in'))"/>
  843.     <xsl:variable name="cms" select="number(substring-before($length,'cm'))"/>
  844.     <xsl:variable name="mms" select="number(substring-before($length,'mm'))"/>
  845.     <xsl:variable name="pts" select="number(substring-before($length,'pt'))"/>
  846.     <xsl:variable name="picas" select="number(substring-before($length,'pc'))"/>
  847.     <xsl:choose>
  848.         <xsl:when test="boolean(number($length))">
  849.             <xsl:value-of select="$length"/>
  850.         </xsl:when>
  851.         <xsl:when test="boolean($pixels)">
  852.             <xsl:value-of select="$pixels"/>
  853.         </xsl:when>
  854.         <xsl:when test="boolean($inches)">
  855.             <xsl:value-of select="96 * $inches"/>
  856.         </xsl:when>
  857.         <xsl:when test="boolean($cms)">
  858.             <xsl:value-of select="(96 * $cms) div 2.54"/>
  859.         </xsl:when>
  860.         <xsl:when test="boolean($mms)">
  861.             <xsl:value-of select="(96 * $mms) div 25.4"/>
  862.         </xsl:when>
  863.         <xsl:when test="boolean($pts)">
  864.             <xsl:value-of select="(96 * $pts) div 72"/>
  865.         </xsl:when>
  866.         <xsl:when test="boolean($picas)">
  867.             <xsl:value-of select="(96 * $picas) div 6"/>
  868.         </xsl:when>
  869.         <xsl:otherwise>0</xsl:otherwise>
  870.     </xsl:choose>
  871. </xsl:template>
  872.  
  873. <!-- Utility function to find the substring after the last occurrence of a token -->
  874. <xsl:template name="SubstringAfterLast">
  875.     <xsl:param name="string"/>
  876.     <xsl:param name="token"/>
  877.     <xsl:choose>
  878.         <xsl:when test="contains($string,$token)">
  879.             <xsl:call-template name="SubstringAfterLast">
  880.                 <xsl:with-param name="string" select="substring-after($string,$token)"/>
  881.                 <xsl:with-param name="token" select="$token"/>
  882.             </xsl:call-template>
  883.         </xsl:when>
  884.         <xsl:otherwise>
  885.             <xsl:value-of select="$string"/>
  886.         </xsl:otherwise>
  887.     </xsl:choose>
  888. </xsl:template>
  889.  
  890. <!-- Section/subsection titles become h1, h2, h3, h4
  891.      The titles are numbered if the secnumbers attribute is 1
  892.      Two kinds of anchors are generated at each heading:
  893.      1. An anchor whose name is the section id attribute, if it exists
  894.      2. A unique numerical anchor used by Table of Contents -->
  895. <xsl:template match="section|subsec1|subsec2|subsec3">
  896.     <xsl:apply-templates select="keyword[1]|*[not(self::keyword)]"/>
  897. </xsl:template>
  898.  
  899. <xsl:template match="section/title">
  900.     <h2>
  901.         <xsl:call-template name="anchoredNumberedTitle">
  902.             <xsl:with-param name="prefix">
  903.                 <xsl:number level="single" format="1."
  904.                     count="section"/>
  905.             </xsl:with-param>
  906.         </xsl:call-template>
  907.     </h2>      
  908. </xsl:template>
  909.  
  910. <xsl:template match="subsec1/title">
  911.     <h3>
  912.         <xsl:call-template name="anchoredNumberedTitle">
  913.             <xsl:with-param name="prefix">
  914.                 <xsl:number level="multiple" format="1.1"
  915.                     count="section|subsec1"/>
  916.             </xsl:with-param>
  917.         </xsl:call-template>
  918.     </h3>      
  919. </xsl:template>
  920.  
  921. <xsl:template match="subsec2/title">
  922.     <h4>
  923.         <xsl:call-template name="anchoredNumberedTitle">
  924.             <xsl:with-param name="prefix">
  925.                 <xsl:number level="multiple" format="1.1.1"
  926.                     count="section|subsec1|subsec2"/>
  927.             </xsl:with-param>
  928.         </xsl:call-template>
  929.     </h4>      
  930. </xsl:template>
  931.  
  932. <xsl:template match="subsec3/title">
  933.     <h5>
  934.         <xsl:call-template name="anchoredNumberedTitle">
  935.             <xsl:with-param name="prefix">
  936.                 <xsl:number level="multiple" format="1.1.1.1"
  937.                     count="section|subsec1|subsec2|subsec3"/>
  938.             </xsl:with-param>
  939.         </xsl:call-template>
  940.     </h5>      
  941. </xsl:template>
  942.  
  943. <xsl:template name="anchoredNumberedTitle">
  944.     <xsl:param name="prefix"/>
  945.     <xsl:apply-templates select="../@id"/>
  946.     <a name="S{$prefix}">
  947.         <xsl:if test="/gcapaper/@secnumbers='1'">
  948.             <xsl:value-of select="$prefix"/>
  949.             <xsl:text> </xsl:text>
  950.         </xsl:if>
  951.         <xsl:apply-templates/>
  952.     </a>
  953. </xsl:template>
  954.  
  955. <xsl:template match="section/keyword[1]|subsec1/keyword[1]
  956.     |subsec2/keyword[1]|subsec3/keyword[1]">
  957.     <p class="sectKeyword">
  958.         <i class="sectKeywordHeader"><xsl:text>Keywords: </xsl:text></i>
  959.         <xsl:apply-templates/>
  960.         <xsl:apply-templates select="following-sibling::keyword"/>
  961.     </p>
  962. </xsl:template>
  963.  
  964. <!-- Table of Contents -->
  965. <xsl:template match="title" mode="toc"/>
  966.  
  967. <xsl:template match="section/title" mode="toc">
  968.     <b>
  969.         <xsl:call-template name="linkedNumberedTitle">
  970.             <xsl:with-param name="prefix">
  971.                 <xsl:number level="single" format="1."
  972.                     count="section"/>
  973.             </xsl:with-param>
  974.         </xsl:call-template>
  975.     </b>
  976.     <br/>
  977. </xsl:template>
  978.  
  979. <xsl:template match="subsec1/title" mode="toc">
  980.     <xsl:text disable-output-escaping="yes">
  981.         <![CDATA[    ]]>
  982.     </xsl:text>
  983.         <xsl:call-template name="linkedNumberedTitle">
  984.             <xsl:with-param name="prefix">
  985.                 <xsl:number level="multiple" format="1.1"
  986.                     count="section|subsec1"/>
  987.             </xsl:with-param>
  988.         </xsl:call-template>
  989.     <br/>
  990. </xsl:template>
  991.  
  992. <xsl:template match="subsec2/title" mode="toc">
  993.     <xsl:text disable-output-escaping="yes">
  994.         <![CDATA[        ]]>
  995.     </xsl:text>
  996.         <xsl:call-template name="linkedNumberedTitle">
  997.             <xsl:with-param name="prefix">
  998.                 <xsl:number level="multiple" format="1.1.1"
  999.                     count="section|subsec1|subsec2"/>
  1000.             </xsl:with-param>
  1001.         </xsl:call-template>
  1002.     <br/>
  1003. </xsl:template>
  1004.  
  1005. <xsl:template match="subsec3/title" mode="toc">
  1006.     <xsl:text disable-output-escaping="yes">
  1007.         <![CDATA[        
  1008.             ]]>
  1009.     </xsl:text>
  1010.         <xsl:call-template name="linkedNumberedTitle">
  1011.             <xsl:with-param name="prefix">
  1012.                 <xsl:number level="multiple" format="1.1.1.1"
  1013.                     count="section|subsec1|subsec2|subsec3"/>
  1014.             </xsl:with-param>
  1015.         </xsl:call-template>
  1016.     <br/>
  1017. </xsl:template>
  1018.  
  1019. <xsl:template name="linkedNumberedTitle">
  1020.     <xsl:param name="prefix"/>
  1021.     <a href="#S{$prefix}">
  1022.         <xsl:if test="/gcapaper/@secnumbers='1'">
  1023.             <xsl:value-of select="$prefix"/>
  1024.             <xsl:text> </xsl:text>
  1025.         </xsl:if>
  1026.         <xsl:apply-templates mode="titleText"/>
  1027.     </a>
  1028. </xsl:template>
  1029.  
  1030. <xsl:template match="expansion|ftnote" mode="titleText"/>
  1031.  
  1032. <xsl:template match="text()" mode="titleText">
  1033.   <xsl:value-of select="."/>
  1034. </xsl:template>
  1035.  
  1036. <xsl:template match="ftnote" mode="toc">
  1037.     <b><a href="#S.Footnotes">Footnotes</a></b>
  1038.     <br/>
  1039. </xsl:template>
  1040.  
  1041. <xsl:template match="acknowl" mode="toc">
  1042.     <b><a href="#S.Acknowledgements">Acknowledgements</a></b>
  1043.     <br/>
  1044. </xsl:template>
  1045.  
  1046. <xsl:template match="bibliog" mode="toc">
  1047.     <b><a href="#S.Bibliography">Bibliography</a></b>
  1048.     <br/>
  1049. </xsl:template>
  1050.  
  1051. <xsl:template match="keyword">
  1052. </xsl:template>
  1053. </xsl:stylesheet>
  1054.