我正在使用以下 XSL 来转换 XML:
<xsl:for-each select="rule">
<xsl:for-each select="tooling/tools/tool">
<Cell ss:StyleID="style_8_DarkBlueHeading">
<Data ss:Type="String">
<xsl:value-of select="current()"/>
</Data>
</Cell>
</xsl:for-each>
</xsl:for-each
有问题的 XML 的 2 个示例节点是:
<rule id="scr0001" type="Software/Firmware">
<tooling>
<tools>
<tool coverageLevel="Full" checkers="" comment="">PC-Lint v9.00</tool>
<tool coverageLevel="Unknown" checkers="" comment="">RSM v7.75</tool>
<tool coverageLevel="Full" checkers="" comment="">Insight v9.2</tool>
<tool coverageLevel="Full" checkers="" comment="">Logiscope v6.6</tool>
<tool coverageLevel="Unknown" checkers="" comment="">Compass/ROSE v0.9.5a</tool>
<tool coverageLevel="Full" checkers="" comment="">TBsecure v8.1.1</tool>
<tool coverageLevel="Unknown" checkers="" comment="">Code sonar v3.5</tool>
</tools>
</tooling>
</rule>
<rule id="scr0002" type="Software/Firmware">
<tooling>
<tools>
<tool coverageLevel="Unknown" checkers="" comment="">Insight v9.2</tool>
<tool coverageLevel="None" checkers="" comment="">FxCop v10.0</tool>
<tool coverageLevel="None" checkers="" comment="">CodeIt.Right v2.0</tool>
<tool coverageLevel="None" checkers="" comment="">dotTEST v9.2.1</tool>
<tool coverageLevel="Unknown" checkers="" comment="">Splint v3.1.2</tool>
<tool coverageLevel="Unknown" checkers="" comment="">Compass/ROSE v0.9.5a</tool>
<tool coverageLevel="Full" checkers="" comment="">TBsecure v8.1.1</tool>
<tool coverageLevel="Unknown" checkers="" comment="">Code sonar v3.5</tool>
</tools>
</tooling>
</rule>
可以看出,“工具”节点有些是通用的,有些是唯一的。我想要实现的是在生成的 excel 文件中获得一组独特的工具节点。
现在,excel 文件将所有节点列为列。
我会感谢任何指导。
问候