开发者

XSLT: how to prevent the XSLT code from generating redundant blank-space in output xml

With my XSL code, whenever I delete an element .. It will introduce a blank-line-space in output xml .. which hampers the Tree-structure look of the XML .. Can you please suggest me .. How to get rid of it .. ?

Here are sample the sample codes ..

Sample XML:

<tag1>
  <tag1_1>text</tag1_1>
  <tag1_2 delete="Y">text</tag1_2>
  <tag1_3>
    <tag1_3_1></tag1_3_1>
    <tag1_3_2 delete="Y">
      <tag_child>text</tag_child>
    </tag1_3_2>
  </tag1_3>
</tag1>

Sample XSLT:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
    <xsl:output method="xml" indent="yes"/>
    <xsl:template match="@* | node()">
        <xsl:copy>
            <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
    </xsl:template>
  <xsl:template match="//*[@delete='Y']"/>
</xsl:stylesheet>

Resulting XML:

<tag1>
  <tag1_1>text</tag1_1>

  <tag1_3>
    <tag1_3_1 />

  </tag1_3>
</tag开发者_Go百科1>


You could use xsl:strip-space:

<xsl:strip-space elements="*"/> 
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜