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.
精彩评论