XML to XML Transformation through XSL

The Input XML is

                                    <CELL col="F">
                                  <Para apprevbar="F">s281w0-602
                                   <a>AB</a>
                                     <b>CD <d> RT </d> 78</b>
                                      <c>EF</c>....etc
                                    </Para>
                                  </CELL>

I want the output as

                                <CELL col="F">
                         <Para apprevbar="F">s281w0-602
                               AB
                               CD
                               RT
                               78
                               EF...etc
                              </Para>
                              </CELL>

Can you please tell me any xsl ideas to transform the above input xml to get the above output.

Upvotes: 0

Views: 86

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167746

Use the identity transformation template

<xsl:template match="@* | node()">
  <xsl:copy>
    <xsl:apply-templates select="@* | node()"/>
  </xsl:copy>
</xsl:template>

and

<xsl:template match="a">
  <xsl:apply-templates/>
</xsl:template>

Based on your comments and your edits you seem to want to strip all element content from the Para element so you can use

<xsl:template match="Para//*">
  <xsl:apply-templates/>
</xsl:template>

to continue with the approach taken so far but you could as well use

<xsl:template match="Para">
  <xsl:copy>
    <xsl:apply-templates select="@*"/>
    <xsl:value-of select="."/>
  </xsl:copy>
</xsl:template>

to simply output the string value of the Para element as the new content.

Upvotes: 1

Related Questions