Re: [xsl] remove certain elements but keep children

Subject: Re: [xsl] remove certain elements but keep children
From: George Cristian Bina <george@xxxxxxx>
Date: Mon, 04 Oct 2004 10:22:25 +0300
Hi Ben,

You can start with a copy template:

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


and add another template that will ignore the output element but not its content:


    <xsl:template match="output">
        <xsl:apply-templates select="node()"/>
    </xsl:template>

Best Regards,
George
---------------------------------------------
George Cristian Bina
http://www.oxygenxml.com
<oXygen/> XML Editor and XSLT Editor/Debugger


Ben Munat wrote:
Hello,

I'm writing an app that aggregates html into a single doc. The chunks of html are put into the new document wrapped in "output" tags. These output tags can be intermingled with html tags.

I'm trying to come up with an xpath or xsl template(s) that will remove the output tags, while leaving their child html and without producing duplicate content.

Here's an example doc:

<output>
    <div>
        <output>
            <h1>a header</h1>
            <p>some stuff</p>
            <output>
                <div>
                    <p>foo bar</p>
                </div>
            </output>
            <p>more html</p>
        </output>
    </div>
    <p>some html</p>
</output>

And I want it to be:

<div>
    <h1>a header</h1>
    <p>some stuff</p>
        <div>
            <p>foo bar</p>
        </div>
        <p>more html</p>
</div>
<p>some html</p>


Any ideas?


thanks,

Ben

Current Thread