xsl-list
[Top] [All Lists]

RE: How might I reproduce a tag, but change one attribute?

2006-01-27 11:28:52
Mike,

Thanks a ton, this is exactly what I was looking for.

Regards,

JF

--- "Haarman, Michael" <mhaarman(_at_)ibsys(_dot_)com> wrote:

From: footh
an <img> tag exactly, except I want to change one
attribute, the "src".  The only way I can think of


  <xsl:template match="img">
    <xsl:copy>
      <xsl:copy-of select="@*"/>
      <xsl:attribute name="src">
        <xsl:value-of select="'bar'"/>
      </xsl:attribute>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>

This is a modified identity template.  The copy-of
instruction selects all
attributes of the element and copies them and their
values.  Just after it,
the attribute instruction names and values a new
@src attribute which
overrides the value for @src just copied in the
previous instruction.
apply-templates catches any child nodes of the img
element, unnecessary if
you know img is always a leaf node.

HTH,


-----------------------------------
Mike Haarman,
XSL Developer,
Internet Broadcasting Systems, Inc.


--~------------------------------------------------------------------
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>
--~--




__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.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>