這是因爲Attribute Value Normalization。換行符正在被標準化爲空格。保留這些的唯一方法是在屬性值中使用字符引用。
舉例來說,如果你有這樣的XML:
<entry ID="93" ENTRY_TYPE="Text1" ENTRYNM="First line:
Second line
third line
fourth line" ENTRY_DT="12-Jan-2004"/>
這XSLT(略XSL-FO的命名空間爲簡潔):
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/*">
<block linefeed-treatment="preserve">
<xsl:value-of select="@ENTRYNM"/>
</block>
</xsl:template>
</xsl:stylesheet>
你會得到這樣的輸出(標準化):
<block linefeed-treatment="preserve">First line: Second line third line fourth line</block>
如果在輸入中將換行符更改爲字符引用:
<entry ID="93" ENTRY_TYPE="Text1" ENTRYNM="First line:

Second line

third line

fourth line" ENTRY_DT="12-Jan-2004"/>
相同XSLT現在產生這樣的輸出:
<block linefeed-treatment="preserve">First line:
Second line
third line
fourth line</block>
這裏是正常化的另一個視覺例子...
如果我們採取的第一個XML輸入例如:
<entry ID="93" ENTRY_TYPE="Text1" ENTRYNM="First line:
Second line
third line
fourth line" ENTRY_DT="12-Jan-2004"/>
並嘗試基於

:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/*">
<block linefeed-treatment="preserve">
<xsl:for-each select="tokenize(@ENTRYNM,'
')">
<token><xsl:value-of select="."/></token>
</xsl:for-each>
</block>
</xsl:template>
</xsl:stylesheet>
我們在輸出得到一個單一的token
:
<block linefeed-treatment="preserve">
<token>First line: Second line third line fourth line</token>
</block>
如果我們使用第二XML輸入例如(與

引用取代了中斷),我們得到4個獨立的token
S:
<block linefeed-treatment="preserve">
<token>First line:</token>
<token> Second line</token>
<token> third line</token>
<token> fourth line</token>
</block>