免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 4884 | 回复: 12
打印 上一主题 下一主题

html文件(用了xml+xslt)放在linux的apache下,通过IE浏览不能显示 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-07-08 08:33 |只看该作者 |倒序浏览
为什么我把html文件放在linux环境的apache下面,我通过IE浏览有错误,不能显示.这个html放在window下面,用IE浏览是好的.这个html用到了xml和xsl.
//test-IndexView.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">;

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">;

        <head>;
                <link rel="stylesheet" type="text/css" href="capture-css.css"/>;
                <script src="LoadXML.js">;</script>;
        </head>;

        <body>;
       
                <div id="IDOutputHTML" />;

                <script>;
                        // Update the tree and dump frames
                        function RefreshViews(Number)
                        {
                                // shows and sorts selected packet
                                window.parent.frames[0].LightPacket(Number);

                                // shows the tree view
                                window.parent.frames[1].LoadPacketTree(Number);

                                // shows the dump view
                                window.parent.frames[2].LoadPacketDump(Number,1,0);
                        }

                        function LightPacket(Number)
                        {
                                //DisplayTransformedXML(Number, "test-psml.xml", "XslIndex.xsl";
                                DisplayTransformedXML(Number, "0624-s.xml", "XslIndex.xsl";
                        }

                        LightPacket(1);

                </script>;
        </body>;
</html>;
///////LoadXML.js

        function DisplayTransformedXML(Number, XMLFile, XSLFile)
        {
        BrowserName = navigator.appName;
        Version = navigator.appVersion;                // Version is not used in the following code

                if (BrowserName == "Netscape"
                {
                var XMLHTTPRequest;
                var XSLStyleSheet;
                var XSLProcessor;
                var XMLSource;

                        // Load the XML source file
                        XMLHTTPRequest = new XMLHttpRequest();
                        XMLHTTPRequest.open("GET", XMLFile, false);
                        XMLHTTPRequest.send(null);
                        XMLSource = XMLHTTPRequest.responseXML;

                        // Load the XSL style sheet
                        XMLHTTPRequest = new XMLHttpRequest();
                        XMLHTTPRequest.open("GET", XSLFile, false);
                        XMLHTTPRequest.send(null);
                        XSLStyleSheet = XMLHTTPRequest.responseXML;

                        // Instantiate the XSLT processor and associate a XSL style sheet with it
                        XSLProcessor= new XSLTProcessor();
                        XSLProcessor.importStylesheet(XSLStyleSheet);

                        /* Code needed to debug some XML object in Mozilla */
                        // var Serializer= new XMLSerializer();
                        // window.alert( Serializer.serializeToString( xslStylesheet ) );
                        /* End code needed to debug some XML object in Mozilla */


                        // Set an optional parameter to the style sheet
                        XSLProcessor.setParameter(null, "selected_packet", Number);

                        // Transform the XML source according to the appropriate style sheet
                        var XMLDOMFragment = XSLProcessor.transformToFragment(XMLSource, document);
                        document.getElementById("IDOutputHTML".innerHTML = "";

                        // Print the result of the transformation into the appropriate element into the HTML page
                        document.getElementById("IDOutputHTML".appendChild(XMLDOMFragment);
                }
                else if (BrowserName == "Microsoft Internet Explorer"
                {
                var XSLStyleSheet;
                var XMLSource;
                var XSLTemplate;
                var XSLProcessor;

                        // Load the XML source file
                        XMLSource = new ActiveXObject("Msxml2.DOMDocument";
                        XMLSource.async = false;
                        XMLSource.resolveExternals = false;
                        XMLSource.load(XMLFile);

                        // Load the XSL style sheet
                        var XSLStyleSheet= new ActiveXObject("Msxml2.FreeThreadedDOMDocument";
                        XSLStyleSheet.load(XSLFile);

                        // We cannot use the following lines, because templates must be created as 'FreeThreadedDOMDocument'
                        // In case we do not want to set parameters to the style sheet, we can use the code below and skip the rest
                        // XSLStyleSheet= document.getElementById("IDStyleSheet";
                        // XSLStyleSheet.async = false;
                        // XSLStyleSheet.resolveExternals = false;
                        // IDOutputHTML.innerHTML= source.transformNode(XSLStyleSheet);                // This line works only in IE; the next one is equivalent and it works also in Mozilla
                        // document.getElementById("IDOutputHTML".innerHTML= XMLSource.transformNode(XSLStyleSheet);

                        XSLStyleSheet.async = false;
                        XSLStyleSheet.resolveExternals = false;

                        // Instantiate the XSLT processor and associate a XSL style sheet with it
                        XSLTemplate= new ActiveXObject("Msxml2.XSLTemplate");
                        XSLTemplate.stylesheet= XSLStyleSheet;
                        XSLProcessor= XSLTemplate.createProcessor();
                        XSLProcessor.input = XMLSource;

                        // Set an optional parameter to the style sheet
                        XSLProcessor.addParameter("selected_packet", Number);

                       
                        // Transform the XML source according to the appropriate style sheet
                        XSLProcessor.transform();

                        // Print the result of the transformation into the appropriate element into the HTML page
                        document.getElementById("IDOutputHTML").innerHTML= XSLProcessor.output;
                }
        }
///////capture-css.css
body,tbody
{
        font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;
        white-space: nowrap;
}

table
{
        border-collapse: collapse;
}

th
{
        font-size: 0.7em;
        text-align: left;
        vertical-align: top;
        background-color: silver;
}

td
{
        font-size: 0.7em;
        text-align: left;
        vertical-align: top;
}

pre
{
        /* this is a bit big because otherwise Mozilla displays it rather small */
        font-size: 1.2em;
}


/* Formatting for the summary view */
.IndexSelected  {background-color:lime; }


/* Formatting for the tree view */
.directory p { font-size: 0.7em; margin: 0px; white-space: nowrap; }
.directory img { vertical-align: middle; }
.directory div { display: none; margin: 0px; }

.TreeProto {  /*font-weight:bold;*/ }
.TreeField {  }


/* Formatting for the dump view */
.DumpSelected {color:red; font-weight:bold;}
.DumpNormal {color:black }
.DumpTest {color:#eeeeee }

/////XslIndex.xsl
<?xml version="1.0" encoding="UTF-8"?>;

<xsl:stylesheet version="1.0" xmlnssl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">;
<xslutput method="html" omit-xml-declaration="no" indent="yes"/>;


<xsl:param name="selected_packet" select="'1'"/>;

<!-- This stylesheet does not work when the capture was generated after copying/cutting elements, because -->;
<!-- the value in the PSML file does not match the position in the PDML file. -->;

<xsl:template match="/">;
        <html>;
                <head>;
                        <link rel="stylesheet" type="text/css" href="capture-css.css"/>;
                </head>;
                <body>;
                        <table border="1">;
                                <xsl:apply-templates/>;
                        </table>;
                </body>;
        </html>;
</xsl:template>;


<xsl:template match="structure">;
        <tr>;
                <xsl:for-each select="section">;
                        <th>;
                                <xsl:value-of select="." />;
                        </th>;
                </xsl:for-each>;
        </tr>;
</xsl:template>;


<xsl:template match="packet">;

        <!-- Save the position of the current packet into the 'num' variable -->;
        <xsl:variable name="num" select="section" />;

        <xsl:choose>;

                <xsl:when test="section= $selected_packet">;

                        <tr class="IndexSelected">;

                                <xsl:for-each select="section">;
                                        <td>;
       
                                                <xsl:if test="position()=1">;
                                                        <img src="pktindex.png"/>;
                                                </xsl:if>;
       
                                                <xsl:value-of select="."/>;
                                        </td>;
                                </xsl:for-each>;
                        </tr>;
                </xsl:when>;

                <xsltherwise>;

                        <tr onClick="RefreshViews({$num})">;

                                <xsl:for-each select="section">;
                                        <td>;
<!--
        This code should print a 'no break space' in all the cells
        However, it does not work in IE6, while it works perfectly well in Xalan.
        No idea why
-->;
<!--
                                            <xsl:text disable-output-escaping="yes">;&amp;nbps;</xsl:text>;
-->;
                                                <xsl:if test="position()=1">;
                                                        <img src="pktindex.png"/>;
                                                </xsl:if>;

                                                <xsl:value-of select="."/>;
                                        </td>;
                                </xsl:for-each>;
                        </tr>;
                </xsltherwise>;
        </xsl:choose>;

</xsl:template>;


</xsl:stylesheet>;
test-psml.xml如下:
<?xml version="1.0" encoding="utf-8" ?>;
<psml  version="0"  creator="NetBee Packet Decoding Engine"  dissectors="04-jan-2004">;
<structure>;
<section>;N.</section>;
<section>;Time</section>;
<section>;Data Link</section>;
<section>;Network</section>;
<section>;Transport</section>;
<section>;Application</section>;
</structure>;
<packet>;
<section>;1</section>;
<section>;22:04:01.207911</section>;
<section>;Eth: 000B5D-20CD02 =>; FFFFFF-FFFFFF</section>;
<section>;IP: 0.0.0.0 =>; 255.255.255.255 (Len 351)</section>;
<section>;UDP: Port 68 =>; 67</section>;
<section>;DHCP Request: Transaction ID 3462696297 DHCP Request</section>;
</packet>;
<packet>;
<section>;2</section>;
<section>;22:04:01.215198</section>;
<section>;Eth: 00095B-2D759A =>; FFFFFF-FFFFFF</section>;
<section>;ARP Request: who has 192.168.0.2 tell 192.168.0.1</section>;
<section>;</section>;
<section>;Data</section>;
</packet>;
<packet>;
<section>;3</section>;
<section>;22:04:01.332685</section>;
<section>;Eth: 00095B-2D759A =>; FFFFFF-FFFFFF</section>;
<section>;IP: 192.168.0.1 =>; 255.255.255.255 (Len 576)</section>;
<section>;UDP: Port 67 =>; 68</section>;
<section>;DHCP Reply: Transaction ID 3462696297 DHCP Acknowledgement</section>;
</packet>;
<packet>;
<section>;4</section>;
<section>;22:04:01.337146</section>;
<section>;Eth: 000B5D-20CD02 =>; FFFFFF-FFFFFF</section>;
<section>;ARP Request: who has 192.168.0.2 tell 192.168.0.2</section>;
<section>;</section>;
<section>;</section>;
</packet>;
</psml>;

论坛徽章:
0
2 [报告]
发表于 2004-07-08 09:59 |只看该作者

html文件(用了xml+xslt)放在linux的apache下,通过IE浏览不能显示

你XML用什麽格式的,最好UTF-8

论坛徽章:
0
3 [报告]
发表于 2004-07-08 10:49 |只看该作者

html文件(用了xml+xslt)放在linux的apache下,通过IE浏览不能显示

我的使用utf8的啊

论坛徽章:
0
4 [报告]
发表于 2004-07-08 18:02 |只看该作者

html文件(用了xml+xslt)放在linux的apache下,通过IE浏览不能显示

测试吧

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
5 [报告]
发表于 2004-07-08 19:36 |只看该作者

html文件(用了xml+xslt)放在linux的apache下,通过IE浏览不能显示

什么叫做不能浏览?

其实你可以一步步调试你的问题的。

先把文件简单化,然后再来一步不复杂

论坛徽章:
0
6 [报告]
发表于 2004-07-08 21:23 |只看该作者

html文件(用了xml+xslt)放在linux的apache下,通过IE浏览不能显示

我想问题的关键不是程序问题.因为我直接打开test.html是可以的.然后我把这个文件放到web服务器上(IIS或apache下),通过地址访问这test.html,却会报错.现在我把文件传来来.大家可以帮我试试看,怎么不能上传附件的啊

论坛徽章:
0
7 [报告]
发表于 2004-07-08 23:01 |只看该作者

html文件(用了xml+xslt)放在linux的apache下,通过IE浏览不能显示

你在提问前不会看看apache的日志先?

说了这么大一堆还不如把log上的错误信息贴上来~

解决问题首先要回分析问题!

论坛徽章:
0
8 [报告]
发表于 2004-07-09 10:06 |只看该作者

html文件(用了xml+xslt)放在linux的apache下,通过IE浏览不能显示

好,access_log的部分日志如下:
178.100.101.225 - - [08/Jul/2004:17:12:05 +0800] "GET /icons/blank.gif HTTP/1.1" 304 -
178.100.101.225 - - [08/Jul/2004:17:12:05 +0800] "GET /icons/back.gif HTTP/1.1" 304 -
178.100.101.225 - - [08/Jul/2004:17:12:05 +0800] "GET /icons/unknown.gif HTTP/1.1" 304 -
178.100.101.225 - - [08/Jul/2004:17:12:05 +0800] "GET /icons/image2.gif HTTP/1.1" 304 -
178.100.101.225 - - [08/Jul/2004:17:12:05 +0800] "GET /icons/text.gif HTTP/1.1" 304 -
178.100.101.225 - - [08/Jul/2004:17:12:08 +0800] "GET /pdml3/test.html HTTP/1.1" 304 -
178.100.101.225 - - [08/Jul/2004:17:12:08 +0800] "GET /pdml3/test-IndexView.html HTTP/1.1" 30
178.100.101.225 - - [08/Jul/2004:17:12:08 +0800] "GET /pdml3/test-TreeView.html HTTP/1.1" 304
178.100.101.225 - - [08/Jul/2004:17:12:08 +0800] "GET /pdml3/test-DumpView.html HTTP/1.1" 304
178.100.101.225 - - [08/Jul/2004:17:12:08 +0800] "GET /pdml3/capture-css.css HTTP/1.1" 304 -
178.100.101.225 - - [08/Jul/2004:17:12:08 +0800] "GET /pdml3/LoadXML.js HTTP/1.1" 304 -
178.100.101.225 - - [08/Jul/2004:17:12:08 +0800] "GET /pdml3/0624-d.xml HTTP/1.1" 304 -
178.100.101.225 - - [08/Jul/2004:17:12:09 +0800] "GET /pdml3/0624-s.xml HTTP/1.1" 304 -
178.100.101.225 - - [08/Jul/2004:17:12:09 +0800] "GET /pdml3/XslIndex.xsl HTTP/1.1" 304 -
178.100.101.225 - - [08/Jul/2004:17:12:09 +0800] "GET /pdml3/0624-d.xml HTTP/1.1" 304 -
178.100.101.225 - - [08/Jul/2004:17:12:09 +0800] "GET /pdml3/XslTree.xsl HTTP/1.1" 304 -
178.100.101.225 - - [09/Jul/2004:08:51:18 +0800] "GET / HTTP/1.1" 200 1018
178.100.101.225 - - [09/Jul/2004:08:51:18 +0800] "GET /apache_pb.gif HTTP/1.1" 304 -
178.100.101.225 - - [09/Jul/2004:08:51:23 +0800] "GET /pdml3/test.html HTTP/1.1" 304 -
178.100.101.225 - - [09/Jul/2004:08:51:23 +0800] "GET /pdml3/test-IndexView.html HTTP/1.1" 30
178.100.101.225 - - [09/Jul/2004:08:51:23 +0800] "GET /pdml3/test-TreeView.html HTTP/1.1" 304
178.100.101.225 - - [09/Jul/2004:08:51:23 +0800] "GET /pdml3/test-DumpView.html HTTP/1.1" 304
178.100.101.225 - - [09/Jul/2004:08:51:23 +0800] "GET /pdml3/capture-css.css HTTP/1.1" 304 -
178.100.101.225 - - [09/Jul/2004:08:51:23 +0800] "GET /pdml3/LoadXML.js HTTP/1.1" 304 -
178.100.101.225 - - [09/Jul/2004:08:51:23 +0800] "GET /pdml3/0624-d.xml HTTP/1.1" 200 465383
178.100.101.225 - - [09/Jul/2004:08:51:24 +0800] "GET /pdml3/XslTree.xsl HTTP/1.1" 200 10944
178.100.101.225 - - [09/Jul/2004:08:51:24 +0800] "GET /pdml3/0624-s.xml HTTP/1.1" 200 11264
178.100.101.225 - - [09/Jul/2004:08:51:24 +0800] "GET /pdml3/XslIndex.xsl HTTP/1.1" 200 1997
178.100.101.225 - - [09/Jul/2004:08:51:24 +0800] "GET /pdml3/0624-d.xml HTTP/1.1" 200 465383
--------------
error_log为空

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
9 [报告]
发表于 2004-07-09 14:43 |只看该作者

html文件(用了xml+xslt)放在linux的apache下,通过IE浏览不能显示

内容太多了,不知道什么原应,都说了,线索小范围,然后再扩大。

论坛徽章:
1
技术图书徽章
日期:2013-12-05 23:25:45
10 [报告]
发表于 2004-07-09 14:44 |只看该作者

html文件(用了xml+xslt)放在linux的apache下,通过IE浏览不能显示

内容太多了,不知道什么原应,都说了,先缩小范围,然后再扩大。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP