Subject: Re: [xsl] removing tab formatting during XSLT? From: Joerg Heinicke <joerg.heinicke@xxxxxx> Date: Thu, 10 Oct 2002 22:08:14 +0200 |
<!-- identity transformation template --> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template>
<xsl:template match="text()"> <xsl:value-of select="normalize-space()"/> </xsl:template>
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"?> <A> <B att="att">a</B> <C>b</C> <D>c</D> </A>
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="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/> <xsl:strip-space elements="*"/> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="*"> <!-- recreate the element --> <xsl:element name="{name()}"> <!-- copy existing attributes--> <xsl:for-each select="@*"> <xsl:copy/> </xsl:for-each> <xsl:apply-templates/> </xsl:element> </xsl:template> <xsl:variable name="tab">nbsp;</xsl:variable> <xsl:template match="text()"> <xsl:value-of select="translate(. , $tab , '')"/> </xsl:template>
<!-- original attempt
<xsl:template match="text()">
<xsl:value-of select="normalize-space(.)"/>
</xsl:template>
-->
</xsl:stylesheet>
I want to remove the tabs because this significantly reduces the size of the file.
Thanks in advance.
cheers
Malcolm
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] removing tab formatting durin, Macaulay,Malcolm (US | Thread | RE: [xsl] removing tab formatting d, Michael Kay |
RE: [xsl] calculate unique items in, Richard Lander | Date | Re: [xsl] calculate unique items in, Joerg Heinicke |
Month |