【发布时间】:2011-07-21 13:49:53
【问题描述】:
我正在尝试使用 XML 创建位置文件。我创建了 XSLT 并且工作正常,除非该字段充满空格。在这种情况下,XSL 只返回一个空格。我正在使用 MSXML (6.0)。
我尝试了以下方法,但没有成功:
<xsl:strip-space elements="*"/>
<xsl:preserve-space elements="*"/>
<fo:block white-space-collapse="false" white-space-treatment="preserve" >
<!-- Code here -->
</fo:block>
这是 XML 输入、XSLT 和输出。
<Document>
<Header>
<Title>Long life to the queen </Title>
<Author>Sam Catnip </Author>
<Year>1996</Year>
<Edition> 1</Edition>
<Price> 12.99</Price>
<Pages> 1244</Pages>
<AuthorNotes> </AuthorNotes>
<Abstract>It is a great book </Abstract>
</Header>
<Header>
<Title>Life and live longer </Title>
<Author>Bill Griffin </Author>
<Year>2001</Year>
<Edition> 1</Edition>
<Price> 2.99</Price>
<Pages> 44</Pages>
<AuthorNotes>Yeah, right </AuthorNotes>
<Abstract>Wishfull thinking </Abstract>
</Header>
</Document>
XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="text"/>
<xsl:template match="//Document">
<xsl:for-each select="./Header">
<xsl:value-of select="./Title"/>
<xsl:value-of select="./Author"/>
<xsl:value-of select="./Year"/>
<xsl:value-of select="./Edition"/>
<xsl:value-of select="./Price"/>
<xsl:value-of select="./Pages"/>
<xsl:value-of select="./AuthorNotes"/>
<xsl:value-of select="./Abstract"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
输出:
Long life to the queen Sam Catnip 1996 1 12.99 1244It is a great book
Life and live longer Bill Griffin 2001 1 2.99 44Yeah, right Wishfull thinking
什么时候应该:
Long life to the queen Sam Catnip 1996 1 12.99 1244 It is a great book
Life and live longer Bill Griffin 2001 1 2.99 44Yeah, right Wishfull thinking
我将非常感谢有关如何解决此问题的任何想法。
谢谢,
艺术
【问题讨论】:
-
您的模板产生所需的输出 (MSXML 6.0)