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

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

Subject: Re: [xsl] Replace content of element, then transform it...
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Thu, 30 Aug 2012 13:26:00 +0200

trond.huso@xxxxxx wrote:

So I tried this

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

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

<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?

Consider to show us minimal but complete XML input and XSLT code samples causing that error, then we should be able to help.

Or try to move the code storing stuff in the variable in the template for the root node e.g.

<xsl:template match="/">
  <xsl:variable name="foo">
  <xsl:apply-templates select="$foo/node()" mode="phase2"/>


	Martin Honnen --- MVP Data Platform Development

Current Thread