-----Original Message-----
From: "Michael A. Thompson" <mathomp(_at_)bgnet(_dot_)bgsu(_dot_)edu>
<xsl:template match="BBB">
<xsl:element name="BBB">
<xsl:attribute name="num">
<xsl:value-of select="//DDD/@id">
</xsl:value-of>
</xsl:attribute>
<xsl:value-of select="."></xsl:value-of></xsl:element>
</xsl:template>
Your problem is with the XPath expression "//DDD/@id". It selects the first node that
matches this pattern, which, of course, is only correct for the children of the first
<DDD> element. Use this expression instead:
"parent::node()/attribute::id"
or in abbreviated format:
"../@id"
While the latter is more concise, the former is easier to understand. Both
expressions evaluate identically.
If you are going for brevity, you could re-write the template so:
<xsl:template match="BBB">
<xsl:element name="BBB">
<xsl:attribute name="num"><xsl:value-of select="../@id" /></xsl:attribute>
<xsl:value-of select="." />
</xsl:element>
</xsl:template>
--
Charles Knell
cknell(_at_)onebox(_dot_)com - email
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list