![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Tranform HTML fragments [Thread Next] Re: Tranform HTML fragmentsTo: NULL Date: 8/2/2006 4:30:00 PM
Chris wrote:
> <div class="transform"><a href="test.asp">
> <img src="test.gif" /></a></div>
>
> into
>
> <div class="transform"><a href="test.asp">
> <img src="test.gif" />
> </a>
> <a href="test.asp">
> <img src="icon.gif" />Click here
> </a>
>
> </div>
It is not quite clear whether you always want to append
<a href="test.asp">
<img src="icon.gif" />Click here
in the div or whether you want to take the existing link and duplicate
with some modification. I have assumed the latter and outlined an
approach as follows:
<xsl:template match="div[@class = 'transform']">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
<xsl:apply-templates select="a" mode="insert" />
</xsl:copy>
</xsl:template>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@*" />
</xsl:copy>
</xsl:template>
<xsl:template match="a" mode="insert">
<xsl:copy>
<xsl:apply-templates select="@*" />
<xsl:apply-templates select="*" mode="insert" />
</xsl:copy>
</xsl:template>
<xsl:template match="img" mode="insert">
<xsl:copy>
<xsl:apply-templates select="@*" />
<xsl:text>Click here</xsl:text>
</xsl:copy>
</xsl:template>
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
