Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - replace attribute value [Thread Next] Re: replace attribute valueTo: NULL Date: 8/13/2007 5:05:00 PM Scott Walters wrote: > I'm trying to write xsl to make an exact copy of the input document > except for replacing the value of one of the attributes, but when I run > it, I get an error that says "Attribute and namespace nodes cannot be > added to the parent element after a text, comment, pi, or sub-element > node has already been added" > > Is there a way to do this? > > My XSL looks something like this... > > <xsl:template match="SomeNode"> > <xsl:attribute name="AttrToReplaceValueOf"> > <xsl:valueof select="newValue"/> > </xsl:attribute> > </xsl:template> > > <xsl:template match="node()|@*"> > <xsl:copy> > <xsl:apply-templates select="node()|@*"/> > </xsl:copy> > </xsl:template> Use the indenity transformation template you have above plus the following template that matches your attribute for which you want special treatment: <xsl:template match="@AttrToReplaceValueOf"> <xsl:attribute name="AttrToReplaceValueOf"> <xsl:value-of select="'newValue'"/> </xsl:attribute> </xsl:template> -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
