[英]XSL1.0 - Apply-templates only takes the first child node
我正在研究此新功能,以报告dip-sensor
数据。 但是我遇到了一个问题,即apply-templates
仅检查第一个<filter>
节点,而不检查其余的节点。
我也尝试过更改代码以使用for-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
因为它应该已经捕获了<filter-list>
所有三个<filter>
节点的所有source/type
和destination/type
。
可以有任意数量的<dlp-sensor>
并且每个都有不同数量的<filter>
。 我究竟做错了什么?
您确实有拼写错误:
< xsl:apply-templates select =“过滤器列表/过滤器” mode =“过滤” />
也可以尝试类似<xsl:for-each select="dlp-sensor/filter-list"> followed with <**xsl:apply-templates** select="filter">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.