Q:

How to omit the string inside nested round bracket using XSLT 1.0

I have a node
<statement> 
     SORBITOL, ARÔMES ARTIFICIELS, DIOXYDE DE SILICIUM, ASPARTAME (05 mg / PIECE (01 g)), ACESULFAME-POTASSIUM (03 mg / PIECE (01 g)), STEARATE DE MAGNESIUM. L'ASPARTAME CONTIENT DE LA PHENYLALANINE.
</statement>

And i need to transform this to:
<statement>SORBITOL, ARÔMES ARTIFICIELS, DIOXYDE DE SILICIUM, ASPARTAME , ACESULFAME-POTASSIUM , STEARATE DE MAGNESIUM. L'ASPARTAME CONTIENT DE LA PHENYLALANINE.</statement>

Therefore i need a function that will extract all the text except string inside round bracket recursively so that if more nesting of round bracket present the function should return the string by omitting the bracket and the sting inside bracket. I need it in XSLT version 1.0.

A:

Try this:
XSLT 1.0
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output indent="yes"/>
    <xsl:template match="statement">
        <xsl:copy>
            <xsl:call-template name="removeRoundBracket">
                <xsl:with-param name="data" select="normalize-space(.)"/>
            </xsl:call-template>
        </xsl:copy>
    </xsl:template>

    <xsl:template name="removeRoundBracket">
        <xsl:param name="data"/>
        <xsl:choose>
            <xsl:when test="contains(substring-before($data, ')'), '(')">
                <xsl:value-of select="substring-before($data, '(')"/>
                <xsl:call-template name="removeRoundBracket">
                    <xsl:with-param name="data" select="substring-after($data, ')')"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:when test="contains($data, ')')">
                <xsl:call-template name="removeRoundBracket">
                    <xsl:with-param name="data" select="substring-after($data, ')')"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$data"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
</xsl:stylesheet>

See transformation at http://xsltransform.net/93nvfck
OUTPUT
<statement>SORBITOL, ARÔMES ARTIFICIELS, DIOXYDE DE SILICIUM, ASPARTAME , ACESULFAME-POTASSIUM , STEARATE DE MAGNESIUM. L'ASPARTAME CONTIENT DE LA PHENYLALANINE.</statement>

