tags:

views:

85

answers:

1

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>
</tag1>
+5  A: 

You could use xsl:strip-space:

<xsl:strip-space elements="*"/>
santiiiii
Thanx its done !!!!!!!
infant programmer
Very useful tip! This goes into my personal arsenal.
Peter Lindqvist