开发者

Saxon XSLT 2.0 ignore whitespace

开发者 https://www.devze.com 2023-01-19 10:53 出处:网络
I\'m using text output method. And I need to ignore all w开发者_Python百科hitespaces in template.

I'm using text output method. And I need to ignore all w开发者_Python百科hitespaces in template.

<xsl:template ...>
   text
</xsl:template>

I'm receiving in output "     text", but I need only "text".

Thanks.


<xsl:template ...>   
   text   
</xsl:template>   

I'm receiving in output " text", but I need only "text".

Use:

<xsl:template ...> 
   <xsl:text>text</xsl:text> 
</xsl:template>

Explanation: In XSLTAny node that is not white-space-only, doesn't belong to the "xsl namespace" and is a child of an <xsl:template> is output "as-is". The XSLT Spec specifically says:

"A template can also contain text nodes. Each text node in a template remaining after whitespace has been stripped as specified in [3.4 Whitespace Stripping] will create a text node with the same string-value in the result tree"

The <xsl:text> instruction was designed exactly with this use-case in mind. It gives the developer control to specify exactly what text should be output.

0

精彩评论

暂无评论...
验证码 换一张
取 消