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

RE: Copy Attribute Unless

Subject: RE: Copy Attribute Unless
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 25 Mar 2005 18:41:20 -0000
xsl copy attribute
>     The following works in Saxon 8.0. I assumed it was bad news to
>     specify an attribute twice, but I suppose the last attribute
>     node copied wins.
> 
>     <xsl:template match="control">
>       <xsl:variable name="definition"
>                     select="ancestor::bench/fixture/control-point[
>                                           @name = current()/@name]"/>
>       <xsl:copy>
>         <xsl:copy-of select="$definition/@*"/>
>         <xsl:copy-of select="@*"/>
>       </xsl:copy>
> 
>     </xsl:template>

Yes, XSLT 2.0 (and 1.0 for that matter) specifies that you can add two
attributes with the same name to an element, and the last one wins. It's
safe to rely on this - this is standard behavior, not one of those
"recoverable errors" where some processors will report an error and others
recover from it.

You can combine the two xsl:copy-of instructions into <xsl:copy-of
select="$definition/@*, @*"/>

Michael Kay
http://www.saxonica.com/

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.