Re: [xsl] removing tab formatting during XSLT?

Subject: Re: [xsl] removing tab formatting during XSLT?
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Thu, 10 Oct 2002 22:08:14 +0200
This stylesheet is only for removing useless whitespace characters?

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

<xsl:template match="text()">
    <xsl:value-of select="normalize-space()"/>

As you can see it's only a simpler version of your stylesheet. This means also, that your "original attempt" should work. I can't see why it doesn't.



Macaulay,Malcolm (US) wrote:
Could someone please enlighten me on how I can remove tab formatting from my resulting XML.

Here's an example:

Source XML:

<?xml version="1.0"?>
	<B att="att">a</B>

Desired output XML (i.e. the same as input but with all tabs removed):

<?xml version="1.0"?><A><B att="att">a</B><C>b</C><D>c</D></A>

XSLT (which doesn't work):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="";>
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
	<xsl:strip-space elements="*"/>
	<xsl:template match="/">
	<xsl:template match="*">
		<!-- recreate the element -->
		<xsl:element name="{name()}">
			<!-- copy existing attributes-->
			<xsl:for-each select="@*">
	<xsl:variable name="tab">nbsp;</xsl:variable>
	<xsl:template match="text()">
		<xsl:value-of select="translate(. , $tab , '')"/>

<!-- original attempt
<xsl:template match="text()">
<xsl:value-of select="normalize-space(.)"/>

I want to remove the tabs because this significantly reduces the size of the file.

Thanks in advance.



XSL-List info and archive:

Current Thread