dip-sensor
데이터를보고하기 위해이 새로운 추가 작업을하고 있습니다. 하지만 apply-templates
은 첫 번째 노드 인 <filter>
만 확인하고 나머지는 확인하지 않는 문제가 있습니다.XSL1.0 - Apply-templates는 첫 번째 자식 노드 만 사용합니다.
또한 apply-templates
대신 for-each
을 사용하는 코드를 변경해 보았지만 아직 행운은 없습니다.
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>[email protected]</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>[email protected]</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
보여하지만이 <filter-list>
에 세 <filter>
노드에서 모든 source/type
및 destination/type
을 캡처해야하기 때문에 663143
을 표시해야합니다.
모든 금액은 <dlp-sensor>
일 수 있으며 각각의 금액은 <filter>
일 수 있습니다. 내가 도대체 뭘 잘못하고있는 겁니까? <xsl:for-each select="dlp-sensor/filter-list"> followed with <**xsl:apply-templates** select="filter">
같은 적용-템플릿 = "필터 목록/필터"모드 = "필터링"을 선택 />
도 아마 시도 뭔가 :
< XSL :
코드가 제대로 작동하는 것 같습니다. 나머지 XSLT의 모습은 무엇입니까? 너 어떻게 지내니? 어떤 프로세서를 사용하고 있습니까? –
무엇을 하든지, 보여준 코드에는 오류가 없습니다. 귀하의 질문에서 그대로 복사, 코드 작동 : http://www.xmlplayground.com/YlH4I0 – Tomalak