home *** CD-ROM | disk | FTP | other *** search
/ ftp.swcp.com / ftp.swcp.com.zip / ftp.swcp.com / mac / mozilla-macos9-1.3.1.sea.bin / Mozilla1.3.1 / Chrome / comm.jar / content / communicator / xml / XMLPrettyPrint.xsl < prev   
Extensible Markup Language  |  2003-06-08  |  6KB  |  162 lines

  1. <?xml version="1.0"?>
  2. <!-- ***** BEGIN LICENSE BLOCK *****
  3.    - Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.    -
  5.    - The contents of this file are subject to the Mozilla Public License Version
  6.    - 1.1 (the "License"); you may not use this file except in compliance with
  7.    - the License. You may obtain a copy of the License at
  8.    - http://www.mozilla.org/MPL/
  9.    -
  10.    - Software distributed under the License is distributed on an "AS IS" basis,
  11.    - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.    - for the specific language governing rights and limitations under the
  13.    - License.
  14.    -
  15.    - The Original Code is mozilla.org code.
  16.    -
  17.    - The Initial Developer of the Original Code is
  18.    - Netscape Communications Corporation.
  19.    - Portions created by the Initial Developer are Copyright (C) 2002
  20.    - the Initial Developer. All Rights Reserved.
  21.    -
  22.    - Contributor(s):
  23.    -   Jonas Sicking <sicking@bigfoot.com> (Original author)
  24.    -
  25.    - Alternatively, the contents of this file may be used under the terms of
  26.    - either the GNU General Public License Version 2 or later (the "GPL"), or
  27.    - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28.    - in which case the provisions of the GPL or the LGPL are applicable instead
  29.    - of those above. If you wish to allow use of your version of this file only
  30.    - under the terms of either the GPL or the LGPL, and not to allow others to
  31.    - use your version of this file under the terms of the MPL, indicate your
  32.    - decision by deleting the provisions above and replace them with the notice
  33.    - and other provisions required by the LGPL or the GPL. If you do not delete
  34.    - the provisions above, a recipient may use your version of this file under
  35.    - the terms of any one of the MPL, the GPL or the LGPL.
  36.    -
  37.    - ***** END LICENSE BLOCK ***** -->
  38.  
  39. <xsl:stylesheet version="1.0"
  40.                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  41.                 xmlns="http://www.w3.org/1999/xhtml">
  42.  
  43.   <xsl:output method="xml"/>
  44.  
  45.   <xsl:template match="/">
  46.     <link href="chrome://communicator/content/xml/XMLPrettyPrint.css" type="text/css" rel="stylesheet"/>
  47.     <div id="header">
  48.       <p>
  49.         This XML file does not appear to have any style information
  50.         associated with it. The document tree is shown below.
  51.       </p>
  52.     </div>
  53.     <xsl:apply-templates/>
  54.   </xsl:template>
  55.  
  56.   <xsl:template match="*">
  57.     <div class="indent">
  58.       <span class="markup"><</span>
  59.       <span class="start-tag"><xsl:value-of select="name(.)"/></span>
  60.       <xsl:apply-templates select="@*"/>
  61.       <span class="markup">/></span>
  62.     </div>
  63.   </xsl:template>
  64.  
  65.   <xsl:template match="*[node()]">
  66.     <div class="indent">
  67.       <span class="markup"><</span>
  68.       <span class="start-tag"><xsl:value-of select="name(.)"/></span>
  69.       <xsl:apply-templates select="@*"/>
  70.       <span class="markup">></span>
  71.  
  72.       <span class="text"><xsl:value-of select="."/></span>
  73.  
  74.       <span class="markup"></</span>
  75.       <span class="end-tag"><xsl:value-of select="name(.)"/></span>
  76.       <span class="markup">></span>
  77.     </div>
  78.   </xsl:template>
  79.  
  80.   <xsl:template match="*[* or processing-instruction() or comment() or string-length(.) > 50]">
  81.     <table>
  82.       <tr>
  83.         <xsl:call-template name="expander"/>
  84.         <td>
  85.           <span class="markup"><</span>
  86.           <span class="start-tag"><xsl:value-of select="name(.)"/></span>
  87.           <xsl:apply-templates select="@*"/>
  88.           <span class="markup">></span>
  89.  
  90.           <div class="expander-content"><xsl:apply-templates/></div>
  91.  
  92.           <span class="markup"></</span>
  93.           <span class="end-tag"><xsl:value-of select="name(.)"/></span>
  94.           <span class="markup">></span>
  95.         </td>
  96.       </tr>
  97.     </table>
  98.   </xsl:template>
  99.  
  100.   <xsl:template match="@*">
  101.     <xsl:text> </xsl:text>
  102.     <span class="attribute-name"><xsl:value-of select="name(.)"/></span>
  103.     <span class="markup">=</span>
  104.     <span class="attribute-value">"<xsl:value-of select="."/>"</span>
  105.   </xsl:template>
  106.  
  107.   <xsl:template match="text()">
  108.     <xsl:if test="normalize-space(.)">
  109.       <div class="indent text"><xsl:value-of select="."/></div>
  110.     </xsl:if>
  111.   </xsl:template>
  112.  
  113.   <xsl:template match="processing-instruction()">
  114.     <div class="indent pi">
  115.       <xsl:text><?</xsl:text>
  116.       <xsl:value-of select="name(.)"/>
  117.       <xsl:text> </xsl:text>
  118.       <xsl:value-of select="."/>
  119.       <xsl:text>?></xsl:text>
  120.     </div>
  121.   </xsl:template>
  122.  
  123.   <xsl:template match="processing-instruction()[string-length(.) > 50]">
  124.     <table>
  125.       <tr>
  126.         <xsl:call-template name="expander"/>
  127.         <td class="pi">
  128.           <?<xsl:value-of select="name(.)"/>
  129.           <div class="indent expander-content"><xsl:value-of select="."/></div>
  130.           <xsl:text>?></xsl:text>
  131.         </td>
  132.       </tr>
  133.     </table>
  134.   </xsl:template>
  135.  
  136.   <xsl:template match="comment()">
  137.     <div class="comment indent">
  138.       <xsl:text><!--</xsl:text>
  139.       <xsl:value-of select="."/>
  140.       <xsl:text>--></xsl:text>
  141.     </div>
  142.   </xsl:template>
  143.  
  144.   <xsl:template match="comment()[string-length(.) > 50]">
  145.     <table>
  146.       <tr>
  147.         <xsl:call-template name="expander"/>
  148.         <td class="comment">
  149.           <xsl:text><!--</xsl:text>
  150.           <div class="indent expander-content"><xsl:value-of select="."/></div>
  151.           <xsl:text>--></xsl:text>
  152.         </td>
  153.       </tr>
  154.     </table>
  155.   </xsl:template>
  156.   
  157.   <xsl:template name="expander">
  158.     <td class="expander">-<div class="spacer"/></td>
  159.   </xsl:template>
  160.  
  161. </xsl:stylesheet>
  162.