content/xml/document/resources/XMLPrettyPrint.xsl

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     1 <?xml version="1.0"?>
     2 <!-- This Source Code Form is subject to the terms of the Mozilla Public
     3    - License, v. 2.0. If a copy of the MPL was not distributed with this
     4    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
     6 <!DOCTYPE overlay [
     7   <!ENTITY % prettyPrintDTD SYSTEM "chrome://global/locale/xml/prettyprint.dtd">
     8   %prettyPrintDTD;
     9   <!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
    10   %globalDTD;
    11 ]>
    13 <xsl:stylesheet version="1.0"
    14                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    15                 xmlns="http://www.w3.org/1999/xhtml">
    17   <xsl:output method="xml"/>
    19   <xsl:template match="/">
    20     <link href="chrome://global/content/xml/XMLPrettyPrint.css" type="text/css" rel="stylesheet"/>
    21     <link title="Monospace" href="chrome://global/content/xml/XMLMonoPrint.css" type="text/css" rel="alternate stylesheet"/>
    22     <div id="header" dir="&locale.dir;">
    23       <p>
    24         &xml.nostylesheet;
    25       </p>
    26     </div>
    27     <xsl:apply-templates/>
    28   </xsl:template>
    30   <xsl:template match="*">
    31     <div>
    32       <xsl:text>&lt;</xsl:text>
    33       <span class="start-tag"><xsl:value-of select="name(.)"/></span>
    34       <xsl:apply-templates select="@*"/>
    35       <xsl:text>/&gt;</xsl:text>
    36     </div>
    37   </xsl:template>
    39   <xsl:template match="*[node()]">
    40     <div>
    41       <xsl:text>&lt;</xsl:text>
    42       <span class="start-tag"><xsl:value-of select="name(.)"/></span>
    43       <xsl:apply-templates select="@*"/>
    44       <xsl:text>&gt;</xsl:text>
    46       <span class="text"><xsl:value-of select="."/></span>
    48       <xsl:text>&lt;/</xsl:text>
    49       <span class="end-tag"><xsl:value-of select="name(.)"/></span>
    50       <xsl:text>&gt;</xsl:text>
    51     </div>
    52   </xsl:template>
    54   <xsl:template match="*[* or processing-instruction() or comment() or string-length(.) &gt; 50]">
    55     <div class="expander-open">
    56       <xsl:call-template name="expander"/>
    58       <xsl:text>&lt;</xsl:text>
    59       <span class="start-tag"><xsl:value-of select="name(.)"/></span>
    60       <xsl:apply-templates select="@*"/>
    61       <xsl:text>&gt;</xsl:text>
    63       <div class="expander-content"><xsl:apply-templates/></div>
    65       <xsl:text>&lt;/</xsl:text>
    66       <span class="end-tag"><xsl:value-of select="name(.)"/></span>
    67       <xsl:text>&gt;</xsl:text>
    68     </div>
    69   </xsl:template>
    71   <xsl:template match="@*">
    72     <xsl:text> </xsl:text>
    73     <span class="attribute-name"><xsl:value-of select="name(.)"/></span>
    74     <xsl:text>=</xsl:text>
    75     <span class="attribute-value">"<xsl:value-of select="."/>"</span>
    76   </xsl:template>
    78   <xsl:template match="text()">
    79     <xsl:if test="normalize-space(.)">
    80       <xsl:value-of select="."/>
    81     </xsl:if>
    82   </xsl:template>
    84   <xsl:template match="processing-instruction()">
    85     <div class="pi">
    86       <xsl:text>&lt;?</xsl:text>
    87       <xsl:value-of select="name(.)"/>
    88       <xsl:text> </xsl:text>
    89       <xsl:value-of select="."/>
    90       <xsl:text>?&gt;</xsl:text>
    91     </div>
    92   </xsl:template>
    94   <xsl:template match="processing-instruction()[string-length(.) &gt; 50]">
    95     <div class="expander-open">
    96       <xsl:call-template name="expander"/>
    98       <span class="pi">
    99         <xsl:text> &lt;?</xsl:text>
   100         <xsl:value-of select="name(.)"/>
   101       </span>
   102       <div class="expander-content pi"><xsl:value-of select="."/></div>
   103       <span class="pi">
   104         <xsl:text>?&gt;</xsl:text>
   105       </span>
   106     </div>
   107   </xsl:template>
   109   <xsl:template match="comment()">
   110     <div class="comment">
   111       <xsl:text>&lt;!--</xsl:text>
   112       <xsl:value-of select="."/>
   113       <xsl:text>--&gt;</xsl:text>
   114     </div>
   115   </xsl:template>
   117   <xsl:template match="comment()[string-length(.) &gt; 50]">
   118     <div class="expander-open">
   119       <xsl:call-template name="expander"/>
   121       <span class="comment">
   122         <xsl:text>&lt;!--</xsl:text>
   123       </span>
   124       <div class="expander-content comment">
   125         <xsl:value-of select="."/>
   126       </div>
   127       <span class="comment">
   128         <xsl:text>--&gt;</xsl:text>
   129       </span> 
   130     </div>
   131   </xsl:template>
   133   <xsl:template name="expander">
   134     <div class="expander">&#x2212;</div>
   135   </xsl:template>
   137 </xsl:stylesheet>

mercurial