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 / docnbsp.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  2.3 KB  |  74 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:str="http://exslt.org/strings"
  20.   extension-element-prefixes="str">
  21.  
  22. <!-- doc2nbsp.xsl - text line wrapping
  23.   This stylesheet uses exslt extension for strings to add non-breaking spaces.
  24. -->
  25.  
  26.   <xsl:template match="document">
  27.     <html>
  28.       <head>
  29.         <title><xsl:value-of select="header/title"/></title>
  30.       </head>
  31.       <xsl:apply-templates/>
  32.     </html>
  33.   </xsl:template>
  34.  
  35.   <xsl:template match="body">
  36.     <body>
  37.       <h1><xsl:value-of select="header/title"/></h1>
  38.       <p>Comment from stylesheet: sequences of two consecutive spaces are replaced by a non-breaking space and a space.
  39.       This keeps indentation while allowing word wrapping.
  40.       </p>
  41.       <xsl:apply-templates/>
  42.     </body>
  43.   </xsl:template>
  44.  
  45.   <xsl:template match="section">
  46.     <xsl:apply-templates/>
  47.   </xsl:template>
  48.  
  49.   <xsl:template match="source">
  50.     <div style="padding:4pt; margin-bottom:8pt; border-width:1px; border-style:solid; border-color:#0086b2;">
  51.       <!-- iterate over each line -->
  52.       <xsl:for-each select="str:split(string(.), ' ')">
  53.         <code>
  54.           <!-- replace each group of two spaces by a   and a space to allow line wrap while still
  55.                keeping indentation -->
  56.           <xsl:for-each select="str:split(string(.), '  ')">
  57.             <xsl:value-of select="."/><xsl:text>  </xsl:text>
  58.           </xsl:for-each>
  59.         </code>
  60.         <br/>
  61.       </xsl:for-each>
  62.     </div>
  63.   </xsl:template>
  64.  
  65.   <xsl:template match="title">
  66.     <h2><xsl:apply-templates/></h2>
  67.   </xsl:template>
  68.  
  69.   <xsl:template match="p">
  70.     <p><xsl:apply-templates/></p>
  71.   </xsl:template>
  72.  
  73. </xsl:stylesheet>
  74.