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 / xml2html.xslt < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  7.7 KB  |  267 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.  
  18. <!--+
  19.     | XSLT REC Compliant Version of IE5 Default Stylesheet
  20.     |
  21.     | Original version by Jonathan Marsh (jmarsh@microsoft.com)
  22.     | Conversion to XSLT 1.0 REC Syntax by Steve Muench (smuench@oracle.com)
  23.     | Added script support by Andrew Timberlake (andrew@timberlake.co.za)
  24.     | Cleaned up and ported to standard DOM by Stefano Mazzocchi (stefano@apache.org)
  25.     | Changed the right margin for SitmapViewer by Jelle Alten 
  26.     |
  27.     | CVS $Id: xml2html.xslt,v 1.2 2004/03/06 02:25:37 antonio Exp $
  28.     +-->
  29.     
  30. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  31.  
  32.    <xsl:template match="/">
  33.       <HTML>
  34.          <HEAD>
  35.             <STYLE>
  36.               BODY  {background-color: white; color: black; font: monospace;}
  37.                 .b  {cursor:pointer; color:red; font-weight:bold; text-decoration:none}
  38.                 .e  {border: 0px; padding: 0px; margin: 0px 0px 0px 2em; text-indent:-1em;}
  39.                 .en {color:#000088; font-weight:bold;}
  40.                 .an {color:#880000}
  41.                 .av {color:#888888}
  42.                 .c  {color:#008800}
  43.                 .t  {color:black}
  44.                 .m  {color:navy}
  45.                 .pi {color:red}
  46.                 PRE {margin:0px; display:inline}
  47.                 DIV {border:0; padding:0; margin:0;}
  48.             </STYLE>
  49.             <SCRIPT><xsl:comment><![CDATA[
  50.  
  51. function click(event) {
  52.  
  53.     var mark = event.target;
  54.  
  55.     while ((mark.className != "b") && (mark.nodeName != "BODY")) {
  56.         mark = mark.parentNode
  57.     }
  58.     
  59.     var e = mark;
  60.     
  61.     while ((e.className != "e") && (e.nodeName != "BODY")) {
  62.         e = e.parentNode
  63.     }
  64.     
  65.     if (mark.childNodes[0].nodeValue == "+") {
  66.         mark.childNodes[0].nodeValue = "-";
  67.         for (var i = 2; i < e.childNodes.length; i++) {
  68.             var name = e.childNodes[i].nodeName;
  69.             if (name != "#text") {
  70.                 if (name == "PRE" || name == "SPAN") {
  71.                    window.status = "inline";
  72.                    e.childNodes[i].style.display = "inline";
  73.                 } else {
  74.                    e.childNodes[i].style.display = "block";
  75.                 }
  76.             }
  77.         }
  78.     } else if (mark.childNodes[0].nodeValue == "-") {
  79.         mark.childNodes[0].nodeValue = "+";
  80.         for (var i = 2; i < e.childNodes.length; i++) {
  81.             if (e.childNodes[i].nodeName != "#text") {
  82.                 e.childNodes[i].style.display = "none";
  83.             }
  84.         }
  85.     }
  86. }  
  87.   
  88. ]]></xsl:comment>
  89.          </SCRIPT>
  90.          </HEAD>
  91.          <BODY>
  92.             <xsl:apply-templates/>
  93.          </BODY>
  94.       </HTML>
  95.    </xsl:template>
  96.  
  97.    <!-- match processing instructions -->
  98.    <xsl:template match="processing-instruction()">
  99.       <DIV class="e">
  100.          <SPAN class="m">
  101.             <xsl:text><?</xsl:text>
  102.          </SPAN>
  103.          <SPAN class="pi">
  104.             <xsl:value-of select="name(.)"/>
  105.             <xsl:value-of select="."/>
  106.          </SPAN>
  107.          <SPAN class="m">
  108.             <xsl:text>?></xsl:text>
  109.          </SPAN>
  110.       </DIV>
  111.    </xsl:template>
  112.  
  113.    <!-- match text -->
  114.    <xsl:template match="text()">
  115.       <DIV class="e">
  116.          <SPAN class="t">
  117.             <xsl:value-of select="."/>
  118.          </SPAN>
  119.       </DIV>
  120.    </xsl:template>
  121.  
  122.    <!-- match comments -->
  123.    <xsl:template match="comment()">
  124.       <DIV class="e">
  125.          <SPAN class="b" onclick="click(event)">-</SPAN>
  126.          <SPAN class="m">
  127.             <xsl:text><!--</xsl:text>
  128.          </SPAN>
  129.          <SPAN class="c">
  130.             <PRE>
  131.                <xsl:value-of select="."/>
  132.             </PRE>
  133.          </SPAN>
  134.          <SPAN class="m">
  135.             <xsl:text>--></xsl:text>
  136.          </SPAN>
  137.       </DIV>
  138.    </xsl:template>
  139.  
  140.    <!-- match attributes -->
  141.    <xsl:template match="@*">
  142.       <SPAN class="an">
  143.          <xsl:value-of select="name(.)"/>
  144.       </SPAN>
  145.       <SPAN class="m">="</SPAN>
  146.       <SPAN class="av">
  147.          <xsl:value-of select="."/>
  148.       </SPAN>
  149.       <SPAN class="m">"</SPAN>
  150.       <xsl:if test="position()!=last()">
  151.          <xsl:text> </xsl:text>
  152.       </xsl:if>
  153.    </xsl:template>
  154.    
  155.    <!-- match empty nodes -->
  156.    <xsl:template match="*">
  157.       <DIV class="e">
  158.         <SPAN class="m"><</SPAN>
  159.         <SPAN class="en">
  160.            <xsl:value-of select="name(.)"/>
  161.         </SPAN>
  162.         <xsl:if test="@*">
  163.            <xsl:text> </xsl:text>
  164.         </xsl:if>
  165.         <xsl:apply-templates select="@*"/>
  166.         <SPAN class="m">
  167.            <xsl:text>/></xsl:text>
  168.         </SPAN>
  169.       </DIV>
  170.    </xsl:template>
  171.  
  172.    <xsl:template match="*[node()]">
  173.       <DIV class="e">
  174.          <DIV>
  175.             <SPAN class="b" onclick="click(event)">-</SPAN>
  176.             <SPAN class="m"><</SPAN>
  177.             <SPAN class="en">
  178.                <xsl:value-of select="name(.)"/>
  179.             </SPAN>
  180.             <xsl:if test="@*">
  181.                <xsl:text> </xsl:text>
  182.             </xsl:if>
  183.             <xsl:apply-templates select="@*"/>
  184.             <SPAN class="m">
  185.                <xsl:text>></xsl:text>
  186.             </SPAN>
  187.          </DIV>
  188.          <DIV>
  189.             <xsl:apply-templates/>
  190.             <DIV>
  191.                <SPAN class="m">
  192.                   <xsl:text></</xsl:text>
  193.                </SPAN>
  194.                <SPAN class="en">
  195.                   <xsl:value-of select="name(.)"/>
  196.                </SPAN>
  197.                <SPAN class="m">
  198.                   <xsl:text>></xsl:text>
  199.                </SPAN>
  200.             </DIV>
  201.          </DIV>
  202.       </DIV>
  203.    </xsl:template>
  204.  
  205.    <xsl:template match="*[text() and not (comment() or processing-instruction())]">
  206.       <DIV class="e">
  207.         <SPAN class="m">
  208.            <xsl:text><</xsl:text>
  209.         </SPAN>
  210.         <SPAN class="en">
  211.            <xsl:value-of select="name(.)"/>
  212.         </SPAN>
  213.         <xsl:if test="@*">
  214.            <xsl:text> </xsl:text>
  215.         </xsl:if>
  216.         <xsl:apply-templates select="@*"/>
  217.         <SPAN class="m">
  218.            <xsl:text>></xsl:text>
  219.         </SPAN>
  220.         <SPAN class="t">
  221.            <xsl:value-of select="."/>
  222.         </SPAN>
  223.         <SPAN class="m"></</SPAN>
  224.         <SPAN class="en">
  225.            <xsl:value-of select="name(.)"/>
  226.         </SPAN>
  227.         <SPAN class="m">
  228.            <xsl:text>></xsl:text>
  229.         </SPAN>
  230.       </DIV>
  231.    </xsl:template>
  232.  
  233.    <xsl:template match="*[*]" priority="20">
  234.       <DIV class="e">
  235.          <DIV>
  236.             <SPAN class="b" onclick="click(event)">-</SPAN>
  237.             <SPAN class="m"><</SPAN>
  238.             <SPAN class="en">
  239.                <xsl:value-of select="name(.)"/>
  240.             </SPAN>
  241.             <xsl:if test="@*">
  242.                <xsl:text> </xsl:text>
  243.             </xsl:if>
  244.             <xsl:apply-templates select="@*"/>
  245.             <SPAN class="m">
  246.                <xsl:text>></xsl:text>
  247.             </SPAN>
  248.          </DIV>
  249.          <DIV>
  250.             <xsl:apply-templates/>
  251.             <DIV>
  252.                <SPAN class="m">
  253.                   <xsl:text></</xsl:text>
  254.                </SPAN>
  255.                <SPAN class="en">
  256.                   <xsl:value-of select="name(.)"/>
  257.                </SPAN>
  258.                <SPAN class="m">
  259.                   <xsl:text>></xsl:text>
  260.                </SPAN>
  261.             </DIV>
  262.          </DIV>
  263.       </DIV>
  264.    </xsl:template>
  265.  
  266. </xsl:stylesheet>
  267.