home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / wiki2xdoc.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  6.9 KB  |  242 lines

  1. <?xml version="1.0"?>
  2. <!--
  3.   Copyright 1999-2004 The Apache Software Foundation
  4.  
  5.   Licensed under the Apache License, Version 2.0 (the "License");
  6.   you may not use this file except in compliance with the License.
  7.   You may obtain a copy of the License at
  8.  
  9.       http://www.apache.org/licenses/LICENSE-2.0
  10.  
  11.   Unless required by applicable law or agreed to in writing, software
  12.   distributed under the License is distributed on an "AS IS" BASIS,
  13.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.   See the License for the specific language governing permissions and
  15.   limitations under the License.
  16. -->
  17. <xsl:stylesheet version="1.0"
  18.                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  19.                 xmlns:st="http://chaperon.sourceforge.net/schema/syntaxtree/2.0"
  20.                 exclude-result-prefixes="st">
  21.  
  22.  <xsl:output indent="yes" 
  23.              method="html"
  24.              doctype-public="-//APACHE//DTD Documentation V1.1//EN"
  25.              doctype-system="document-v11.dtd"
  26.              cdata-section-elements="source"/>
  27.  
  28.  <xsl:template match="st:output">
  29.   <xsl:apply-templates select="st:document/st:paragraphs/st:paragraph/*" mode="paragraph"/>  
  30.   <xsl:apply-templates select="st:document/st:section"/>
  31.  </xsl:template>
  32.  
  33.  <xsl:template match="st:section">
  34.   <section>
  35.    <title><xsl:value-of select="st:title/st:textsequence"/></title>
  36.    <xsl:apply-templates select="st:paragraphs/st:paragraph/*|st:paragraphs/st:subsection" mode="paragraph"/>
  37.   </section>
  38.  </xsl:template>
  39.  
  40.  <xsl:template match="st:subsection" mode="paragraph">
  41.   <section>
  42.    <title><xsl:value-of select="st:subtitle/st:textsequence"/></title>
  43.    <xsl:apply-templates select="st:subparagraphs/st:paragraph/*|st:subparagraphs/st:subsubsection" mode="paragraph"/>
  44.   </section>
  45.  </xsl:template>
  46.  
  47.  <xsl:template match="st:subsubsection" mode="paragraph">
  48.   <section>
  49.    <title><xsl:value-of select="st:subsubtitle/st:textsequence"/></title>
  50.    <xsl:apply-templates select="st:subsubparagraphs/st:paragraph/*" mode="paragraph"/>
  51.   </section>
  52.  </xsl:template>
  53.  
  54.  <xsl:template match="st:source" mode="paragraph">
  55.   <source>
  56.    <xsl:value-of select="substring(.,4,string-length(.)-6)"/>
  57.   </source>
  58.  </xsl:template>
  59.  
  60.  <xsl:template match="st:textsequence" mode="paragraph">
  61.   <p>
  62.    <xsl:apply-templates select="st:textblock/*|st:break"/>
  63.   </p>
  64.  </xsl:template>
  65.  
  66.  <xsl:template match="st:line" mode="paragraph">
  67.   <p>--------------------------------------------------------------------------------</p>
  68.  </xsl:template>
  69.  
  70.  <xsl:template match="st:table" mode="paragraph"> 
  71.   <table>
  72.    <xsl:apply-templates select="st:tablehead|st:tablerows/st:tablecolumns"/>
  73.   </table>
  74.  </xsl:template>
  75.  
  76.  <xsl:template match="st:tablehead"> 
  77.   <tr>
  78.    <xsl:apply-templates select="st:tabletitle"/>
  79.   </tr>
  80.  </xsl:template>
  81.  
  82.  <xsl:template match="st:tabletitle">
  83.   <th>
  84.    <xsl:apply-templates select="st:textblock/*"/>
  85.   </th>
  86.  </xsl:template>
  87.  
  88.  <xsl:template match="st:tablecolumns">
  89.   <tr>
  90.    <xsl:apply-templates select="st:tablecolumn"/>
  91.   </tr>
  92.  </xsl:template>
  93.  
  94.  <xsl:template match="st:tablecolumn">
  95.   <td>
  96.    <xsl:apply-templates select="st:textblock/*"/>
  97.   </td>
  98.  </xsl:template>
  99.  
  100.  <xsl:template match="st:text">
  101.   <xsl:value-of select="."/><xsl:text> </xsl:text>
  102.  </xsl:template>
  103.  
  104.  <xsl:template match="st:break">
  105.   <br/>
  106.  </xsl:template>
  107.  
  108.  <xsl:template match="st:link">
  109.   <xsl:choose>
  110.    <xsl:when test="contains(.,'|')">
  111.  
  112.     <xsl:variable name="href" select="substring-before(substring-after(.,'|'),']')"/>
  113.     <xsl:variable name="text" select="substring-after(substring-before(.,'|'),'[')"/>
  114.  
  115.     <xsl:choose>
  116.      <xsl:when test="string(number($href)) != 'NaN'">
  117.       <link href="#{$href}">
  118.        <xsl:value-of select="$text"/>
  119.       </link>
  120.      </xsl:when>
  121.      <xsl:when test="contains($href,':') or contains($href,'.')">
  122.       <link href="{$href}">
  123.        <xsl:value-of select="$text"/>
  124.       </link>
  125.      </xsl:when>
  126.      <xsl:otherwise>
  127.       <link href="view.do?page={$href}">
  128.        <xsl:value-of select="$text"/>
  129.       </link>
  130.      </xsl:otherwise>
  131.     </xsl:choose>
  132.  
  133.    </xsl:when>
  134.    <xsl:otherwise>
  135.     <xsl:variable name="href" select="substring(.,2,string-length(.)-2)"/>
  136.     
  137.     <xsl:choose>
  138.      <xsl:when test="string(number($href)) != 'NaN'">
  139.       <link href="#{$href}">
  140.        [<xsl:value-of select="$href"/>]
  141.       </link>
  142.      </xsl:when>
  143.      <xsl:when test="contains($href,'.png') or contains($href,'.jpg') or contains($href,'.gif')">
  144.       <img src="{$href}" alt="{$href}"/>
  145.      </xsl:when>
  146.      <xsl:when test="contains($href,':') or contains($href,'.')">
  147.       <link href="{$href}">
  148.        <xsl:value-of select="$href"/>
  149.       </link>
  150.      </xsl:when>
  151.      <xsl:otherwise>
  152.       <link href="view.do?page={$href}">
  153.        <xsl:value-of select="$href"/>
  154.       </link>
  155.      </xsl:otherwise>
  156.     </xsl:choose>
  157.  
  158.    </xsl:otherwise>
  159.   </xsl:choose>
  160.  </xsl:template>
  161.  
  162.  <xsl:template match="st:anchor" >
  163.   <xsl:choose>
  164.    <xsl:when test="contains(.,'|')">
  165.     <anchor name="{substring-before(substring-after(.,'|#'),']')}">
  166.      <xsl:value-of select="substring-after(substring-before(.,'|'),'[')"/>
  167.     </anchor>
  168.    </xsl:when>
  169.    <xsl:otherwise>
  170.     <anchor name="{substring(.,3,string-length(.)-3)}"/>
  171.    </xsl:otherwise>
  172.   </xsl:choose>
  173.  </xsl:template>
  174.  
  175.  <xsl:template match="st:emblock">
  176.   <em><xsl:value-of select="st:text"/></em><xsl:text> </xsl:text>
  177.  </xsl:template>
  178.  
  179.  <xsl:template match="st:strongblock">
  180.   <strong><xsl:value-of select="st:text"/></strong><xsl:text> </xsl:text>
  181.  </xsl:template>
  182.  
  183.  <xsl:template match="st:codeblock">
  184.   <code><xsl:value-of select="st:text"/></code><xsl:text> </xsl:text>
  185.  </xsl:template>
  186.  
  187.  <xsl:template match="st:bulletedlist" mode="paragraph">
  188.   <ul>
  189.    <xsl:apply-templates select="st:bulletedlistitem"/>
  190.   </ul>
  191.  </xsl:template>
  192.  
  193.  <xsl:template match="st:bulletedlistitem" >
  194.   <li>
  195.    <xsl:apply-templates select="st:textsequence/st:textblock/*"/>
  196.   </li>
  197.  </xsl:template>
  198.  
  199.  <xsl:template match="st:numberedlist1" mode="paragraph">
  200.   <ol>
  201.    <xsl:apply-templates select="st:numberedlistitem1|st:numberedlist2"/>
  202.   </ol>
  203.  </xsl:template>
  204.  
  205.  <xsl:template match="st:numberedlistitem1" >
  206.   <li>
  207.    <xsl:apply-templates select="st:textsequence/st:textblock/*"/>
  208.   </li>
  209.  </xsl:template>
  210.  
  211.  <xsl:template match="st:numberedlist2" >
  212.   <ol>
  213.    <xsl:apply-templates select="st:numberedlistitem2|st:numberedlist3"/>
  214.   </ol>
  215.  </xsl:template>
  216.     
  217.  <xsl:template match="st:numberedlistitem2" >
  218.   <li>
  219.    <xsl:apply-templates select="st:textsequence/st:textblock/*"/>
  220.   </li>
  221.  </xsl:template>
  222.  
  223.  <xsl:template match="st:numberedlist3" >
  224.   <ol>
  225.    <xsl:apply-templates select="st:numberedlistitem3"/>
  226.   </ol>
  227.  </xsl:template>
  228.     
  229.  <xsl:template match="st:numberedlistitem3" >
  230.   <li>
  231.    <xsl:apply-templates select="st:textsequence/st:textblock/*"/>
  232.   </li>
  233.  </xsl:template>
  234.  
  235.  <xsl:template match="@*|*|text()|processing-instruction()" priority="-1">
  236.   <xsl:copy>
  237.    <xsl:apply-templates select="@*|*|text()|processing-instruction()"/>
  238.   </xsl:copy>
  239.  </xsl:template>
  240.  
  241. </xsl:stylesheet>
  242.