0

当我选中它并单击继续时,我有一个复选框,我想从 xml 文件中读取所有数据并将其放入表中,其中一列显示超链接,这将帮助用户添加或编辑数据以保存或更新。

单选按钮代码:

 <input type="radio" value="Yes" id="RBServer" name="radio4">Server</td>

当我单击继续时,我正在尝试读取 xslt 文件。代码如下:

Javascript如下:

var testRadio = document.getElementById('RBServer');
 if (testRadio.checked==true)
    {
        var style = new ActiveXObject("Microsoft.xmldom");
        style.async = false;
        style.load("Server.xslt");
        document.all.targetHTML.innerHTML = source.transformNode(style);
    }

我已经像这样创建了 Server.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" exclude-result-prefixes="msxsl">
    <xsl:output method="xml" indent="yes"/>

  <xsl:template match="/">
      <html>
        <body style="font-family:Helvetica Neue">
          <Div id="ListingScreen1">
            <table border="1" width="1024px" >
              <tr>
                <th>Server</th>
                <th>ID</th>           
              </tr>
              <xsl:choose>
                <xsl:when test="CATALOG/orderByTitle">
                  <xsl:apply-templates select="CATALOG/CD">
                    <!--<xsl:sort select="TITLE" />-->
                  </xsl:apply-templates>
                </xsl:when>
                <xsl:when test="CATALOG/orderByTitleDesc">
                  <xsl:apply-templates select="CATALOG/CD">
                    <!--<xsl:sort select="TITLE" order="ascending" />-->
                  </xsl:apply-templates>
                </xsl:when>
                <xsl:when test="CATALOG/orderByArtist">
                  <xsl:apply-templates select="CATALOG/CD">
                    <!--<xsl:sort select="ARTIST" />-->
                  </xsl:apply-templates>
                </xsl:when>
              </xsl:choose>
            </table>

          </Div>
        </body>
            </html>
        <!--<xsl:copy>
            <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>-->


    </xsl:template>

  <xsl:template match="CD">
    <tr>
      <td>
        <!--<xsl:value-of select="ID"/>-->
      </td>
      <td onclick="javascript:FillEditScreen(this.innerText);">
        <a href="javascript:void(0);">
          <p style="display:none;">
            <xsl:value-of select="Server"/>
          </p>
          <xsl:value-of select="ID"/>
        </a>
      </td>
    </tr>
  </xsl:template>
</xsl:stylesheet>

我的xml文件是这样的:Server.xml

<?xml version="1.0" encoding="utf-8"?>
<CATALOG>
  <orderByTitleDesc />
  <CD>
    <Server>KL12ACUC.CS.AD.KLMCORP.NET</Server>
    <ID>KL12ACUC.CS.AD.KLMCORP.NET</ID>
  </CD>
  <CD>
    <Server>basant112</Server>
    <ID>basant</ID>
  </CD>
</CATALOG>
4

0 回答 0