xsl-list
[Top] [All Lists]

Re: Copy Attribute Unless

2005-03-25 10:40:12
* Alan <alan-xsl-list(_at_)engrm(_dot_)com> [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(_at_)engrm(_dot_)com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>