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 / site2wml.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  3.9 KB  |  173 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.  
  18. <!--
  19.   Version <![CDATA[ $Id: site2wml.xsl,v 1.3 2004/04/05 12:25:32 antonio Exp $ ]]>
  20.   
  21.   Transformation of an aggregated site document to wml
  22. -->
  23.  
  24. <xsl:stylesheet version="1.0" 
  25.   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  26.   xmlns:page="http://apache.org/cocoon/paginate/1.0"
  27.   
  28.   exclude-result-prefixes="page"
  29. >
  30.  
  31. <xsl:template match="site">
  32.   <!--xsl:copy-of select="."/-->
  33. <wml>
  34.   <template>
  35.     <do type="prev" name="prev" label="Zur∩┐╜ck">
  36.       <prev/>
  37.     </do>
  38.   </template>
  39.   
  40.   <card id="Main">
  41.     <xsl:attribute name="title"><xsl:value-of select="/site/mid-col-2/header/title"/></xsl:attribute>
  42.  
  43.     <xsl:apply-templates select="/site/mid-col-2/body/*"/>
  44.     <!--xsl:apply-templates select="/site/bottom-col-1/body/*"/-->
  45.     
  46.     <p>
  47.       <xsl:apply-templates select="/site/page:page"/>
  48.     </p>
  49.     
  50.     <p> <a href="#Links">Links</a>
  51.     </p>
  52.   </card>
  53.   
  54.   <card id="Links" title="Links">
  55.     <xsl:apply-templates select="/site/top-col-1"/>
  56.  
  57.     <xsl:apply-templates select="/site/mid-col-1/body/*"/>
  58.     <xsl:apply-templates select="/site/mid-col-3/body/*"/>
  59.     
  60.   </card>
  61.   
  62. </wml>
  63. </xsl:template>
  64.  
  65. <xsl:template match="top-col-1">
  66.   <p>
  67.     <em>
  68.       <xsl:value-of select="body/p"/>
  69.     </em>
  70.   </p>
  71. </xsl:template>
  72.  
  73. <xsl:template match="ul|ol">
  74.   <p>
  75.     <xsl:apply-templates/>
  76.   </p>
  77. </xsl:template>
  78.  
  79. <xsl:template match="li">
  80.   <xsl:text>»</xsl:text>
  81.   <xsl:apply-templates/>
  82.   <br/>
  83. </xsl:template>
  84.  
  85. <xsl:template match="s1">
  86.   <p>
  87.     <strong><xsl:value-of select="@title"/></strong>
  88.   </p>
  89.   <xsl:apply-templates/>
  90. </xsl:template>
  91.  
  92. <xsl:template match="s2">
  93.   <p>
  94.     <em><xsl:value-of select="@title"/></em>
  95.   </p>
  96.   <xsl:apply-templates/>
  97. </xsl:template>
  98.  
  99. <xsl:template match="s3">
  100.   <p>
  101.     <u><xsl:value-of select="@title"/></u>
  102.   </p>
  103.   <xsl:apply-templates/>
  104. </xsl:template>
  105.  
  106. <xsl:template match="p">
  107.   <xsl:variable name="pcontent" select="."/>
  108.   <xsl:choose>
  109.     <xsl:when test="string-length($pcontent) > 120">
  110.       <p>
  111.         <xsl:value-of select="substring($pcontent, 1, 120 )"/>
  112.         <xsl:text>...</xsl:text>
  113.       </p>
  114.     </xsl:when>
  115.     <xsl:otherwise>
  116.       <p>
  117.         <xsl:apply-templates/>
  118.       </p>
  119.     </xsl:otherwise>
  120.   </xsl:choose>
  121. </xsl:template>
  122.  
  123. <xsl:template match="p/br">
  124.   <br/>
  125. </xsl:template>
  126.  
  127. <xsl:template match="blockquote">
  128.   <p> <xsl:text> + </xsl:text>
  129.     <xsl:apply-templates/>
  130.   </p>
  131. </xsl:template>
  132.  
  133. <xsl:template match="pre|source">
  134.   <p>
  135.     <xsl:text> ... </xsl:text>
  136.   </p>
  137. </xsl:template>
  138.  
  139. <xsl:template match="link">
  140.   <xsl:variable name="href" select="@href"/>
  141.   <xsl:choose>
  142.     <xsl:when test="not(contains( $href, '.wml' ))">
  143.       <xsl:value-of select="."/> 
  144.       <xsl:text>: </xsl:text> 
  145.       <u><xsl:value-of select="@href"/></u>
  146.     </xsl:when>
  147.     <xsl:otherwise>
  148.       <a><xsl:attribute 
  149.         name="href"><xsl:value-of select="@href"/></xsl:attribute><xsl:value-of 
  150.         select="."/></a>
  151.     </xsl:otherwise>
  152.   </xsl:choose>
  153. </xsl:template>
  154.  
  155. <xsl:template match="jump">
  156.   <a href="{@href}#{@anchor}">
  157.     <xsl:apply-templates/>
  158.   </a>
  159. </xsl:template>
  160.  
  161. <xsl:template match="page:page">
  162.   <xsl:if test="page:link[@type='prev']">
  163.     [<a href="{page:link[@type = 'prev']/@uri}">Back</a>]
  164.   </xsl:if>
  165.    
  166.   <xsl:if test="page:link[@type='next']">
  167.     [<a href="{page:link[@type = 'next']/@uri}">Next</a>]
  168.   </xsl:if>
  169. </xsl:template>
  170.  
  171. </xsl:stylesheet>
  172.  
  173.