包含另一个xsl文件时,XSL纯文本缩进

时间:2012-01-04 14:54:57

标签: xslt

我有一个纯文本XSL模板,它工作正常,不会缩进。

然后我将另一个XSL模板添加到此模板,其中包含以下行:

<xsl:copy-of select="document('AboutThisMessagePlainText.xsl')"></xsl:copy-of>

渲染XSL时,AboutThisMessagePlainText.xsl文件中的文本是缩进的。

我该如何防止这种情况?

我的完整XSL是:

<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" indent="no" />
<xsl:template match="/Email">
<xsl:text>To Our Valued Customer:</xsl:text>
<xsl:text>&#10;</xsl:text>
<xsl:text>&#10;</xsl:text>
<xsl:text>Welcome, and thank you .....blah blah blah</xsl:text>
<xsl:text>Sincerely,</xsl:text>
<xsl:text>&#10;</xsl:text>
<xsl:text>&#10;</xsl:text>
<xsl:text>My Company</xsl:text>
<xsl:copy-of select="document('AboutThisMessagePlainText.xsl')"></xsl:copy-of>
</xsl:template>
</xsl:transform>

AboutThisMessagePlainText.xsl是:

<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" indent="no" />
<xsl:template match="/">
<xsl:text>About This Message</xsl:text>
<xsl:text>You received this email because you subscribed to our electronic notification service. If you no longer wish to receive electronic notifications, etc...</xsl:text>
</xsl:template>
</xsl:transform>

预期输出结果为:

  

致我们尊贵的客户:

     

欢迎,谢谢你......等等等等等等      

此致

     

我的公司关于此消息您收到此电子邮件是因为您   订阅了我们的电子通知服务。如果你不再   希望收到电子通知等......

     

然而,关于此消息,并且您收到了...缩进。

     

谢谢!

1 个答案:

答案 0 :(得分:0)

我最终通过将AboutThisMessagePlainText.xsl更改为文本文件来解决此问题。这样可以防止文本缩进。

文本文件如下:

<text>



About This Message

You received this email because you subscribed to our electronic notification service. If you no longer wish to receive electronic notifications, etc...
</text>