[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] combination of copy-of and apply-templates


Subject: Re: [xsl] combination of copy-of and apply-templates
From: Nico Van Cleemput <Nicolas.VanCleemput@xxxxxxxx>
Date: Wed, 22 Nov 2006 13:11:23 +0100

this helped me quite a bit already. I made this template:

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

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

    <xsl:template match="//mytag">
        blabla
    </xsl:template>

This does exactly what I want except for one thing: it also copies the myhtml tag. What am I doing wrong?


Nevermind, I already found what I was doing wrong:


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

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

    <xsl:template match="//mytag">
        blabla
    </xsl:template>

Gives the desired result.

Thanks very much.

Nico


Current Thread