本文介绍了在下拉列表中选择项目应显示相关的细节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含一些数据的XML文件。我使用XSL文件中的表的形式来显示的数据。

请检查XML code和XSL code和截图

xml文件

 <?xml样式表类型=文/ XSL的href =MMDiagnostics.xslt&GT?;< MediaMixer>  <会议及GT;
    <名称>测试与LT; /名称>
    < ConfId> 1002 LT; / ConfId>
    < CompositeAddress> 238.57.0.1< / CompositeAddress>
    < CompositePort> 48000< / CompositePort>
    < CompositeSsrc> 243324353< / CompositeSsrc>
    &所述; NoOfParticipants→2&下; / NoOfParticipants>    <参与者GT;
      <&ID1 GT; abc88C< / ID1>
      &所述; ID2大于0&下; / ID2>
      < ParticipantAddress> 192.168.177.45< / ParticipantAddress>
      < ParticipantListeningPort> 22004< / ParticipantListeningPort>
      < MMListeningPort> 45004< / MMListeningPort>
      < SSRCFromParticipant> 316541< / SSRCFromParticipant>
      < SSRCFromMM> 26481< / SSRCFromMM>
    < /与会者>    <参与者GT;
      <&ID1 GT; piy65R< / ID1>
      &所述; ID2大于0&下; / ID2>
      < ParticipantAddress> 192.168.177.45< / ParticipantAddress>
      < ParticipantListeningPort> 22004< / ParticipantListeningPort>
      < MMListeningPort> 45004< / MMListeningPort>
      < SSRCFromParticipant> 316541< / SSRCFromParticipant>
      < SSRCFromMM> 26481< / SSRCFromMM>
    < /与会者>  < /会议及GT;  <会议及GT;
    <名称>&Test002 LT; /名称>
    < ConfId> 1002 LT; / ConfId>
    < CompositeAddress> 238.57.0.1< / CompositeAddress>
    < CompositePort> 48005< / CompositePort>
    < CompositeSsrc> 353324353< / CompositeSsrc>
    &所述; NoOfParticipants→2&下; / NoOfParticipants>    <参与者GT;
      <&ID1 GT; 70542151< / ID1>
      &所述; ID2大于0&下; / ID2>
      < ParticipantAddress> 192.168.177.45< / ParticipantAddress>
      < ParticipantListeningPort> 22004< / ParticipantListeningPort>
      < MMListeningPort> 45004< / MMListeningPort>
      < SSRCFromParticipant> 316541< / SSRCFromParticipant>
      < SSRCFromMM> 26481< / SSRCFromMM>
    < /与会者>    <参与者GT;
      <&ID1 GT; 70542151< / ID1>
      &所述; ID2大于0&下; / ID2>
      < ParticipantAddress> 192.168.177.45< / ParticipantAddress>
      < ParticipantListeningPort> 22004< / ParticipantListeningPort>
      < MMListeningPort> 45004< / MMListeningPort>
      < SSRCFromParticipant> 316541< / SSRCFromParticipant>
      < SSRCFromMM> 26481< / SSRCFromMM>
    < /与会者>
  < /会议及GT;
  < / MediaMixer>

XSL文件

 <?XML版本=1.0编码=ISO-8859-1&GT?;
<的xsl:样式版本=1.0的xmlns:XSL =htt​​p://www.w3.org/1999/XSL/Transform>
  <的xsl:模板匹配=/>
    < HTML和GT;
      < HEAD>
        <标题> VPGate媒体混合器< /标题>
        < META HTTP-EQUIV =过期的内容=0/>
        < META HTTP-EQUIV =编译内容=无缓存/>
        < META HTTP-EQUIV =缓存控制内容=无缓存,必重新验证/>
        < META HTTP-当量=刷新内容=15>< /元>
        <脚本SRC =/通用/ common.js \\类型=文/ JavaScript的>< / SCRIPT>
        <链接rel =stylesheet属性类型=文/ CSS的href =style001.css/>
        <链接rel =stylesheet属性类型=文/ CSS的href =Grid.Default.css/>
      < /头>
      <车身类=工作区>
        < D​​IV CLASS =divSummaryHeaderID =SummaryHeader>
          < H1>媒体混合器 - VPGate< / H1>
        < / DIV>        &放大器;#160;
        < D​​IV CLASS =radgrid控件RadGrid_DefaultID =SummaryData的风格=的位置是:绝对的;宽度:828px;高度:510px;溢出:汽车>
          <表格边框=0级=rgMasterTable rgClipCellsCELLSPACING =0的cellpadding =0>
            &所述; TR>
              <输入类型=按钮级=formEditBtnID =SUBBTNVALUE =刷新的onclick =window.location的= window.location的;/>
            < / TR>
            &所述; TR>
              < TD类=rgHeader SummaryTableHdrRow的风格=字体重量:大胆的;合并单元格=2>会议纪要< / TD>
            < / TR>
            &所述; TR>
              &所述; TD>
                <表格边框=0级=rgMasterTable rgClipCellsCELLSPACING =0的cellpadding =0>
                  &所述; TR>
                    < TD类=rgHeader SummaryTableHdrRow的风格=字体重量:大胆;>会议名称< / TD>
                    < TD类=rgHeader SummaryTableHdrRow的风格=字体重量:大胆;>会议ID< / TD>
                    < TD类=rgHeader SummaryTableHdrRow的风格=字体重量:大胆;>复合地址< / TD>
                    < TD类=rgHeader SummaryTableHdrRow的风格=字体重量:大胆;>复合港口和LT; / TD>
                    < TD类=rgHeader SummaryTableHdrRow的风格=字体重量:大胆;>复合SSRC< / TD>
                    < TD类=rgHeader SummaryTableHdrRow的风格=字体重量:大胆;>没有参加与的LT; / TD>
                  < / TR>
                  <的xsl:if测试=!MediaMixer =''>
                    <的xsl:for-每个选择=MediaMixer /会议>
                      !< - < XSL:排序选择=名称/> - >
                      <的xsl:if测试=!名称=''>
                        <的xsl:if测试=(位置()模2 = 0)>
                          &所述; TR类=rgAltRow SummaryTableDataRow>
                            < TD VALIGN =顶>
                              < XSL:选择=名称/&GT值的;
                            < / TD>
                            < TD VALIGN =顶>
                              < XSL:选择=ConfId/&GT值的;
                            < / TD>
                            < TD VALIGN =顶>
                              < XSL:选择=CompositeAddress/&GT值的;
                            < / TD>
                            < TD VALIGN =顶>
                              < XSL:选择=CompositePort/&GT值的;
                            < / TD>
                            < TD VALIGN =顶>
                              < XSL:选择=CompositeSsrc/&GT值的;
                            < / TD>
                            < TD VALIGN =顶>
                              <的xsl:value-of的选择=NoOfParticipants/>
                            < / TD>
                          < / TR>
                        < / XSL:如果>
                        <的xsl:if测试=(位置()模2 = 1)>
                          &所述; TD>
                            &所述; TR类=rgRow SummaryTableDataRow>
                              < TD VALIGN =顶>
                                < XSL:选择=名称/&GT值的;
                              < / TD>
                              < TD VALIGN =顶>
                                < XSL:选择=ConfId/&GT值的;
                              < / TD>
                              < TD VALIGN =顶>
                                < XSL:选择=CompositeAddress/&GT值的;
                              < / TD>
                              < TD VALIGN =顶>
                                < XSL:选择=CompositePort/&GT值的;
                              < / TD>
                              < TD VALIGN =顶>
                                < XSL:选择=CompositeSsrc/&GT值的;
                              < / TD>
                              < TD VALIGN =顶>
                                <的xsl:value-of的选择=NoOfParticipants/>
                              < / TD>
                            < / TR>
                          < / TD>
                        < / XSL:如果>
                      < / XSL:如果>
                    < /的xsl:for-每个>
                  < / XSL:如果>
                  <的xsl:if测试=MediaMixer =''>
                    < TD VALIGN =顶>
                      < XSL:文本>无数据< / XSL:文本>
                    < / TD>
                  < / XSL:如果>
                < /表>
              < / TD>
            < / TR>
          < /表>
          &放大器;#160;          < D​​IV ALIGN =中心>
            < B>请选择一个会议名称:< / B>
           &放大器;#160;
            <选择>
              <的xsl:for-每个选择=MediaMixer /会议>
                <选项>
                  < XSL:选择=名称/&GT值的;
                < /选项>
              < /的xsl:for-每个>
            < /选择>
          < / DIV>
          <表格边框=0级=rgMasterTable rgClipCellsCELLSPACING =1的cellpadding =1>
            &所述; TR>
              < TD类=rgHeader SummaryTableHdrRow的风格=字体重量:大胆的;合并单元格=2>会议详情及LT; / TD>
            < / TR>
            &所述; TR>
              &所述; TD>
                <表格边框=0级=rgMasterTable rgClipCellsCELLSPACING =0的cellpadding =0>
                  &所述; TR>
                    < TD类=rgHeader SummaryTableHdrRow的风格=字体重量:大胆;>会议名称< / TD>
                    < TD类=rgHeader SummaryTableHdrRow的风格=字体重量:大胆;>会议ID< / TD>
                    < TD类=rgHeader SummaryTableHdrRow的风格=字体重量:大胆;>参与者编号1 LT; / TD>
                    < TD类=rgHeader SummaryTableHdrRow的风格=字体重量:大胆;>参与者编号2'; / TD>
                    < TD类=rgHeader SummaryTableHdrRow的风格=字体重量:大胆;>与会者地址< / TD>
                    < TD类=rgHeader SummaryTableHdrRow的风格=字体重量:大胆;>参与者侦听端口< / TD>
                    < TD类=rgHeader SummaryTableHdrRow的风格=字体重量:大胆;> MM侦听端口< / TD>
                    < TD类=rgHeader SummaryTableHdrRow的风格=字体重量:大胆;> SSRC从参与者< / TD>
                    < TD类=rgHeader SummaryTableHdrRow的风格=字体重量:大胆;> SSRC从MM< / TD>
                  < / TR>
                  <的xsl:if测试=!MediaMixer =''>
                    <的xsl:for-每个选择=MediaMixer /会议>
                      <的xsl:for-每个选择=参与者>
                        <的xsl:if测试=(位置()模2 = 0)>
                          &所述; TR类=rgAltRow SummaryTableDataRow>
                            < TD VALIGN =顶>
                              < XSL:选择=../名/&GT值的;
                            < / TD>
                            < TD VALIGN =顶>
                              <的xsl:value-of的选择=../ ConfId/>
                            < / TD>
                            < TD VALIGN =顶>
                              <的xsl:value-of的选择=翻译(ID1,
                                'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
                                'ABCDEFGHIJKLMNOPQRSTUVWXYZ')/>
                            < / TD>
                            < TD VALIGN =顶>
                                < XSL:选择=ID2/&GT值的;
                            < / TD>
                            < TD VALIGN =顶>
                              < XSL:选择=ParticipantAddress/&GT值的;
                            < / TD>
                            < TD VALIGN =顶>
                              < XSL:选择=ParticipantListeningPort/&GT值的;
                            < / TD>
                            < TD VALIGN =顶>
                              < XSL:选择=MMListeningPort/&GT值的;
                            < / TD>
                            < TD VALIGN =顶>
                              < XSL:选择=SSRCFromParticipant/&GT值的;
                            < / TD>
                            < TD VALIGN =顶>
                              < XSL:选择=SSRCFromMM/&GT值的;
                            < / TD>
                          < / TR>
                        < / XSL:如果>
                        <的xsl:if测试=(位置()模2 = 1)>
                          &所述; TD>
                            &所述; TR类=rgRow SummaryTableDataRow>                              < TD VALIGN =顶>
                                < XSL:选择=../名/&GT值的;
                              < / TD>
                              < TD VALIGN =顶>
                                <的xsl:value-of的选择=../ ConfId/>
                              < / TD>
                              < TD VALIGN =顶>
                                <的xsl:value-of的选择=翻译(ID1,
                                'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
                                'ABCDEFGHIJKLMNOPQRSTUVWXYZ')/>
                              < / TD>
                              < TD VALIGN =顶>
                                < XSL:选择=ID2/&GT值的;
                              < / TD>
                              < TD VALIGN =顶>
                                < XSL:选择=ParticipantAddress/&GT值的;
                              < / TD>
                              < TD VALIGN =顶>
                                < XSL:选择=ParticipantListeningPort/&GT值的;
                              < / TD>
                              < TD VALIGN =顶>
                                < XSL:选择=MMListeningPort/&GT值的;
                              < / TD>
                              < TD VALIGN =顶>
                                < XSL:选择=SSRCFromParticipant/&GT值的;
                              < / TD>
                              < TD VALIGN =顶>
                                < XSL:选择=SSRCFromMM/&GT值的;
                              < / TD>
                            < / TR>
                          < / TD>
                        < / XSL:如果>
                      < /的xsl:for-每个>
                    < /的xsl:for-每个>
                  < / XSL:如果>
                  <的xsl:if测试=MediaMixer =''>
                    < TD VALIGN =顶>
                      < XSL:文本>无数据< / XSL:文本>
                    < / TD>
                  < / XSL:如果>
                < /表>
              < / TD>
            < / TR>
          < /表>
          &放大器;#160;
          < D​​IV的风格=显示:无>
            < IFRAME ID =frameUpdateNAME =frameUpdateWIDTH =100%>< / IFRAME>
          < / DIV>
        < / DIV>
      < /身体GT;
    < / HTML>
  < / XSL:模板>
< / XSL:样式>

我有一个从第一个表显示会议名称的下拉框。我要的是,当我选择一个会议名称,有关它的数据应该在第二个表显示。不应当显示的是不相关的一个特定的会议名称的数据。现在,我从XML文件中显示的所有数据。

我如何设置基于我在下拉菜单中选择XSL来显示数据的条件?


解决方案

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

这篇关于在下拉列表中选择项目应显示相关的细节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 13:50