[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
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-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
RE: [xsl] Newby Question reformatting xml
Subject: RE: [xsl] Newby Question reformatting xml From: cknell@xxxxxxxxxx Date: Mon, 17 Feb 2003 09:36:49 -0500 |
-----Original Message----- From: "Michael A. Thompson" <mathomp@xxxxxxxxxxxxxx>
<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@xxxxxxxxxx - email
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Newby Question reformatti, Yates, Danny (ANTS) | Thread | Re: [xsl] XSLT FAQ ideas (was Re: t, Joe Fawcett |
RE: [xsl] Newby Question reformatti, Yates, Danny (ANTS) | Date | Re: [xsl] performance issues saxon, Vasu Chakkera |
Month |
Keywords