我正在研究报告dip-sensor
数据的新增功能。但是我遇到了一个问题,即apply-templates
只检查第一个<filter>
节点而不检查其余节点。
我也尝试将代码更改为使用 afor-each
而不是apply-templates
,但仍然没有运气。
XML 文件:
...
</dlp-sensor>
<dlp-sensor>
<name>DLPSensor.1</name>
<description/>
<property>0</property>
<filter-list>
<filter>
<enabled>true</enabled>
<source>
<type>6</type>
<any/>
</source>
<destination>
<type>6</type>
<any/>
</destination>
<dlp-action>
<smtp-action>lock</smtp-action>
<action>drop</action>
<log>1</log>
<alarm>0</alarm>
</dlp-action>
</filter>
<filter>
<enabled>true</enabled>
<source>
<type>3</type>
<email-addr>blah@uneducated.edu</email-addr>
</source>
<destination>
<type>1</type>
<host-ip-addr>192.1.1.1</host-ip-addr>
</destination>
<dlp-action>
<smtp-action>block</smtp-action>
<action>drop</action>
<log>1</log>
<alarm>DLP</alarm>
</dlp-action>
</filter>
<filter>
<enabled>true</enabled>
<source>
<type>4</type>
<auth-user>ninja-hacker</auth-user>
</source>
<destination>
<type>3</type>
<email-addr>ceo@companyowner.edu</email-addr>
</destination>
<dlp-action>
<smtp-action>strip</smtp-action>
<action>block</action>
<log>0</log>
<alarm>0</alarm>
</dlp-action>
</filter>
</filter-list>
</dlp-sensor>
<dlp-sensor>
...
XSL v1.0:
<xsl:template match="dlp-sensor" mode="dlpDetails">
<table>
<tr>
<th class="second_head"><xsl:call-template name="getResource"><xsl:with-param name="resID" select="'Source'"/></xsl:call-template></th>
<th class="second_head"><xsl:call-template name="getResource"><xsl:with-param name="resID" select="'Destination'"/></xsl:call-template></th>
</tr>
<xsl:apply-templates select="filter-list/filter" mode="filtering"/>
</table>
</xsl:template>
<xsl:template match="filter" mode="filtering">
<tr>
<td>
<xsl:value-of select="source/type"/>
</td>
<td>
<xsl:value-of select="destination/type"/>
</td>
</tr>
</xsl:template>
结果:
66
期望:
663143
结果只显示66
但应该显示,663143
因为它应该已经捕获了.source/type
destination/type
<filter>
<filter-list>
可以有任意数量,<dlp-sensor>
每个可能有不同数量的<filter>
. 我究竟做错了什么?