+ -
当前位置:首页 → 问答吧 → 同是ie5,xml transform的结果却万完不一样

同是ie5,xml transform的结果却万完不一样

时间:2004-04-15

来源:互联网

一台是win2000as+ie 5.0.3700(好象是)
就能正常
而另一台是win2000pr + ie5.0.310x版木。缺把xslt语法标识都显示出来了。没有transform。结果导致结果内容南圆北则
-------------------正缺的结果片段------------------
<TABLE cellSpacing=0 cellPadding=0 width="90%" border=0>
<TBODY>
<TR>
<TD class=pro-class onmouseover='show_submenu("43")' style="PADDING-RIGHT: 4px; PADDING-LEFT: 4px; PADDING-BOTTOM: 4px; CURSOR: hand; PADDING-TOP: 4px" onmouseout='&#9;hide_submenu("43")' align=right><SPAN class=font-14><B>扎把机系列 </B></SPAN>
<DIV class=menu_pro_div>
<DIV style="BORDER-TOP-WIDTH: 1px; BORDER-LEFT-WIDTH: 1px; Z-INDEX: 9; LEFT: -10px; BORDER-BOTTOM-WIDTH: 1px; POSITION: absolute; TOP: -26px; BORDER-RIGHT-WIDTH: 1px">
<TABLE id=submenu_43 style="DISPLAY: none; MARGIN-LEFT: 14px" cellSpacing=0 cellPadding=0 border=0>
<TBODY>
------------------------------------------
但其中多出了个"&#9;"不知为什么。但也不出错
------------------------------------------
----------------另一个ie板本transform的结果是-------------------------
TABLE border=0 cellPadding=0 cellSpacing=0 width=187>
<TBODY>
<TR>
<TD align=right height=24 style="CURSOR: hand"><xsl:attribute name="onclick">pro_show_menu('<xsl:value-of select="@id"></xsl:value-of>')</xsl:attribute> <xsl:choose><xsl:when test="@ico!=''"><IMG> <xsl:attribute name="src">pro_Pic/scopes_ico/<xsl:value-of select="@ico"></xsl:value-of></xsl:attribute> <xsl:attribute name="alt"><xsl:value-of select="@explain"></xsl:value-of></xsl:attribute></IMG></xsl:when><xsl:otherwise><SPAN class=scopes-title><xsl:value-of select="@explain"></xsl:value-of></SPAN></xsl:otherwise></xsl:choose>   </TD></TR>
---------------------------------------------
transform的结果是。并没有transform。它把xslt的内容都show出来了
***************************************************
我的问提是
***********原文件pro_menu.xml*************
<?xml version="1.0" encoding="gb2312"?>
<Root>
        <scopes id="2" explain="金融办公自动化" hide="False" ico="s_2_ico.gif">
                <class id="44" explain="其它" hide="True">
</class>
                <class id="43" explain="扎把机系列" hide="False">
                        <pro id="56" serial="JL030" name="全自动扎把机" Y_service="False" Y_specific="False" specific_url=""/>
                        <pro id="55" serial="JL028" name="全自动扎把机" Y_service="False" Y_specific="False" specific_url=""/>
                        <pro id="49" serial="JL019" name="全自动扎把机" Y_service="False" Y_specific="False" specific_url=""/>
                </class>
                <class id="42" explain="点钞机系列" hide="False">
                        <pro id="54" serial="JL201A" name="全兼容鉴伪点钞机" Y_service="False" Y_specific="False" specific_url=""/>
                        <pro id="51" serial="JL201E" name="全兼容鉴伪点钞机" Y_service="False" Y_specific="False" specific_url=""/>
                </class>
                <class id="41" explain="捆钞机系列" hide="False">
                        <pro id="50" serial="JL106" name="自动捆钞机" Y_service="False" Y_specific="False" specific_url=""/>
                        <pro id="48" serial="JL101-15" name="全自动捆钞机" Y_service="False" Y_specific="False" specific_url=""/>
                        <pro id="47" serial="JL101A" name="全自动捆钞机" Y_service="False" Y_specific="False" specific_url=""/>
                </class>
        </scopes>
        <scopes id="3" explain="工业过程自动化" hide="False" ico="">
                <class id="26" explain="太格IV日文" hide="True">
                        <pro id="29" serial="asdfxcfzxc" name="vsadfasdf" Y_service="False" Y_specific="False" specific_url=""/>
                        <pro id="23" serial="asdfasdf" name="asdfasdf" Y_service="False" Y_specific="False" specific_url=""/>
                        <pro id="16" serial="001" name="kunchaoji" Y_service="True" Y_specific="False" specific_url=""/>
                </class>
                <class id="17" explain="xxxxssss" hide="False">
                        <pro id="14" serial="110000000001122" name="点钞机" Y_service="False" Y_specific="False" specific_url=""/>
                </class>
                <class id="16" explain="345213452345" hide="False">
</class>
                <class id="14" explain="asdfasdf" hide="False">
                        <pro id="21" serial="asdfasdf" name="asdfasdf" Y_service="False" Y_specific="False" specific_url=""/>
                </class>
                <class id="11" explain="波丝王子:时之沙" hide="False">
</class>
                <class id="7" explain="没目录" hide="False">
</class>
        </scopes>
        <scopes id="8" explain="数字医疗" hide="False" ico="">
                <class id="46" explain="微波热灌注循环治疗机" hide="False">
                        <pro id="57" serial="JL-600" name="微波热灌注循环治疗机" Y_service="False" Y_specific="False" specific_url=""/>
                </class>
                <class id="25" explain="港式按摩" hide="True">
                        <pro id="27" serial="222" name="2222" Y_service="False" Y_specific="False" specific_url=""/>
                </class>
                <class id="24" explain="足疗" hide="False">
</class>
                <class id="23" explain="保健按摩" hide="False">
                        <pro id="17" serial="002" name="00002" Y_service="False" Y_specific="True" specific_url="zx"/>
                        <pro id="1" serial="asdf" name="asdf" Y_service="True" Y_specific="True" specific_url="asdf"/>
                </class>
                <class id="6" explain="fffff" hide="False">
</class>
                <class id="5" explain="C-C将军" hide="False">
                        <pro id="26" serial="342342" name="324234234" Y_service="False" Y_specific="False" specific_url=""/>
                </class>
        </scopes>
        <scopes id="10" explain="药剂残留检测" hide="False" ico="">
                <class id="30" explain="2342342323" hide="False">
                        <pro id="32" serial="爱情八啦啦" name="爱情八啦啦" Y_service="True" Y_specific="False" specific_url=""/>
                </class>
                <class id="29" explain="asdfasdf" hide="False">
</class>
        </scopes>
</Root>
*******************原文件pro_menu.xslt***************
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
        <xsl:output method="xml" encoding="gb2312"/>
        <xsl:template match="Root">

                <input id="default_scopes" name="default_scopes" type="hidden">
                        <xsl:attribute name="value">
                                <xsl:value-of select="//Root/scopes/@id[position()=1]"/>
                        </xsl:attribute>
                </input>
                <xsl:apply-templates select="scopes"/>

        </xsl:template>

        <xsl:template match="scopes">
                <xsl:if test="class">
                        <xsl:choose>
                                <xsl:when test="@hide='False'">
                                        <table width="187" border="0" cellspacing="0" cellpadding="0">
                                                <tr>
                                                        <td align="right" height="24" style="cursor: hand;">
                                                                <xsl:attribute name="onclick">pro_show_menu('<xsl:value-of select="@id"/>')</xsl:attribute>
                                                                <xsl:choose>
                                                                        <xsl:when test="@ico!=''">
                                                                                <img>
                                                                                        <xsl:attribute name="src">pro_Pic/scopes_ico/<xsl:value-of select="@ico"/></xsl:attribute>
                                                                                        <xsl:attribute name="alt"><xsl:value-of select="@explain"/></xsl:attribute>
                                                                                </img>
                                                                        </xsl:when>
                                                                        <xsl:otherwise>
                                                                                <span class="scopes-title">
                                                                                                <xsl:value-of select="@explain"/>               
                                                                                </span>
                                                                        </xsl:otherwise>
                                                                </xsl:choose>  
                                </td>
                                                </tr>
                                                <tr>
                                                        <td>
                                                                <img src="../images/proMenu_12.gif" width="187" height="2"/>
                                                        </td>
                                                </tr>
                                                <tr>
                                                        <td background="../images/proMenu_d.gif" style="display:none">
                                                                <xsl:attribute name="id">menu_<xsl:value-of select="@id"/></xsl:attribute>
                                                                <xsl:attribute name="obj">menuTd<xsl:value-of select="@id"/></xsl:attribute>
                                                                <xsl:if test="class">
                                                                        <table width="90%" border="0" cellpadding="0" cellspacing="0">
                                                                                <xsl:apply-templates select="class"/>
                                                                                <tr>
                                                                                        <td>
                                                                                                <img src="../images/proMenu_12.gif" width="187" height="2" alt=""/>
                                                                                        </td>
                                                                                </tr>
                                                                        </table>
                                                                </xsl:if>
                                                        </td>
                                                </tr>
                                        </table>
                                </xsl:when>
                                <xsl:when test="@hide='True'">
                                        <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                                <tr>
                                                        <td>
                                                                <img src="../images/proMenu_12.gif" width="187" height="2" alt=""/>
                                                        </td>
                                                </tr>
                                                <tr>
                                                        <td background="../images/proMenu_d.gif">
                                                                <xsl:if test="class">
                                                                        <table width="90%" border="0" cellpadding="0" cellspacing="0">
                                                                                <xsl:apply-templates select="class"/>
                                                                                <tr>
                                                                                        <td>
                                                                                                <img src="../images/proMenu_12.gif" width="187" height="2" alt=""/>
                                                                                        </td>
                                                                                </tr>
                                                                        </table>
                                                                </xsl:if>
                                                        </td>
                                                </tr>
                                                <tr>
                                                        <td>
                                                                <img src="../images/proMenu_12.gif" width="187" height="2" alt=""/>
                                                        </td>
                                                </tr>
                                        </table>
                                </xsl:when>
                        </xsl:choose>
                </xsl:if>
        </xsl:template>
        <xsl:template match="class">
                <xsl:if test="pro">
                        <xsl:choose>
                                <xsl:when test="@hide='False'">
                                        <tr>
                                                <td align="right" style="padding:4px;cursor:hand" class="pro-class">
                                                        <xsl:attribute name="onmouseover">show_submenu("<xsl:value-of select="@id"/>")</xsl:attribute><xsl:attribute name="onmouseout">        hide_submenu("<xsl:value-of select="@id"/>")</xsl:attribute>
                                                        <span class="font-14">
                                                                <b><xsl:value-of select="@explain"/> </b>
                                                        </span>
                                                        <div class="menu_pro_div">
                                                                <div style="position:absolute; z-index:9; left: -10px; top: -26px; border: 1px side #000000;">
                                                                        <table cellspacing="0" cellpadding="0" style="margin-left:14px;display:none" border="0"><xsl:attribute name="id">submenu_<xsl:value-of select="@id"/></xsl:attribute><tbody>
                                                                                  <tr>
    <td width="2" height="5"><img src="../images/sub_tab_03.gif" width="2" height="5" alt=""/></td>
    <td background="../images/sub_tab_05.gif"></td>
    <td width="4"><img src="../images/sub_tab_06.gif" width="4" height="5" alt=""/></td>
  </tr>
  <tr>
    <td background="../images/sub_tab_08.gif"></td>
    <td bgcolor="#EDEDED">
                            <table border="0" width="100" cellspacing="0" cellpadding="0">
                                        <tbody>
                                        <tr>
                                                <td background="../images/1X3_1X2.gif" height="1"></td>
                                        </tr>
                                                        <xsl:apply-templates select="pro"/>

                                        </tbody>
                                </table></td>
    <td background="../images/sub_tab_10.gif"></td>
  </tr>
  <tr>
    <td width="2" height="5"><img src="../images/sub_tab_13.gif" width="2" height="5" alt=""/></td>
    <td background="../images/sub_tab_14.gif"></td>
    <td><img src="../images/sub_tab_15.gif" width="4" height="5" alt=""/></td>
  </tr>

                                                                               

                                                                                                       

                                                                                </tbody>
                                                                        </table>
                                                                </div>
                                                        </div>
                                                </td>
                                        </tr>
                                </xsl:when>
                                <xsl:when test="@hide='True'">
                                        <xsl:for-each select="pro">
                                                <tr>
                                                        <td style="padding:4px;cursor:hand" class="pro-class" align="right">
                <a>
                <xsl:choose>
                        <xsl:when test="@Y_specific='True'">
                                <xsl:attribute name="href"><xsl:value-of select="@specific_url"/>                                                </xsl:attribute>
                                <xsl:value-of select="@serial"/>
                        </xsl:when>
                        <xsl:when test="@Y_specific='False'">
                                <xsl:attribute name="href">product_view.asp?parem=<xsl:value-of select="@id"/>&scopes_sn=<xsl:value-of select="../../@id"/></xsl:attribute>
                                <xsl:value-of select="@serial"/>
                        </xsl:when>
                </xsl:choose>
                </a> 
                                                        </td>
                                                </tr>
                                        </xsl:for-each>
                                </xsl:when>
                        </xsl:choose>
                        <tr>
                                <td height="1" align="right">
                                        <table width="80%" border="0" cellpadding="0" cellspacing="0">
                                                <tbody>
                                                        <tr>
                                                                <td background="../images/1X3_1X2.gif" height="1"/>
                                                        </tr>
                                                </tbody>
                                        </table>
                                </td>
                        </tr>
                </xsl:if>
        </xsl:template>
        <xsl:template match="pro">
        <tr class="rowChange" change_bgcolor="#ffffff">
                <td> 
                <a><xsl:choose>
                        <xsl:when test="@Y_specific='True'">
                                <xsl:attribute name="href"><xsl:value-of select="@specific_url"/>                                                </xsl:attribute>
                                <xsl:value-of select="@serial"/>
                        </xsl:when>
                        <xsl:when test="@Y_specific='False'">
                                <xsl:attribute name="href">product_view.asp?parem=<xsl:value-of select="@id"/>&scopes_sn=<xsl:value-of select="../../@id"/></xsl:attribute>
                                <xsl:value-of select="@serial"/>
                        </xsl:when>
                </xsl:choose>
                </a>
                </td>
        </tr>
                                        <tr>
                                                <td background="../images/1X3_1X2.gif" height="1"></td>
                                        </tr>
        </xsl:template>
</xsl:stylesheet>
******************原文件js**************
        var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
        xmlDoc.async = "false";
        xmlDoc.load("pro_menu.xml");
        xmlroot=xmlDoc.documentElement;
       
        var xsltDoc = new ActiveXObject("Microsoft.XMLDOM");
        xsltDoc.async = "false";
        xsltDoc.load("pro_menu.xslt");
        xmlDoc.transformNode(xsltDoc)
        document.all("xmlMenuDiv").innerHTML = xmlDoc.transformNode(xsltDoc)
********************************
同是ie5,它的兼容性快要把我搞死了
后来。我想在server端transform。我在asp的后台程序中:

transformNodeToObject xsl,outxml
xml.save(outxml)的方法,得到的文件是空的
又用
Set outfile = xml.transformNode(xsl)
filesystemobject
file.write(outfile)的方法。写到文件时。内容是有了可是文件是unicode码
asp的include不支持!!!!!!!!!!!!!!!!!!!
救我!hlep me!!

作者: windbell   发布时间: 2004-04-15

在运行xml.transformNode(xsl)时候确实好像有些字符会被转化为转义字符,
我早上刚好在做一个xml的Loading,也遇到类似的情况,但没有碰到出现&#9;的,只出现了&lt;与&gt;,解决方法是
var outfile = xml.transformNode(xsl).replace(/&lt;/ig,"<").replace(/&gt;/ig,">");
//JavaScript

作者: 泣红亭   发布时间: 2004-04-19

如果不想在结果中出现被转义的咚咚,特别是脚本这类东西,可以用
<xsl:text
  disable-output-escaping = "yes" | "no">
</xsl:text>
Default is "no". If the value is "yes", a text node generated by instantiating the <xsl:text> element will be output without any escaping. For example, the following generates the single character "<".
<xsl:text disable-output-escaping="yes"><</xsl:text>


详细东西可以参考msdn
ms-help://MS.MSDNQTR.2003FEB.2052/xmlsdk/htm/xsl_elm_qz_5sl0.htm

作者: HLa   发布时间: 2004-05-16

<xsl:attribute name="onmouseover">  show_submenu("<xsl:value-of select="@id"/>")</xsl:attribute><xsl:attribute name="onmouseout">    hide_submenu("<xsl:value-of select="@id"/>")</xsl:attribute>
在函数开始的空是什么东西,看看自己的源代码,删除掉先了

作者: HLa   发布时间: 2004-05-16