home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 October / maximum-cd-2009-10.iso / DiscContents / Firefox Setup 3.5.exe / nonlocalized / chrome / toolkit.jar / content / global / xml / XMLPrettyPrint.xsl < prev   
Encoding:
Extensible Markup Language  |  2009-06-24  |  5.6 KB  |  171 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. <!DOCTYPE overlay [
  40.   <!ENTITY % prettyPrintDTD SYSTEM "chrome://global/locale/xml/prettyprint.dtd">
  41.   %prettyPrintDTD;
  42.   <!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
  43.   %globalDTD;
  44. ]>
  45.  
  46. <xsl:stylesheet version="1.0"
  47.                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  48.                 xmlns="http://www.w3.org/1999/xhtml">
  49.  
  50.   <xsl:output method="xml"/>
  51.  
  52.   <xsl:template match="/">
  53.     <link href="chrome://global/content/xml/XMLPrettyPrint.css" type="text/css" rel="stylesheet"/>
  54.     <link title="Monospace" href="chrome://global/content/xml/XMLMonoPrint.css" type="text/css" rel="alternate stylesheet"/>
  55.     <div id="header" dir="&locale.dir;">
  56.       <p>
  57.         &xml.nostylesheet;
  58.       </p>
  59.     </div>
  60.     <xsl:apply-templates/>
  61.   </xsl:template>
  62.  
  63.   <xsl:template match="*">
  64.     <div>
  65.       <xsl:text><</xsl:text>
  66.       <span class="start-tag"><xsl:value-of select="name(.)"/></span>
  67.       <xsl:apply-templates select="@*"/>
  68.       <xsl:text>/></xsl:text>
  69.     </div>
  70.   </xsl:template>
  71.  
  72.   <xsl:template match="*[node()]">
  73.     <div>
  74.       <xsl:text><</xsl:text>
  75.       <span class="start-tag"><xsl:value-of select="name(.)"/></span>
  76.       <xsl:apply-templates select="@*"/>
  77.       <xsl:text>></xsl:text>
  78.  
  79.       <span class="text"><xsl:value-of select="."/></span>
  80.  
  81.       <xsl:text></</xsl:text>
  82.       <span class="end-tag"><xsl:value-of select="name(.)"/></span>
  83.       <xsl:text>></xsl:text>
  84.     </div>
  85.   </xsl:template>
  86.  
  87.   <xsl:template match="*[* or processing-instruction() or comment() or string-length(.) > 50]">
  88.     <div class="expander-open">
  89.       <xsl:call-template name="expander"/>
  90.  
  91.       <xsl:text><</xsl:text>
  92.       <span class="start-tag"><xsl:value-of select="name(.)"/></span>
  93.       <xsl:apply-templates select="@*"/>
  94.       <xsl:text>></xsl:text>
  95.  
  96.       <div class="expander-content"><xsl:apply-templates/></div>
  97.  
  98.       <xsl:text></</xsl:text>
  99.       <span class="end-tag"><xsl:value-of select="name(.)"/></span>
  100.       <xsl:text>></xsl:text>
  101.     </div>
  102.   </xsl:template>
  103.  
  104.   <xsl:template match="@*">
  105.     <xsl:text> </xsl:text>
  106.     <span class="attribute-name"><xsl:value-of select="name(.)"/></span>
  107.     <xsl:text>=</xsl:text>
  108.     <span class="attribute-value">"<xsl:value-of select="."/>"</span>
  109.   </xsl:template>
  110.  
  111.   <xsl:template match="text()">
  112.     <xsl:if test="normalize-space(.)">
  113.       <xsl:value-of select="."/>
  114.     </xsl:if>
  115.   </xsl:template>
  116.  
  117.   <xsl:template match="processing-instruction()">
  118.     <div class="pi">
  119.       <xsl:text><?</xsl:text>
  120.       <xsl:value-of select="name(.)"/>
  121.       <xsl:text> </xsl:text>
  122.       <xsl:value-of select="."/>
  123.       <xsl:text>?></xsl:text>
  124.     </div>
  125.   </xsl:template>
  126.  
  127.   <xsl:template match="processing-instruction()[string-length(.) > 50]">
  128.     <div class="expander-open">
  129.       <xsl:call-template name="expander"/>
  130.  
  131.       <span class="pi">
  132.         <xsl:text> <?</xsl:text>
  133.         <xsl:value-of select="name(.)"/>
  134.       </span>
  135.       <div class="expander-content pi"><xsl:value-of select="."/></div>
  136.       <span class="pi">
  137.         <xsl:text>?></xsl:text>
  138.       </span>
  139.     </div>
  140.   </xsl:template>
  141.  
  142.   <xsl:template match="comment()">
  143.     <div class="comment">
  144.       <xsl:text><!--</xsl:text>
  145.       <xsl:value-of select="."/>
  146.       <xsl:text>--></xsl:text>
  147.     </div>
  148.   </xsl:template>
  149.  
  150.   <xsl:template match="comment()[string-length(.) > 50]">
  151.     <div class="expander-open">
  152.       <xsl:call-template name="expander"/>
  153.  
  154.       <span class="comment">
  155.         <xsl:text><!--</xsl:text>
  156.       </span>
  157.       <div class="expander-content comment">
  158.         <xsl:value-of select="."/>
  159.       </div>
  160.       <span class="comment">
  161.         <xsl:text>--></xsl:text>
  162.       </span> 
  163.     </div>
  164.   </xsl:template>
  165.   
  166.   <xsl:template name="expander">
  167.     <div class="expander">−</div>
  168.   </xsl:template>
  169.  
  170. </xsl:stylesheet>
  171.