[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Bug in XT? was [RE: Change Attribute Value: Search-n-rep

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
xslt change attribute
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.