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

Copying nested tags and adding attributes

Subject: Copying nested tags and adding attributes
From: <graeme.ludwig@xxxxxx>
Date: Tue, 30 Jan 2007 00:42:44 -0000
 Copying nested tags and adding attributes
I'd like to combine elements of solutions 12 and 8 of Dave Pawson's XSL
copying FAQ (http://www.dpawson.co.uk/xsl/sect2/N1930.html).

Specifically, I would like to take the XML:

<description>See how <b>cans</b> are made into model cars, planes, bikes, etc.
at  <a href="http://www.tincanmodels.com/" target="_self">Tin Can Models</a>.
</description>

and transform it into

See how <b>cans</b> are made into model cars, planes, bikes, etc. at  <a
href="http://www.tincanmodels.com/" alt="Tin Can Models" target="_self">Tin
Can Models</a>.

i.e. I want to add an alt attribute to the hyperlink and set it to the text of
the link itself. The bold attribute should remain unchanged.

I know I can use

<xsl:template match="description">
  <xsl:copy-of select="node()"/>
</xsl:template>

to get the text out as per solution 12, but am unsure how to generate the
extra alt attribute for any <a> elements that occur within the text. I believe
I am using an XSLT 1.0 processor.

Any help appreciated.

Thanks,

Graeme.

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.