这是该问题的示例 XML:
<functions>
<function id="678">
<name>getFunctions()</name>
<File ID="1">
<ncss>0</ncss>
<ccn>0</ccn>
<javadocs>0</javadocs>
</File>
<File ID="2">
<ncss>5</ncss>
<ccn>3</ccn>
<javadocs>1</javadocs>
</File>
<function>
</functions>
我需要输出采用以下格式(表格)
FunctionId Name FileID NCSS CCN Javadocs
678 getFunctions() 1 0 0 0
2 5 3 1
这样做的问题是,当我用其他文本(例如 sourceFile 和 destFile 而不是 File id="1" 和 File id="2")替换 2 个 File 标记时,我能够获得所需的输出。
但我需要它采用上述格式,我不知道如何去做。所有输入将不胜感激。
谢谢你。
这是我在此之前使用的 XSLT 片段:
<center><h1>Function Summary</h1></center>
<table width="1000" border="1" cellspacing="5">
<tr>
<th width="73" align="center" valign="top">ID</th>
<th width="176" align="center" valign="top">Name></th>
<th colspan="2" align="center" valign="top">File</th>
<th colspan="2" align="center" valign="top">NCSS</th>
<th colspan="2" align="center" valign="top">CCN</th>
<th colspan="2" align="center" valign="top">Javadocs</th>
</tr>
<xsl:for-each select="//function">
<tr>
<td align="center" valign="top"> <xsl:value-of select="@id" /> </td>
<td align="left" valign="middle"> <xsl:value-of select="name" /> </td>
<td width="40" align="center" valign="top">srcFile</td>
<td width="50" align="center" valign="top">summaryFile</td>
<td width="63" align="center" valign="top"> <xsl:value-of select="sourceFile/ncss" /> </td>
<td width="80" align="center" valign="top"><xsl:value-of select="summaryFile/ncss" /></td>
<td width="53" align="center" valign="top"><xsl:value-of select="sourceFile/ccn" /></td>
<td width="66" align="center" valign="top"><xsl:value-of select="summaryFile/ccn" /></td>
<td width="108" align="center" valign="top"><xsl:value-of select="sourceFile/javadocs" /></td>
<td width="109" align="center" valign="top"><xsl:value-of select="summaryFile/javadocs" /></td>
</tr>
</xsl:for-each>
</table>
sourceFile 和 summaryFile 已分别替换为 File id="1" 和 File id="2"。输出将只是一个 HTML 表格。