晚上好,所有人。我是XML的新手,今天花了很多时间试图弄清楚这段代码到底在做什么。我花了很多时间测试/重写我在Free Online XSL Transformer(XSLT)上提供的内容 - FreeFormatter.com。但我正式陷入困境
我们使用可以提取XML提要的工具,虽然我是XML的新手,我通常可以修复一些工作,但不是今晚。 我必须编写一个翻译,它将使用XLS文件翻译我的XML。 XLS是我被困的地方。
问题如下: 我有多个ReportHost,只有一个报告 当我通过变换器运行以下代码时,我没有获得有关我的变量调出中的Host-IP,Host-FQDN,System-type,Operating-system的任何信息。我可以看到XML中的数据正在提供它但不在我的输出中。任何和所有的帮助总是非常感谢!
XLS如下:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.archer-tech.com/">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:template match="NessusClientData_v2">
<ArcherRecords>
<xsl:apply-templates select="Report" />
</ArcherRecords>
</xsl:template>
<xsl:template match="Report">
<xsl:for-each select="ReportHost">
<xsl:variable name="a" select="@name"/>
<xsl:variable name="host" select="/NessusClientData_v2/Report/ReportHost[@name=$a]"/>
<xsl:variable name="x" select="host-ip"/>
<xsl:variable name="y" select="host-fqdn"/>
<xsl:variable name="z" select="system-type"/>
<xsl:variable name="os" select="operating-system"/>
<xsl:variable name="extract_ip" select="$host/HostProperties/tag[@name=$x]"/>
<xsl:variable name="extract_netbios" select="$host/HostProperties/tag[@name=$y]"/>
<xsl:variable name="extract_type" select="$host/HostProperties/tag[@name=$z]"/>
<xsl:variable name="extract_operating-system" select="$host/HostProperties/tag[@name=$os]"/>
<xsl:for-each select="ReportItem">
<ArcherRecord>
<IP><xsl:value-of select="$extract_ip/text()"/></IP>
<Device_Name><xsl:value-of select="$extract_netbios/text()"/></Device_Name>
<Device_Type><xsl:value-of select="$extract_type/text()"/></Device_Type>
<Operating_System><xsl:value-of select="$extract_operating-system/text()"/></Operating_System>
<port><xsl:value-of select="@port"/></port>
<svc_name><xsl:value-of select="@svc_name"/></svc_name>
<protocol><xsl:value-of select="@protocol"/></protocol>
<raw_severity><xsl:value-of select="@severity"/></raw_severity>
<pluginID><xsl:value-of select="@pluginID"/></pluginID>
<pluginName><xsl:value-of select="@pluginName"/></pluginName>
<pluginFamily><xsl:value-of select="@pluginFamily"/></pluginFamily>
<xsl:variable name="extract_port" select="@port"/>
<xsl:variable name="details" select="/NessusClientData_v2/Report/ReportHost/ReportItem[@port=$extract_port]"/>
<solution><xsl:value-of select="$details/solution/text()"/></solution>
<risk><xsl:value-of select="$details/risk_factor/text()"/></risk>
<description><xsl:value-of select="$details/description/text()"/></description>
<output><xsl:value-of select="$details/plugin_output/text()"/></output>
<cvss_temporal_score><xsl:value-of select="$details/cvss_temporal_score/text()"/></cvss_temporal_score>
<cvss_base_score><xsl:value-of select="$details/cvss_base_score/text()"/></cvss_base_score>
<cpe><xsl:value-of select="$details/cpe/text()"/></cpe>
<cve><xsl:value-of select="$details/cve/text()"/></cve>
</ArcherRecord>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
XML的片段
<NessusClientData_v2>
<Report name="CCRI Network Scan" xmlns:cm="http://www.nessus.org/cm">
<ReportHost name="1328.1527.1142.128">
<HostProperties>
<tag name="LastAuthenticatedResults">1450111187</tag>
<tag name="Credentialed_Scan">true</tag>
<tag name="policy-used">b4c1a0418/FSO Scan Policy</tag>
<tag name="patch-summary-total-cves">2</tag>
<tag name="cpe">cpe:/o:linux:linux_kernel</tag>
<tag name="os">linux</tag>
<tag name="smb-login-used">so</tag>
<tag name="ssh-fingerprint">SSH-2.0-Cisco-1.25
</tag>
<tag name="cpe-0">cpe:/o:cisco:ios:15.1 -> Cisco IOS 15.1</tag>
<tag name="mac-address">e0:129:82:d1
00:</tag>
<tag name="system-type">router</tag>
<tag name="operating-system">CISCO IOS 15.1(2)SG6</tag>
<tag name="ssh-auth-meth">password</tag>
<tag name="ssh-login-used">sagalliano</tag>
<tag name="local-checks-proto">ssh</tag>
<tag name="traceroute-hop-5">1338.13357.1342.138</tag>
<tag name="traceroute-hop-4">1383.1357.1342.31</tag>
<tag name="traceroute-hop-3">1338.1632.1356.2337</tag>
<tag name="traceroute-hop-2">1538.3237.24.138</tag>
<tag name="traceroute-hop-1">1358.2433.2333.252</tag>
<tag name="traceroute-hop-0">1538.2433.331.1330</tag>
<tag name="HOST_END">Mon Dec 14 16:39:47 2015</tag>
<tag name="host-ip">14138.12457.12442.118</tag>
<tag name="HOST_START">Mon Dec 14 16:36:31 2015</tag>
</HostProperties>
请求输出
<ArcherRecord>
<IP />
<Device_Name />
<Device_Type />
<Operating_System />
<port>0</port>
<svc_name>general</svc_name>
<protocol>tcp</protocol>
<raw_severity>0</raw_severity>
<pluginID>47864</pluginID>
<pluginName>Cisco IOS Version</pluginName>
<pluginFamily>CISCO</pluginFamily>
<solution>n/a</solution>
<risk>None</risk>
<description>The remote host is running IOS, an operating system for Cisco routers.