Senthil,
Or, two less general solutions, which would work on the sample input given:
#1
<xsl:stylesheet ...>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:copy-of select="/"/>
</xsl:template>
</xsl:stylesheet>
#2 what George had, except
<xsl:template match="text()"/>
These are less general since they remove more than just the carriage
returns. #1 removes all whitespace-only nodes (by trimming them from
the input tree before copying it to output), while #2 removes all
text nodes whatsoever.
Cheers,
Wendell
At 03:26 AM 5/3/2007, George wrote:
Start with a recursive copy template then match the text nodes and
process the new lines, for instance replace them with spaces:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of select="translate(., ' ',' ')"/>
</xsl:template>
</xsl:stylesheet>
Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina - http://aboutxml.blogspot.com/
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Senthilkumaravelan K wrote:
Hi
I want to flatten the XML node structure to single line,
I tried indent=no and it does not work for me.
Please any suggestions.
I use the following xslt
<?xml version="1.0" encoding='UTF-8'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="no" />
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
input
<node1>
</Item1>
</Item1>
</Item1>
</Item1>
</Item1>
</Item1>
</Item1>
</node1>
output
<node1></Item1></Item1></Item1>..</node1>
Regards,
Senthil
======================================================================
Wendell Piez
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--