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

[xsl] Replace content of element, then transform it...


Subject: [xsl] Replace content of element, then transform it...
From: <trond.huso@xxxxxx>
Date: Thu, 30 Aug 2012 11:08:58 +0000

Hi,

I have the following XSLT.
<xsl:template match="body">
        <body>
            <xsl:value-of select="." disable-output-escaping="yes"/>
        </body>
    </xsl:template>

    <xsl:template match="leadtext">
        <leadtext>
            <xsl:value-of select="." disable-output-escaping="yes"/>
        </leadtext>
    </xsl:template>


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

Which does what is intended. Just that I want to not output it, but start w=
orking on it in a phase-two process.
So I tried this

<xsl:template match="body">
        <body>
            <xsl:value-of select="." disable-output-escaping="yes"/>
        </body>
    </xsl:template>

    <xsl:template match="leadtext">
        <leadtext>
            <xsl:value-of select="." disable-output-escaping="yes"/>
        </leadtext>
    </xsl:template>


    <xsl:template match="node()|@*">
        <xsl:variable name="foo">
        <xsl:copy>
            <xsl:apply-templates select="node()|@*"/>
        </xsl:copy>
        </xsl:variable>
        <xsl:apply-templates select="$foo" mode="phase2" />
    </xsl:template>
<!-- Error message:
Description: Cannot create an attribute node (id) whose parent is a documen= t
node
-->

After reading about how this works, I now understand why I am getting the e=
rror. Is there another alternative to make this possible in one document, o= r
do I have to send the output to a new document?

Best regards,

Trond Husx
System Developer
Mobile : +47 450 35 715
E-mail : trond.huso@xxxxxx
www.ntb.no


Current Thread