[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Copy Attribute Unless
> 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/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|