On 15 Feb 2005 13:50:10 -0800, mikea_59 <> wrote:
> I am having trouble combining similar elements. Elements can be
> combined if they have the same name and the same attribute values. I
> can handle single level elements but am having problems with
> multi-level elments (level of element nesting is unbound). I cannot
> rely on fixed element names in the translator code since the translator
> will be general purpose, elements names are not fixed.
Hi,
I'm afraid you'll have to use an 'xx:node-set' extension function to solve
this (in XSLT1.0).
Here's one solution (tested with Saxon), gives correct output for your
input.
<xsl:stylesheet xmlns

sl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl">
<xsl

utput method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:key name="element" match="*" use="concat(local-name(),@*)"/>
<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:variable name="set">
<xsl:copy-of select="key('element',concat(local-name(),@*))/*"/>
</xsl:variable>
<xsl:apply-templates select="text()"/>
<xsl:apply-templates
select="exsl:node-set($set)/*[generate-id()=generate-id(key('element',concat(local-name(),@*)))]"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
regards,
Joris Gillis
--
Using Opera's revolutionary e-mail client:
http://www.opera.com/m2/