下拉列表中的选定项目应显示相关详细信息

时间:2011-09-21 07:52:27

标签: c# asp.net css xml xslt

我有一个包含一些数据的xml文件。我使用xsl文件以表格的形式显示数据。

请检查xml代码和xsl代码以及屏幕截图

xml文件

<?xml-stylesheet type="text/xsl" href="MMDiagnostics.xslt"?>

<MediaMixer>

  <Conference>
    <Name>Test</Name>
    <ConfId>1002</ConfId>
    <CompositeAddress>238.57.0.1</CompositeAddress>
    <CompositePort>48000</CompositePort>
    <CompositeSsrc>243324353</CompositeSsrc>
    <NoOfParticipants>2</NoOfParticipants>

    <Participant>
      <ID1>abc88C</ID1>
      <ID2>0</ID2>
      <ParticipantAddress>192.168.177.45</ParticipantAddress>
      <ParticipantListeningPort>22004</ParticipantListeningPort>
      <MMListeningPort>45004</MMListeningPort>
      <SSRCFromParticipant>316541</SSRCFromParticipant>
      <SSRCFromMM>26481</SSRCFromMM>
    </Participant>

    <Participant>
      <ID1>piy65R</ID1>
      <ID2>0</ID2>
      <ParticipantAddress>192.168.177.45</ParticipantAddress>
      <ParticipantListeningPort>22004</ParticipantListeningPort>
      <MMListeningPort>45004</MMListeningPort>
      <SSRCFromParticipant>316541</SSRCFromParticipant>
      <SSRCFromMM>26481</SSRCFromMM>
    </Participant>   

  </Conference>

  <Conference>
    <Name>Test002</Name>
    <ConfId>1002</ConfId>
    <CompositeAddress>238.57.0.1</CompositeAddress>
    <CompositePort>48005</CompositePort>
    <CompositeSsrc>353324353</CompositeSsrc>
    <NoOfParticipants>2</NoOfParticipants>

    <Participant>
      <ID1>70542151</ID1>
      <ID2>0</ID2>
      <ParticipantAddress>192.168.177.45</ParticipantAddress>
      <ParticipantListeningPort>22004</ParticipantListeningPort>
      <MMListeningPort>45004</MMListeningPort>
      <SSRCFromParticipant>316541</SSRCFromParticipant>
      <SSRCFromMM>26481</SSRCFromMM>
    </Participant>

    <Participant>
      <ID1>70542151</ID1>
      <ID2>0</ID2>
      <ParticipantAddress>192.168.177.45</ParticipantAddress>
      <ParticipantListeningPort>22004</ParticipantListeningPort>
      <MMListeningPort>45004</MMListeningPort>
      <SSRCFromParticipant>316541</SSRCFromParticipant>
      <SSRCFromMM>26481</SSRCFromMM>
    </Participant>
  </Conference>


  </MediaMixer>

xsl文件

<?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>
              <xsl:for-each select="MediaMixer/Conference">
                <option>
                  <xsl:value-of select="Name"/>
                </option>
              </xsl:for-each>
            </select>
          </div>






          <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: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: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>

enter image description here

我有一个下拉框,显示第一个表中的会议名称。我想要的是,当我选择会议名称时,与其相关的数据应显示在第二个表格中。不应显示与特定会议名称无关的数据。现在,我正在显示xml文件中的所有数据。

如何在xsl中设置条件以根据我在下拉列表中的选择显示数据?

1 个答案:

答案 0 :(得分:0)

  

如何在xsl中设置条件以根据我的选择显示数据   在下拉列表中?

<强>一般

您需要将转换中的全局(外部指定)参数作为唯一标识所选会议的值。

<xsl:param name="confUniqueId" select="someValueHere"/>

此参数的值由启动转换的代码(在本例中为JS)设置 - 您需要阅读文档以了解必须如何完成此操作。

然后在您的XSLT代码中,根据此参数的值,标识所需的Conference元素,并仅将模板应用于此元素。

不幸的是,在提供的XML文档中,多个会议具有相同的ID和相同的名称......