如何从上一个节点提取数据

时间:2014-10-01 10:00:53

标签: xslt-1.0

我遇到了一个挑战,我正在努力寻找合适的方法。所需信息位于两个不同的节点中,但属于设备的相同信息。

后一个节点按照图片包含上一个节点的目标信息:XML nodes

电话设备有两个节点,用于存储设备上的信息,IP电话和工作站。在工作站下,主要信息与一个密钥一起存储,该密钥将其链接到IP电话部分。

我有以下代码:

   <?xml version='1.0'?>
     <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
       <xsl:template match="/">
         <html>
           <body>
         <table border="1">
           <tr>
             <td><strong>Name</strong></td>
             <td><strong>Software Version</strong></td>
         <td><strong>Status</strong></td>
           </tr>
           <xsl:for-each select="ENTRY/ENTRY/ENTRY/ENTRY/ENTRY">
         <xsl:if test="@CLASS='Workstation'">
           <tr>
         <td><xsl:value-of select="@NAME"/></td>
         <xsl:for-each select="ATTRIBUTE">
           <xsl:if test="@NAME='Managed IP Phone'">
             <xsl:call-template name="Phone_Data">
               <xsl:with-param name="IPPhone" select="VALUE"/>
             </xsl:call-template>
           </xsl:if>
         </xsl:for-each>
         <td>.</td>
           </tr>
         </xsl:if>
       </xsl:for-each>
     </table>
       </body>
     </html>
</xsl:template>

  <!-- Additional templates to pull 2nd phone node data. -->
  <xsl:template name="Phone_Data">
  <xsl:param name="IPPhone"/>
    <td> <xsl:value-of select="$IPPhone"/> </td> <!--   -->
<xsl:for-each select="../ENTRY">
  <xsl:if test="@NAME='IP Phones'">
    <xsl:for-each select="ENTRY">
      <xsl:if test="@NAME=$IPPhone">
        <xsl:for-each select="ATTRIBUTE">
      <!-- This is an attribute under the IP Phones - GBADM104_ENTRY  -->
      <xsl:if test="@NAME='Software Version'">
        <td><xsl:value-of select="VALUE"/></td>
      </xsl:if>
    </xsl:for-each>
      </xsl:if>
    </xsl:for-each>
      </xsl:if>
</xsl:for-each>
  </xsl:template>

  </xsl:stylesheet>

来自 工作站 节点下的GBADM104_ENTRY,它没有向我提供我希望从 IP下的GBADM104_ENTRY获取的信息屏幕截图中的电话 节点。

由于我是新手,我显然在Phone_Data模板中犯了一个错误,用我需要的数据来定位节点。我不知道是否能以正确的方式向我提出如何做到这一点的建议?

  <?xml version="1.0" encoding="utf-8"?>
  <!-- Generated by DSEdit -->
  <ENTRY NAME="CustomerSite" CLASS="Site">
    <ENTRY NAME="Production" CLASS="Configuration Set">
      <ENTRY NAME="REG6699CIC01" CLASS="Server">
        <ENTRY NAME="IP Phones" CLASS="IP Phones">
          <ENTRY NAME="51948094-c6e6-4fb9-bb76-ba1986c51429" CLASS="IP Phone">
            <ATTRIBUTE NAME="VAD">
              <VALUE>No</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Software Version">
              <VALUE>3.2.7.0198</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Feature Call Park">
              <VALUE>Yes</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Status">
              <VALUE>Current</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Station Type">
              <VALUE>Workstation</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="ReloadedLast">
              <VALUE>20140825143741Z</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="MAC Address">
              <VALUE>0004F24F4012</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Name">
              <VALUE>GBADM103</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Date Last Modified">
              <VALUE>1406660976</VALUE>
            </ATTRIBUTE>
          </ENTRY>
          <ENTRY NAME="51dbb1fe-9957-420a-bfc3-3f4d9bc1b2fc" CLASS="IP Phone">
            <ATTRIBUTE NAME="Software Version">
              <VALUE>3.2.7.0198</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Status">
              <VALUE>Current</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Station Type">
              <VALUE>Workstation</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="ReloadedLast">
              <VALUE>20140912074858Z</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="MAC Address">
              <VALUE>0004F2B37167</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Name">
              <VALUE>GBADM104</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Date Last Modified">
              <VALUE>1410881183</VALUE>
            </ATTRIBUTE>
          </ENTRY>
          <ENTRY NAME="51eace77-7f6d-467a-bbac-b27329229c53" CLASS="IP Phone">
            <ATTRIBUTE NAME="VAD">
              <VALUE>No</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Software Version">
              <VALUE>3.2.7.0198</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Status">
              <VALUE>Current</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Station Type">
              <VALUE>Workstation</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="ReloadedLast">
              <VALUE>20140814104810Z</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="MAC Address">
              <VALUE>0004F24F3E3B</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Persistent">
              <VALUE>Yes</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="IP Address">
              <VALUE>10.254.250.61</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Name">
              <VALUE>GBADS201</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Date Last Modified">
              <VALUE>1406899229</VALUE>
            </ATTRIBUTE>
    </ENTRY>
      <ATTRIBUTE NAME="Security">
        <VALUE>Minimal</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Call Ringback Timeout">
        <VALUE>0</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="VQM Collector Periodic Trigger">
        <VALUE>0</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Codec Pref">
        <VALUE>0|G.711 mu-law|</VALUE>
        <VALUE>1|G.711 a-law|</VALUE>
        <VALUE>2|G.729AB|</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Active">
        <VALUE>Yes</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Use 486 For Reject">
        <VALUE>No</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Emergency Customer Name">
        <VALUE>Regus</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Call Waiting Tone">
        <VALUE>No</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Connection Type">
        <VALUE>SIPAddress</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Sync Forward To IC Status">
        <VALUE>No</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="IsSupportedRingSets">
        <VALUE>Yes</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="SIP ID Address SYNC">
        <VALUE>Sync Dynamic</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="VQM Collector Session">
        <VALUE>No</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="SIP Receive Port">
        <VALUE>5060</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Audio Path">
        <VALUE>Always In</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="VAD">
        <VALUE>No</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Proxy Group">
        <VALUE>3b6b817b-73e5-4db5-b6d5-57eb0f9b26ff</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Polycom Override Date Date Top">
        <VALUE>D</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Software Version">
        <VALUE>3.2.7.0198</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Emergency Location Description">
        <VALUE>15305 Dallas Parkway Suite 300, Addison, TX, 75001</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Polycom Headset Microphone Gain">
        <VALUE>21</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Feature Call Park">
        <VALUE>Yes</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Region Location">
        <VALUE>North America</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Status">
        <VALUE>Current</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Polycom Override Date Format">
        <VALUE>D</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Emergency Numbers">
        <VALUE>911</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Feature URL Dialing">
        <VALUE>No</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="DTMF Off Time">
        <VALUE>80</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Station Type">
        <VALUE>Workstation</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="VQM Collector Periodic">
        <VALUE>No</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="One Touch Voicemail">
        <VALUE>No</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Ring Always">
        <VALUE>Yes</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Regional Tone Set">
        <VALUE>Language_Default</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="VQM RTCP-XR">
        <VALUE>No</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="ExpansionModules">
        <VALUE>0</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Polycom Call Waiting">
        <VALUE>beep</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Enable Handsfree">
        <VALUE>Yes</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Polycom NumberFirstCID">
        <VALUE>No</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Interface Language">
        <VALUE>English_United_States</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Headset Echo-Noise Suppression">
        <VALUE>No</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Feature Call List">
        <VALUE>Yes</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Polycom Override Date Long Format">
        <VALUE>D</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="SIP Session Timeout">
        <VALUE>60</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="ReloadedLast">
        <VALUE>20140905170113Z</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Phone Manufacturer">
        <VALUE>Polycom</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Disable Delayed Media">
        <VALUE>No</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Station Appearances">
        <VALUE>0|Private|USISM010|Yes</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Inbound SIP Security Challenge">
        <VALUE>none</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Call per Station">
        <VALUE>1</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Bus Gain">
        <VALUE>0</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="RTP QOS Byte">
        <VALUE>B8</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Call Dialtone Timeout">
        <VALUE>15</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Feature Call List Placed">
        <VALUE>Yes</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Password">
        <VALUE>F08470F66758CE835CA9DD495F57E5B433F03937D78CFA01CAC315492D7F167C</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Location NTP Server Overrides DHCP">
        <VALUE>No</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Electronic Hookswitch Mode">
        <VALUE>0</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Authentication">
        <VALUE>Yes</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Echo Cancellation">
        <VALUE>No</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Phone Limits Calls Per Line Key">
        <VALUE>No</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Feature Presence">
        <VALUE>No</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="TimeZone">
        <VALUE>CST</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Phone Model">
        <VALUE>IP331</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Persist Handset Volume">
        <VALUE>Yes</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="SIP Register Interval">
        <VALUE>86400</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="MWI Message Light">
        <VALUE>Yes</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Audio Protocol">
        <VALUE>RTP</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="VQM Collector Period">
        <VALUE>20</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Polycom Override 24 Hour Clock">
        <VALUE>D</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Polycom Headset Sidetone Gain">
        <VALUE>-3</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Use SIP Session Timer">
        <VALUE>Yes</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Media Port Start Range">
        <VALUE>2222</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Dialplan Digitmap Timeout">
        <VALUE>3|1|3|3</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Call Offering Timeout">
        <VALUE>0</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="DefaultLabelType">
        <VALUE>Station</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Feature Group Call Pickup">
        <VALUE>Yes</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Syslog Transport">
        <VALUE>1</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="MAC Address">
        <VALUE>0004F2A72B5F</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Location Description">
        <VALUE>Colonnade</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Sync DND To IC Status">
        <VALUE>No</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Polycom Headset Speaker Gain">
        <VALUE>4</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Persistent">
        <VALUE>Yes</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Disable App Logs When Using Syslog">
        <VALUE>Yes</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Location Time Zone Overrides DHCP">
        <VALUE>Yes</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="User Name">
        <VALUE>38bc4dfa7e384f29bb7e62fc24dac94d</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="IP Address">
        <VALUE>10.175.250.106</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Terminate Call Analysis On Connect">
        <VALUE>Yes</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Disconnect on Broken RTP">
        <VALUE>0</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Syslog Render Level">
        <VALUE>0</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Headset Mode">
        <VALUE>Yes</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="DTMF On Time">
        <VALUE>80</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="DTMF Type">
        <VALUE>RFC2833</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Persist Headset Volume">
        <VALUE>Yes</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Feature Call List Received">
        <VALUE>Yes</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="SIP QOS Byte">
        <VALUE>Not Set</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Dial On Offhook">
        <VALUE>No</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Use Proxy">
        <VALUE>Not Set</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Network Gain">
        <VALUE>0</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Disallow Media Server Passthru">
        <VALUE>No</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Feature Directory">
        <VALUE>Yes</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="External Devices Determine Codecs">
        <VALUE>No</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Connection Call Warm Down Time">
        <VALUE>5</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Feature Messaging">
        <VALUE>No</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="DTMF Payload">
        <VALUE>101</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Handset Echo-Noise Suppression">
        <VALUE>No</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Disable Delayed Media reINVITE">
        <VALUE>No</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Name">
        <VALUE>USISM010</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Persist Handsfree Volume">
        <VALUE>Yes</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="IP3X0 Line 2 Key Function">
        <VALUE>Line2</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Feature Call List Missed">
        <VALUE>No</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Emergency Outbound ANI">
        <VALUE>19727152000</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Dialplan Digitmap">
        <VALUE>x.T|*T|*905|*90[1-4]x.T</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Allow SIP Registration">
        <VALUE>Yes</VALUE>
      </ATTRIBUTE>
      <ATTRIBUTE NAME="Date Last Modified">
        <VALUE>1372825753</VALUE>
      </ATTRIBUTE>
    </ENTRY>
        </ENTRY>
        <ENTRY NAME="Workstations" CLASS="Workstations">
          <ENTRY NAME="GBADM103" CLASS="Workstation">
            <ATTRIBUTE NAME="Security">
              <VALUE>Minimal</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Active">
              <VALUE>Yes</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Counted Licenses">
              <VALUE>I3_LICENSE_BASIC_STATION</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Connection Type">
              <VALUE>SIPAddress</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="SIP ID Address">
              <VALUE>GBADM103</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Station Type">
              <VALUE>Workstation</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Managed Label">
              <VALUE>GBADM103</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Line">
              <VALUE>sip:GBADM103@192.168.1.203:5060</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Licenses Enabled">
              <VALUE>Yes</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="MAC Address">
        <VALUE>0004F2B37157</VALUE>
      </ATTRIBUTE>
            <ATTRIBUTE NAME="Managed IP Phone">
              <VALUE>51948094-c6e6-4fb9-bb76-ba1986c51429</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Date Last Modified">
        <VALUE>1410882147</VALUE>
      </ATTRIBUTE>
          </ENTRY>
          <ENTRY NAME="GBADM104" CLASS="Workstation">
            <ATTRIBUTE NAME="Counted Licenses">
              <VALUE>I3_LICENSE_BASIC_STATION</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="SIP ID Address">
              <VALUE>GBADM104</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Managed Label">
              <VALUE>GBADM104</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Extension">
              <VALUE>903104</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Line">
              <VALUE>sip:GBADM104@192.168.1.204:5060</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="MAC Address">
              <VALUE>0004F2B37167</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Persistent">
              <VALUE>Yes</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Managed IP Phone">
              <VALUE>51dbb1fe-9957-420a-bfc3-3f4d9bc1b2fc</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Date Last Modified">
              <VALUE>1410881183</VALUE>
            </ATTRIBUTE>
          </ENTRY>
          <ENTRY NAME="GBADS201" CLASS="Workstation">
            <ATTRIBUTE NAME="Counted Licenses">
              <VALUE>I3_LICENSE_BASIC_STATION</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Connection Type">
              <VALUE>SIPAddress</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="SIP ID Address">
              <VALUE>GBADS201</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Station Type">
              <VALUE>Workstation</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Managed Label">
              <VALUE>GBADS201</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="MAC Address">
              <VALUE>UK1058597LT.uk-eire.regus.local</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Managed IP Phone">
              <VALUE>51eace77-7f6d-467a-bbac-b27329229c53</VALUE>
            </ATTRIBUTE>
            <ATTRIBUTE NAME="Date Last Modified">
              <VALUE>1372819315</VALUE>
            </ATTRIBUTE>
          </ENTRY>
        </ENTRY>
      </ENTRY>
    </ENTRY>
  </ENTRY>

1 个答案:

答案 0 :(得分:1)

我大多在猜这里。以下样式表:

XSLT 1.0

<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="xml" omit-xml-declaration="yes" version="1.0" encoding="utf-8" indent="yes"/>

<xsl:key name="entry-by-name" match="ENTRY" use="@NAME" />

<xsl:template match="/">
    <html>
        <body>
            <table border="1">
                <tr>
                    <th>Name</th>
                    <th>Software Version</th>
                    <th>Status</th>
                </tr>
                <xsl:for-each select="ENTRY/ENTRY/ENTRY/ENTRY[@CLASS='Workstation']">
                    <tr>
                        <td>
                            <xsl:value-of select="@NAME"/>
                        </td>
                        <td>
                            <xsl:value-of select="key('entry-by-name', ATTRIBUTE[@NAME='Managed IP Phone']/VALUE)/ATTRIBUTE[@NAME='Software Version']/VALUE"/>
                        </td>
                        <td>.</td>
                    </tr>
                </xsl:for-each>
            </table>
        </body>
    </html>
</xsl:template>

</xsl:stylesheet>

应用于您的示例输入(已针对良好格式进行了更正!)将生成以下结果

<html>
   <body>
      <table border="1">
         <tr>
            <th>Name</th>
            <th>Software Version</th>
            <th>Status</th>
         </tr>
         <tr>
            <td>GBADM103</td>
            <td>3.2.7.0198</td>
            <td>.</td>
         </tr>
         <tr>
            <td>GBADM104</td>
            <td>3.2.7.0198</td>
            <td>.</td>
         </tr>
         <tr>
            <td>GBADS201</td>
            <td>3.2.7.0198</td>
            <td>.</td>
         </tr>
      </table>
   </body>
</html>

呈现为:

enter image description here

请注意使用谓词选择感兴趣的节点,并使用 key 从XML输入的另一个分支中查找数据。