Re: [xsl] The identity transform and attributes

Subject: Re: [xsl] The identity transform and attributes
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Mon, 21 Jan 2008 11:34:34 +0000
> <xsl:template match="element()">
>     <xsl:copy>
>         <xsl:apply-templates select="@*,node()"/>
>     </xsl:copy>
> </xsl:template>
> (The "," in place of "|" is a minor optimization that recent Saxon releases
> do anyway - it avoids an unnecessary merge/deduplication of the sequence of
> attributes with the sequence of children.)

Nice - a definite change for the 2.0 version.

> Btw, it is never possible to override the text() of an attribute. An
> attribute does not have children.

Indeed, I probably should repeat that to myself a few times.  It's an
odd concept to me for some reason... Why shouldn't an attribute node
have a child text node?  I guess it's because it's not needed due the
limited content allowed for an attribute?... or for historical
reasons?... or perhaps some fundamental markup principle that I'm
unaware of after all this time :)

It's certainly not intuitive that when you what to just change the
attribute's value you have to create a new attribute node - something
that's not helped by the usual indentity template.

Andrew Welch

Current Thread