我正在创建一些XSL来将XML转换为文本(最终将是CSV)。我正在使用VS2008。当我使用编辑器创建XSL时,转换后的输出将根据我的XSL缩进。但是,如果我编辑XSL并删除它正确输出的格式化空白,那么这样做是一个噩梦。
是否有一些XSL预处理程序命令或标记可以防止这种情况发生?我想忽略XSL中的任何空白,只使用
<!CDATA[]]>
或
<xsl:text>
.
我的XSL如下-这将缩进输出
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="text" indent="no"/>
<!-- @* is all class attributes -->
<xsl:template match="/">
<xsl:text>CSV Output</xsl:text>
<!-- Start of output -->
<xsl:for-each select="//rows/row">
<![CDATA[row id=]]><xsl:value-of select="(@id)"/>
</xsl:for-each>
<!-- OK, that is the end of the file -->
<![CDATA[<EOF>]]>
</xsl:template>
</xsl:stylesheet>
其输出如下:
CSV Output
row id=0
row id=1
<EOF>
但是,以下输出正确:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="text" indent="no"/>
<!-- @* is all class attributes -->
<xsl:template match="/">
<xsl:text>CSV Output</xsl:text>
<!-- Start of output -->
<xsl:for-each select="//rows/row">
<![CDATA[row id=]]><xsl:value-of select="(@id)"/>
</xsl:for-each>
<!-- OK, that is the end of the file -->
<![CDATA[<EOF>]]>
</xsl:template>
</xsl:stylesheet>
输出正确如下:
CSV Output
row id=0
row id=1
<EOF>
我还想控制新行的位置。在我的XSL中,我不会让它包含一个。
请帮助!!
谢谢,
安德仕