我在使用来自网络设备的 XSLT 转换某些 XML 数据时遇到问题。考虑以下 xml 输出...
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/11.4X27/junos">
<multi-routing-engine-results>
<multi-routing-engine-item>
<re-name>member0</re-name>
<environment-information
xmlns="http://xml.juniper.net/junos/11.4X27/junos-chassis">
<environment-item>
<name>PEM 0</name>
<class>Temp</class>
<status>OK</status>
<temperature junos:celsius="30">30 degrees C / 86 degrees F
</temperature>
</environment-item>
<environment-item>
<name>PEM 1</name>
<class>Temp</class>
<status>OK</status>
<temperature junos:celsius="30">30 degrees C / 86 degrees F
</temperature>
</environment-item>
</environment-information>
</multi-routing-engine-item>
<multi-routing-engine-item>
<re-name>member1</re-name>
<environment-information
xmlns="http://xml.juniper.net/junos/11.4X27/junos-chassis">
<environment-item>
<name>PEM 0</name>
<class>Temp</class>
<status>OK</status>
<temperature junos:celsius="25">25 degrees C / 77 degrees F
</temperature>
</environment-item>
<environment-item>
<name>PEM 1</name>
<class>Temp</class>
<status>OK</status>
<temperature junos:celsius="25">25 degrees C / 77 degrees F
</temperature>
</environment-item>
</environment-information>
</multi-routing-engine-item>
</multi-routing-engine-results>
<cli>
<banner>{master:member0-re0}</banner>
</cli>
</rpc-reply>
如何遍历 XSLT 中的每个“环境项”元素。我目前有类似以下内容....
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select="rpc-reply/multi-routing-engine-results/multi-routing-engine-item">
...
<xsl:for-each select="./environment-information/environment-item">
.....
</xsl:for-each>
</block>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
但是,当它到达第二个循环时,我的代码不起作用<xsl:for-each select="./environment-information/environment-item">
。我怀疑这与<environment-information xmlns="http://xml.juniper.net/junos/11.4X27/junos-chassis">
元素有关。
我应该使用一些特殊的语法吗?