选择xsl中的下拉值

时间:2011-09-22 04:58:10

标签: xslt

如何选择下拉值?每当我在xsl的下拉列表中选择一些值时,我都试图显示一些数据。例如,如果在下拉列表中选择了A,则与A相关的详细信息将显示在表格中。同样,如果选择B,则仅显示与B相关的详细信息。我需要在xslt中编写一行代码来选择if语句中的下拉值。

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet  version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="/">
    <html>
      <head>
        <title>VPGate Media Mixer</title>
        <meta http-equiv="expires" content="0"/>
        <meta http-equiv="pragma" content="no-cache"/>
        <meta http-equiv="cache-control" content="no-cache, must-revalidate"/>
        <meta http-equiv="refresh" content="15"></meta>
        <script src="/Common/common.js\" type="text/javascript"></script>
        <link rel="stylesheet" type="text/css" href="style001.css" />
        <link rel="stylesheet" type="text/css" href="Grid.Default.css" />
      </head>
      <body class="WorkArea">
        <div class="divSummaryHeader" id="SummaryHeader">
          <h1>Media Mixer - VPGate</h1>         
        </div>

        &#160;
        <div class="RadGrid RadGrid_Default" id="SummaryData" style="position:absolute;width:828px;height:510px;overflow:auto">
          <table border="0" class="rgMasterTable rgClipCells" cellspacing="0" cellpadding="0" >
            <tr>
              <input type="button" class="formEditBtn" id="SubBtn" value="Refresh" onclick="window.location=window.location;"/> 
            </tr>
            <tr>
              <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;" colspan="2">Conference Summary</td>
            </tr>
            <tr>
              <td>
                <table border="0" class="rgMasterTable rgClipCells" cellspacing="0" cellpadding="0"  >
                  <tr>
                    <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Conference Name</td>
                    <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Conference ID</td>
                    <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Composite Address</td>
                    <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Composite Port</td>
                    <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Composite Ssrc</td>
                    <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">No Of Participants</td>
                  </tr>
                  <xsl:if test="MediaMixer!= ''">
                    <xsl:for-each select="MediaMixer/Conference">
                      <!--<xsl:sort select="Name"/>-->
                      <xsl:if test="Name !=''">
                        <xsl:if test="(position() mod 2 = 0)">
                          <tr class="rgAltRow SummaryTableDataRow">
                            <td valign = "top">
                              <xsl:value-of select="Name"/>
                            </td>
                            <td valign = "top">
                              <xsl:value-of select="ConfId"/>
                            </td>
                            <td valign = "top">
                              <xsl:value-of select="CompositeAddress"/>
                            </td>
                            <td valign = "top">
                              <xsl:value-of select="CompositePort"/>
                            </td>
                            <td valign = "top">
                              <xsl:value-of select="CompositeSsrc"/>
                            </td>
                            <td valign = "top">
                              <xsl:value-of select="NoOfParticipants"/>
                            </td>
                          </tr>
                        </xsl:if>
                        <xsl:if test="(position() mod 2 = 1)">
                          <td>
                            <tr class="rgRow SummaryTableDataRow">
                              <td valign = "top">
                                <xsl:value-of select="Name"/>
                              </td>
                              <td valign = "top">
                                <xsl:value-of select="ConfId"/>
                              </td>
                              <td valign = "top">
                                <xsl:value-of select="CompositeAddress"/>
                              </td>
                              <td valign = "top">
                                <xsl:value-of select="CompositePort"/>
                              </td>
                              <td valign = "top">
                                <xsl:value-of select="CompositeSsrc"/>
                              </td>
                              <td valign = "top">
                                <xsl:value-of select="NoOfParticipants"/>
                              </td>
                            </tr>
                          </td>
                        </xsl:if>
                      </xsl:if>
                    </xsl:for-each>
                  </xsl:if>
                  <xsl:if test="MediaMixer = ''">
                    <td valign = "top">
                      <xsl:text>No Data </xsl:text>
                    </td>
                  </xsl:if>
                </table>
              </td>
            </tr>
          </table>
          &#160;

          <div align="center">
            <b> Please select a Conference Name :</b>
            &#160;
            <select name="combo" id="combo">
              <xsl:for-each select="MediaMixer/Conference">
                <option>
                  <xsl:value-of select="Name"/>
                </option>
              </xsl:for-each>
            </select>
          </div>




          <script type="text/C#" runat="server">

          </script>



            <table border="0" class="rgMasterTable rgClipCells" cellspacing="1" cellpadding="1">
            <tr>
              <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;" colspan="2">Conference Details</td>
            </tr>

            <tr>
              <td>
                <table border="0" class="rgMasterTable rgClipCells" cellspacing="0" cellpadding="0" >
                  <tr>
                    <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Conference Name</td>
                    <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Conference ID</td>
                    <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Participant ID 1</td>
                    <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Participant ID 2</td>
                    <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Participant Address</td>
                    <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">Participant Listening Port</td>
                    <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">MM Listening Port</td>
                    <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">SSRC From Participant</td>
                    <td class="rgHeader SummaryTableHdrRow" style="font-weight:bold;">SSRC From MM</td>
                  </tr>
                  <xsl:if test="MediaMixer!= ''">
                    <xsl:for-each select="MediaMixer/Conference">
                      <xsl:if test="Name='combo.SelectedValue'">


                        <xsl:for-each  select="Participant">
                          <xsl:if test="(position() mod 2 = 0)">
                            <tr class="rgAltRow SummaryTableDataRow">
                              <td valign = "top">
                                <xsl:value-of select="../Name"/>
                              </td>
                              <td valign = "top">
                                <xsl:value-of select="../ConfId"/>
                              </td>
                              <td valign = "top">
                                <xsl:value-of select="translate(ID1,
                                'abcdefghijklmnopqrstuvwxyz',
                                'ABCDEFGHIJKLMNOPQRSTUVWXYZ')" />
                              </td>
                              <td valign = "top">
                                <xsl:value-of select="ID2"/>
                              </td>
                              <td valign = "top">
                                <xsl:value-of select="ParticipantAddress"/>
                              </td>
                              <td valign = "top">
                                <xsl:value-of select="ParticipantListeningPort"/>
                              </td>
                              <td valign = "top">
                                <xsl:value-of select="MMListeningPort"/>
                              </td>
                              <td valign = "top">
                                <xsl:value-of select="SSRCFromParticipant"/>
                              </td>
                              <td valign = "top">
                                <xsl:value-of select="SSRCFromMM"/>
                              </td>
                            </tr>
                          </xsl:if>
                          <xsl:if test="(position() mod 2 = 1)">
                            <td>
                              <tr class="rgRow SummaryTableDataRow">

                                <td valign = "top">
                                  <xsl:value-of select="../Name"/>
                                </td>
                                <td valign = "top">
                                  <xsl:value-of select="../ConfId"/>
                                </td>
                                <td valign = "top">
                                  <xsl:value-of select="translate(ID1,
                                'abcdefghijklmnopqrstuvwxyz',
                                'ABCDEFGHIJKLMNOPQRSTUVWXYZ')" />
                                </td>
                                <td valign = "top">
                                  <xsl:value-of select="ID2"/>
                                </td>
                                <td valign = "top">
                                  <xsl:value-of select="ParticipantAddress"/>
                                </td>
                                <td valign = "top">
                                  <xsl:value-of select="ParticipantListeningPort"/>
                                </td>
                                <td valign = "top">
                                  <xsl:value-of select="MMListeningPort"/>
                                </td>
                                <td valign = "top">
                                  <xsl:value-of select="SSRCFromParticipant"/>
                                </td>
                                <td valign = "top">
                                  <xsl:value-of select="SSRCFromMM"/>
                                </td>
                              </tr>
                            </td>
                          </xsl:if>
                        </xsl:for-each>
                      </xsl:if>
                    </xsl:for-each>
                  </xsl:if>
                  <xsl:if test="MediaMixer= ''">
                    <td valign = "top">
                      <xsl:text>No Data </xsl:text>
                    </td>
                  </xsl:if>
                </table>
              </td>
            </tr>
          </table>
          &#160;
          <div style="display:none">
            <iframe id="frameUpdate" name="frameUpdate" width="100%"></iframe>
          </div>
        </div>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

1 个答案:

答案 0 :(得分:1)

如果要在浏览器中使用客户端XSLT从XML数据构建HTML页面,请注意XSLT只能定义转换过程。当HTML准备就绪时,XSLT已经完成了它的工作。你可以做的是将javascript插入XSLT源,它对下拉变化做出反应并隐藏不合适的数据。 XSLT无法与Javascript通信,因为Javascript将在页面完成并且XSLT已经完成后开始工作。但它可以使javascript适合HTML源代码。想象一下如何在没有XSLT的普通HTML中解决这个问题,让XSLT构建这个HTML。