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 / jt-to-html.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  3.1 KB  |  88 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.     Convert slop output to HTML for the javateach sample
  20.     $Id: jt-to-html.xsl,v 1.2 2004/03/06 02:25:42 antonio Exp $
  21. -->
  22. <xsl:stylesheet
  23.     version="1.0"
  24.     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  25.     xmlns:slop="http://apache.org/cocoon/slop/parser/1.0"
  26. >
  27.  
  28.     <xsl:param name="pageTitle" select="'Javateach sample - using the Cocoon SLOP parser'"/>
  29.  
  30.     <!-- keys based on last preceding lpstart or lpend, used to split between code and teaching comments -->
  31.     <xsl:key
  32.         name="lastMarkKey"
  33.         match="slop:*" use="generate-id(preceding::slop:*[self::slop:__lpstart|self::slop:__lpend][1])"
  34.     />
  35.  
  36.     <xsl:template match="/">
  37.         <html>
  38.             <head>
  39.                 <title><xsl:value-of select="$pageTitle"/></title>
  40.                 <link rel="stylesheet" type="text/css" href="css/javateach.css"/>
  41.             </head>
  42.             <body>
  43.                 <div id="content">
  44.                     <h1 class="pageTitle"><xsl:value-of select="$pageTitle"/></h1>
  45.                     <div class="code">
  46.                         <pre>
  47.                             <xsl:apply-templates
  48.                                 select="slop:parsed-text/slop:*[not(preceding::slop:__lpstart) and not(self::slop:__lpstart)]"
  49.                                 mode="code"
  50.                             />
  51.                         </pre>
  52.                     </div>
  53.                     <xsl:apply-templates select="slop:parsed-text/slop:__lpstart|slop:parsed-text/slop:__lpend"/>
  54.                 </div>
  55.             </body>
  56.         </html>
  57.  
  58.     </xsl:template>
  59.  
  60.     <xsl:template match="slop:__lpstart">
  61.         <div class="teachingComments">
  62.             <xsl:apply-templates select="key('lastMarkKey',generate-id(.))" mode="teachingComments"/>
  63.         </div>
  64.     </xsl:template>
  65.  
  66.     <xsl:template match="slop:__lpend">
  67.         <div class="code">
  68.             <pre>
  69.                 <xsl:apply-templates select="key('lastMarkKey',generate-id(.))" mode="code"/>
  70.             </pre>
  71.         </div>
  72.     </xsl:template>
  73.  
  74.     <xsl:template match="slop:*" mode="teachingComments">
  75.         <xsl:value-of select="concat(substring-after(.,'//'),' ')" disable-output-escaping="yes"/>
  76.     </xsl:template>
  77.  
  78.     <xsl:template match="slop:*" mode="code">
  79.         <span class="lineNumber">
  80.             <xsl:value-of select="concat(@line-number,'  ')"/>
  81.         </span>
  82.         <span class="codeLine">
  83.             <xsl:value-of select="concat(.,' ')"/>
  84.         </span>
  85.     </xsl:template>
  86.  
  87. </xsl:stylesheet>
  88.