[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: Alan <alan-xsl-list@xxxxxxxxx>
Date: Fri, 25 Mar 2005 12:40:12 -0500
xslt copy attributes
* Alan <alan-xsl-list@xxxxxxxxx> [2005-03-25 12:27]:
>     In my expand.xslt I have a template like so...
> 
>     <xsl:template match="control">
>       <xsl:variable name="definition"
>                     select="ancestor::bench/fixture/control-point[
>                                           @name = current()/@name]"/>
>       <xsl:copy>
>         <xsl:copy-of select="@*"/>
>         <xsl:if test="not(@trim)">
>           <xsl:copy-of select="$defition/@trim"/>
>         </xsl:if>
>         <xsl:if test="not(@class)">
>           <xsl:copy-of select="$defition/@class"/>
>         </xsl:if>
>         <!--| Repeat for every attribute I add. |-->
>       </xsl:copy>
> 
>     </xsl:template>

>     My question... Is there a clever select statement that could
>     "copy all the attributes, and all the definition attributes,
>     unless they are already definied in the test instance."

    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>



--
Alan Gutierrez - alan@xxxxxxxxx

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.