我試圖用XML創建位置文件。我創建了XSLT並且工作正常,除非該字段填充空格。在這種情況下,XSL只返回一個空格。我正在使用MSXML(6.0)。將XML轉換爲位置文本文件時沒有剝離空間的幫助
我都試過,沒有運氣以下:
<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) –