愚蠢,簡單的問題。當我輸出文本時,它仍然基於我的格式化/縮進XSL結構獲取標籤。我如何指示變形器忽略樣式表中的間距,同時仍保持整齊格式化?XSLT去除文本輸出中的所有選項卡
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:apply-templates select="Foo/Bar"></xsl:apply-templates>
</xsl:template>
<xsl:template match="Bar">
<xsl:for-each select="AAA"><xsl:for-each select="BBB"><xsl:value-of select="Label"/>|<xsl:value-of select="Value"/><xsl:text> </xsl:text></xsl:for-each></xsl:for-each>
</xsl:template>
</xsl:stylesheet>
由生產線生產輸出線無標籤:
SomeLabel|SomeValue
SomeLabel|SomeValue
SomeLabel|SomeValue
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:apply-templates select="Foo/Bar"></xsl:apply-templates>
</xsl:template>
<xsl:template match="Bar">
<xsl:for-each select="AAA">
<xsl:for-each select="BBB">
<xsl:value-of select="Label"/>|<xsl:value-of select="Value"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
生成輸出與標籤:
SomeLabel|SomeValue
SomeLabel|SomeValue
SomeLabel|SomeValue
更新: 添加此不能解決問題:
<xsl:output method="text" indent="no"/>
<xsl:strip-space elements="*"></xsl:strip-space>
這是人爲的,但你能想象的XML看起來是這樣的:
<Foo>
<Bar>
<AAA>
<BBB>
<Label>SomeLabel1</Label>
<Value>SomeValue1</Value>
</BBB>
<BBB>
<Label>SomeLabel2</Label>
<Value>SomeValue2</Value>
</BBB>
<BBB>
<Label>SomeLabel3</Label>
<Value>SomeValue3</Value>
</BBB>
</AAA>
</Bar>
</Foo>
你已經張貼不會產生結果的XSLT代碼你聲稱:http://xsltransform.net/pPgCcop –
@ michael.hor257k已更新。縮進在xsltransform上是正確的。淨,但我在visual studio和記事本++中運行這個,並且當XSLT縮進時,插入到輸出中的標籤。 – kakridge