Altova Mailing List Archives>Archive Index >xsl-list Archive Home >Recent entries >Thread Prev - [xsl] XSL: multiple element come to single parent element [Thread Next] Re: [xsl] XSL: multiple element come to single parent elementTo: xsl-list@-----.------------.--- Date: 5/10/2009 5:31:00 PM Selva Ganesh wrote:
> <div class="LegEnactingText">
> <p class="LegText">The Secretary</p>
> </div>
> <div class="LegEnactingText">
> <p class="LegText">vfgdhdf dfhdsgh </p>
> </div>
> <div class="LegEnactingText">
> <p class="LegText">dffsg gsdfg sdghds</p>
> </div>
> ...
> ...
> <div class="LegEnactingText">
> <p class="LegText">sgg dgfg dgfgd</p>
> </div>
>
> What i need:
>
> <enacting-words>
> <enacting-text>The Secretary</enacting-text>
> <enacting-text>vfgdhdf dfhdsgh </enacting-text>
> <enacting-text>dffsg gsdfg sdghds</enacting-text>
> ...
> ...
> <enacting-text>sgg dgfg dgfgd</enacting-text>
> </enacting-words>
Write a template for the parent element of those div elements. The
following assumes that is a 'body' element but you could of course
change that as needed:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" indent="yes" />
<xsl:template match="body">
<enacting-words>
<xsl:apply-templates select="div[@class = 'LegEnactingText']/p"/>
</enacting-words>
</xsl:template>
<xsl:template match="div[@class = 'LegEnactingText']/p">
<enacting-text>
<xsl:apply-templates/>
</enacting-text>
</xsl:template>
</xsl:stylesheet>
--
Martin Honnen
http://msmvps.com/blogs/martin_honnen/
--~------------------------------------------------------------------
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@l...>
--~--
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
