开发者

selected item in drop-down should display relevant details

I have a xml file that contains some data. I use a xsl file to display the data in the form of a table.

Please check the xml code and xsl code and the screenshot

xml file

<?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 file

<?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>
                开发者_如何学Python              <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>

selected item in drop-down should display relevant details

I have a drop-down box that displays the Conference Names from the first table. What i want is, when i select a conference name, data relevant to it should be displayed in the second table. The data that is not relevant to a particular conference name should not be displayed. Right now, I am displaying all the data from the xml file.

How do i set a condition in xsl to display data based on my selection in the drop-down ?


How do i set a condition in xsl to display data based on my selection in the drop-down ?

Generally:

You need to provide as a global (externally specified) parameter to the transformation a value that uniquely identifies the selected conference.

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

The value of this parameter is set by the code (JS in this case) that initiates the transformation -- you need to read the documentation to understand how exactly this must be done.

Then in your XSLT code, from the value of this parameter, identify the desired Conference element and apply templates only to this element.

Unfortunately, in the provided XML document more than one conference have both the same ID and the same Name...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜