【发布时间】:2011-03-15 19:49:00
【问题描述】:
我有一个动态生成值的 xml 文档,我需要使用 xslt 将这些数据导出到 excel。出于测试目的,我创建了一个示例 xml:-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<ucdetector>
<!--COPY_RIGHT-->
<statistics/>
<markers>
<!--Sample XML_INFO-->
<marker>
<description>Desc</description>
<classRef>Test1</classRef>
<classRef>Test2</classRef>
<classRef>Test3</classRef>
<markerType>Class PreferenceInitializer has 8 references</markerType>
</marker>
</markers>
<problems/>
</ucdetector>
xslt如下:-
= tab = 换行 -->
<!-- First line: about -->
<xsl:value-of
select="concat('Report', '	', /ucdetector/statistics/abouts/about[@name='reportCreated']/value, '
', '
')" />
<!-- Second line: header -->
<xsl:value-of
select="concat('Class Name', '	', 'Referring class
name', '	', 'Class Details', '
')" />
<xsl:for-each select="/ucdetector/markers/marker">
<xsl:variable name="vars">
<xsl:apply-templates select="classRef" />
</xsl:variable>
<xsl:value-of
select="concat(description, '	', $vars, '	', markerType, '
')" />
</xsl:for-each>
我能够将所有数据正确导出到 excel 中,但标签“classRef”中的数据一起显示为“Test1Test2Test3”,但我需要将它们分别放在 excel 的不同列中。 有人可以提供一些线索吗?
【问题讨论】: