当前Xpath
//devices/device/@* | //devices/device/CMDB/HPSM_CI_ID结果:
Linux,10.37.99.82,ELROND-LC3,ELROND,CI146826,
Windows,40.37.199.822,Mordor-LC3,Mordor,
CI19765
,
Windows Events (NIC),10.30.70.45, BALROG-LC2, BALROG, Wcuties, fad.822,Mordor-LC3,
CI19765
;注意,它返回查询的所有迭代。当我添加一个concat和“AC.26”时,它会返回:
Linux,CI46826|本质上,我只是想让它这样做:
Linux, 10.37.99.82, ELROND-LC3, ELROND, CI146826 | Windows, 40.37.199.822, Mordor-LC3, Mordor, CI19765 | Windows Events (NIC), 10.30.70.45, BALROG-LC2, BALROG, Wcuties, fad.822, Mordor-LC3, CI19765 |以下是XML:
<device-attributes>
<!--
Attribute definitions
-->
<attribute-definitions>
<category name="Location">
<attribute name="Country"/>
<attribute name="State"/>
<attribute name="County"/>
<attribute name="City"/>
<attribute name="Campus"/>
<attribute name="Building"/>
<attribute name="Floor"/>
<attribute name="Room"/>
</category>
<category name="Organization">
<attribute name="Company"/>
<attribute name="Division"/>
<attribute name="BusinessUnit"/>
<attribute name="Department"/>
<attribute name="Group"/>
<attribute name="Contact"/>
</category>
<category name="Owner">
<attribute name="Manager"/>
<attribute name="PrimaryAdministrator"/>
<attribute name="BackupAdministrator"/>
</category>
<category name="Physical">
<attribute name="Manufacturer"/>
<attribute name="SerialNumber"/>
<attribute name="AssetTagNumber"/>
<attribute name="Voltage"/>
<attribute name="UPSProtected"/>
<attribute name="RackHeight"/>
<attribute name="Depth"/>
<attribute name="BTUOutput"/>
</category>
<category name="Function">
<attribute name="PrimaryRole"/>
<attribute name="SubRole1"/>
<attribute name="SubRole2"/>
</category>
<category name="Importance">
<attribute name="Value"/>
</category>
<category name="Vulnerability">
<attribute name="Value"/>
</category>
<category name="Zone">
<attribute name="WAN"/>
<attribute name="LAN"/>
<attribute name="Security"/>
<attribute name="Operational"/>
</category>
<category name="Properties">
<attribute name="CustomName"/>
<attribute name="ResolvedName"/>
<attribute name="Description"/>
</category>
<category name="SystemInformation">
<attribute name="DomainName"/>
<attribute name="SystemName"/>
<attribute name="Identifier"/>
<attribute name="Description"/>
</category>
<category name="CMDB">
<attribute name="HPSM_CI_ID"/>
<attribute name="HPSM_CI_COMMON_NAME"/>
<attribute name="ASR_TIER_SCORE"/>
<attribute name="NEZUMI_SCORE"/>
<attribute name="ACAF_SCORE"/>
<attribute name="ACAF_CRITICALITY"/>
</category>
</attribute-definitions>
<devices>
<!--
Devices
-->
<device ipaddr="10.37.99.82" dtype="Linux" site="ELROND" node="ELROND-LC3">
<Importance>
<Value>
1
</Value>
</Importance>
<Vulnerability>
<Value>
1
</Value>
</Vulnerability>
<Properties>
<ResolvedName>
kdcpmblrobo04.kdc.capitalone.com
</ResolvedName>
</Properties>
<CMDB>
<HPSM_CI_ID>
CI146826
</HPSM_CI_ID>
<HPSM_CI_COMMON_NAME>
kdcpmblrobo04
</HPSM_CI_COMMON_NAME>
</CMDB>
</device>
<device ipaddr="40.37.199.822" dtype="Windows" site="Mordor" node="Mordor-LC3">
<Importance>
<Value>
1
</Value>
</Importance>
<Vulnerability>
<Value>
1
</Value>
</Vulnerability>
<Properties>
<ResolvedName>
kdcpmblrobo04.kdc.capitalone.com
</ResolvedName>
</Properties>
<CMDB>
<HPSM_CI_ID>
CI19765
</HPSM_CI_ID>
<HPSM_CI_COMMON_NAME>
FaceFace
</HPSM_CI_COMMON_NAME>
</CMDB>
</device>
<device ipaddr="10.30.70.45" dtype="Windows Events (NIC)" site="BALROG" node="BALROG-LC2">
<Importance>
<Value>
1
</Value>
</Importance>
<Vulnerability>
<Value>
1
</Value>
</Vulnerability>
<Properties>
<ResolvedName>
sqlp05
</ResolvedName>
</Properties>
<CMDB>
<ASR_TIER_SCORE>
</ASR_TIER_SCORE>
<NEZUMI_SCORE>
</NEZUMI_SCORE>
<ACAF_SCORE>
</ACAF_SCORE>
<ACAF_CRITICALITY>
Low
</ACAF_CRITICALITY>
</CMDB>
</device>
<device ipaddr="fad.822" dtype="Wcuties" node="Mordor-LC3">
<Importance>
<Value>
1
</Value>
</Importance>
<Vulnerability>
<Value>
1
</Value>
</Vulnerability>
<Properties>
<ResolvedName>
kdcpmblrobo04.kdc.capitalone.com
</ResolvedName>
</Properties>
<CMDB>
<HPSM_CI_ID>
CI19765
</HPSM_CI_ID>
<HPSM_CI_COMMON_NAME>
FaceFace
</HPSM_CI_COMMON_NAME>
</CMDB>
</device>
</devices>
</device-attributes>我试过了
concat(//device/device/@*, //devices/device/CMDB/HPSM_CI_ID, '|')但是没有用,因为它在第一次迭代之后截断了答案。
发布于 2013-12-11 18:46:09
你需要使用每条指令。
concat(//device/device/@*, //devices/device/CMDB/HPSM_CI_ID, '|')将选择所有节点,而不是对每个节点进行迭代。你需要这样的东西:
<xsl:for-each select="//device/device/@* | //devices/device/CMDB/HPSM_CI_ID">
<xsl:value-of select="."/><xsl:text>|</xsl:text>
</xsl:for-each>发布于 2013-12-12 09:38:18
在XPath 2.0中,您可以做到
string-join((//device/device/@*, //devices/device/CMDB/HPSM_CI_ID), '|')如果您不能使用XPath 2.0,那么在您的问题中清楚地说明这一点是个好主意。
https://stackoverflow.com/questions/20527308
复制相似问题