This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Unwrapping trees
- From: Wendell Piez <wapiez at mulberrytech dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Thu, 13 Jun 2002 14:23:41 -0400
- Subject: Re: [xsl] Unwrapping trees
- Reply-to: xsl-list at lists dot mulberrytech dot com
Norm --
How about:
<xsl:template match="a"><!-- just letting it default -->
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="a//text()">
<a href="{ancestor::a[1]/@href}">
<xsl:value-of select="."/>
</a>
</xsl:template>
...and just copying the span...?
Cheers,
Wendell
At 10:56 AM 6/13/2002, you wrote:
Has anyone written the XSLT required to "unwrap" nested links?
I'd like to turn, for example:
<p>
text
<a href="1">
text
<span>
<a href="2">test</a>
text
</span>
text
</a>
text
</p>
into
<p>
text
<a href="1">
text
<span/>
</a>
<span>
<a href="2">test</a>
text
</span>
<a href="1">
text
</a>
text
</p>
With extra bonus points for discarding the empty span (if it doesn't
have an ID :-)
Be seeing you,
norm
--
Norman.Walsh@Sun.COM | Wisdom is only a comparative quality, it will
XML Standards Engineer | not bear a single definition.--Marquess of
XML Technology Center | Halifax
Sun Microsystems, Inc. |
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
======================================================================
Wendell Piez mailto:wapiez@mulberrytech.com
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list