Re: Bug in XT? was [RE: Change Attribute Value: Search-n-replace isbetter?]

Subject: Re: Bug in XT? was [RE: Change Attribute Value: Search-n-replace isbetter?]
From: Phil Lanch <phil@xxxxxxxxxxxxxxx>
Date: Wed, 22 Dec 1999 10:36:10 +0000
John Robert Gardner wrote:
> handgun. I'm needing to work with the syntax below b/c the examples have
> to be as light on esoteric syntax as possible (it's for folks even more
> technically disinclined than I repeatedly appear to be) and, quoting the
> XSL/T spec:
> 
> <snip from="http://www.w3.org/TR/xslt#creating-attributes";>
> Adding an attribute to an element replaces any existing attribute of that
> element with the same expanded-name.
> </snip>
> 
> Thus, the following _should_ replace hte existing "meter="tristubh""
> attribute with "meter="gayatri"" (unless "expanded-name" is some level of
> non-apparent subtlety of meaning):

no it shouldn't: --

  <xsl:attribute
name="meter"><xsl:text>gayatri</xsl:text></xsl:attribute>

-- adds a meter attr, and then --

  <xsl:apply-templates select="*|@*" />

-- also adds a meter attr, which replaces the first one, as your <snip>
from the spec says.

when the spec talks about replacing "any existing attribute", it doesn't
mean an existing attr in the input tree, but one in the output tree -
i.e. it's talking about the stylesheet creating an attr more than once
(regardless of whether it does so by copying the input tree or
otherwise).

> > > <xsl:template match="div2[@id='1.2']">
> > >                     <div2>
> > >                     <xsl:attribute name="meter">
> > >                     <xsl:text>gayatri</xsl:text>
> > >                     </xsl:attribute>
> > >             <xsl:apply-templates select="*|@*" />
> > >                     </div2>
> > >             </xsl:template>

so you could just put the attr-creation that inserts the right value
_last_:

<xsl:template match="div2[@id='1.2']">
                    <div2>
            <xsl:apply-templates select="@*" />
                    <xsl:attribute name="meter">
                    <xsl:text>gayatri</xsl:text>
                    </xsl:attribute>
            <xsl:apply-templates select="*" />
                    </div2>
            </xsl:template>

-- 

cheers

phil

"that monotonous state of the soul halfway between fulfillment
and futility which comes with life in the country" --- Musil


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread