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 / code2html.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  2.0 KB  |  62 lines

  1. <?xml version="1.0" encoding="iso-8859-1"?>
  2.  
  3. <!--
  4.   Copyright 1999-2004 The Apache Software Foundation
  5.  
  6.   Licensed under the Apache License, Version 2.0 (the "License");
  7.   you may not use this file except in compliance with the License.
  8.   You may obtain a copy of the License at
  9.  
  10.       http://www.apache.org/licenses/LICENSE-2.0
  11.  
  12.   Unless required by applicable law or agreed to in writing, software
  13.   distributed under the License is distributed on an "AS IS" BASIS,
  14.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15.   See the License for the specific language governing permissions and
  16.   limitations under the License.
  17. -->
  18.  
  19. <!-- convert code elements to HTML -->
  20.  
  21. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  22.  
  23.     <!-- by default copy everything -->
  24.     <xsl:template match="*">
  25.         <xsl:copy>
  26.             <xsl:copy-of select="@*"/>
  27.             <xsl:apply-templates/>
  28.         </xsl:copy>
  29.     </xsl:template>
  30.  
  31.     <!-- process xml-code elements -->
  32.     <xsl:template match="xml-code">
  33.         <div class="code">
  34.             <xsl:apply-templates mode="code"/>
  35.         </div>
  36.     </xsl:template>
  37.  
  38.     <!-- in code mode, dump all elements -->
  39.     <xsl:template match="*" mode="code">
  40.         <div class="codeIndent">
  41.             <xsl:choose>
  42.                 <xsl:when test="*|.//text()|.//comment">
  43.                     <<xsl:value-of select="name()"/><xsl:apply-templates select="@*" mode="code"/>>
  44.                     <xsl:apply-templates mode="code"/>
  45.                     </<xsl:value-of select="name()"/>>
  46.                 </xsl:when>
  47.  
  48.                 <xsl:otherwise>
  49.                     <<xsl:value-of select="name()"/><xsl:apply-templates select="@*" mode="code"/>/>
  50.                 </xsl:otherwise>
  51.             </xsl:choose>
  52.         </div>
  53.  
  54.     </xsl:template>
  55.  
  56.     <!-- in code mode, dump all attributes -->
  57.     <xsl:template match="@*" mode="code">
  58.         <xsl:value-of select="concat(' ',name(),'="',.,'"')"/>
  59.     </xsl:template>
  60.  
  61. </xsl:stylesheet>
  62.