我的XML看起来像这样:
<NewDataSet>
<Table>
<Column1>"Date = "2017/11/10", ImageType = "A", Doctype = "ABC", DOCTYPE_DESCR = "ABC data file", Total = "2"</Column1>
</Table>
<Table>
<Column1>"Date = "2017/11/10", ImageType = "b", Doctype = "DEF", DOCTYPE_DESCR = "DEF chart file", Total = "2"</Column1>
</Table>
<Table>
<Column1>"Date = "2017/11/10", ImageType = "C", Doctype = "HIJ", DOCTYPE_DESCR = "HIJ PDF ", Total = "2"</Column1>
</Table>
<Table>
<Column1>"Date = "2017/11/10", ImageType = "d", Doctype = "KLM", DOCTYPE_DESCR = "KLM file.", Total = "1"</Column1>
</Table>
</NewDataSet>
这是我想要的输出文本文件。目前,我的程序正在输出单个文本文件,而不是一个具有多个结果的单个文本文件。任何帮助是极大的赞赏。
"Date = "2017/11/10", ImageType = "A", Doctype = "ABC", DOCTYPE_DESCR = "ABC data file", Total = "2"
"Date = "2017/11/10", ImageType = "B", Doctype = "DEF", DOCTYPE_DESCR = "DEF chart file", Total = "2"
"Date = "2017/11/10", ImageType = "C", Doctype = "HIJ", DOCTYPE_DESCR = "HIJ PDF", Total = "2"
"Date = "2017/11/10", ImageType = "D", Doctype = "KLM", DOCTYPE_DESCR = "KLM file", Total = "1"
这是我的XSLT
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" indent="yes"/>
<!--match the root node-->
<xsl:template match="NewDataSet">
</xsl:element>
</xsl:template>
</xsl:stylesheet>
答案 0 :(得分:0)
如果使用XSLT 2.0
是一个选项,您可以使用方法xsl:result-document
:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:template match="NewDataSet">
<xsl:result-document method="text" href="NewDataSet.txt">
<xsl:for-each select="/NewDataSet/Table/Column1">
<xsl:copy-of select="."/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:result-document>
</xsl:template>
</xsl:stylesheet>