錯在哪里?你直接COPY這兩個文件瀏覽試試﹐我瀏覽得很正常﹐用Validate XML檢測也正確

解决方案 »

  1.   

    那可能是你的環境不支持﹐我瀏覽的結果是這樣﹐轉換為HTML<select>
    <option value="1">1one
    </option>
    <option value="2">2two
    </option>
    </select>
    <table>
    <th>編號</th><th>名稱</th>
    <tr><td>942</td>
    <td>aaa</td></tr>
    <tr><td>943</td>
    <td>bbb</td></tr>
    </table>
      

  2.   

    <?xml version="1.0" encoding="big5"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
    <xsl:template match="/">
    <script>
    function selChange(x){           
             stylesheet=document.XSLDocument;                
             source=document.XMLDocument;                
            
             sortField=stylesheet.selectNodes("//@test");                
         sortField[0].value=".[@area_id="+x+"]";                    
         qswh.innerHTML=(source.documentElement.transformNode(stylesheet));
            }      </script>
      <select onchange="selChange(value)">
        <xsl:for-each select="phone">
    <xsl:apply-templates/>
    </xsl:for-each>
      </select>
    <div id="qswh">
      <xsl:apply-templates/>
    </div>
    </xsl:template>

    <xsl:template match="phone">
    <table>
    <th>編號</th><th>名稱</th>
    <xsl:for-each select="//area">
    <xsl:if test=".[@area_id=1]">
    <xsl:apply-templates />
    </xsl:if>
    </xsl:for-each>
    </table>
    </xsl:template>

    <xsl:template match="area">
       <option>
        <xsl:attribute name="value">
          <xsl:value-of select="@area_id" />
        </xsl:attribute>
        <xsl:value-of select="@area_id" />
    <xsl:value-of select="@area_name" />
       </option>
    </xsl:template> <xsl:template match="fact">
    <tr><td><xsl:value-of select="@fact_id" /></td>
    <td><xsl:value-of select="@fact_name" /></td></tr>
    </xsl:template>
    </xsl:stylesheet>