Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: replace attribute value

From: Martin Honnen <mahotrash@-----.-->
To: 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/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent