0

我正在研究报告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/typedestination/type<filter><filter-list>

可以有任意数量,<dlp-sensor>每个可能有不同数量的<filter>. 我究竟做错了什么?

4

1 回答 1

1

您确实有拼写错误:

< xsl:apply-templates select="filter-list/filter" mode="filtering"/>

也许也可以尝试类似的东西 <xsl:for-each select="dlp-sensor/filter-list"> followed with <**xsl:apply-templates** select="filter">

于 2014-04-15T18:51:05.913 回答