[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Selecting/matching based on inherited attributes
Wendell wrote: > "all myelem elements for which > a first ancestor-or-self with an @att1 has @att1='d' > and > a first ancestor-or-self with an @att2 has @att2='c'" > > which is what you say you want. > > OTOH, this doesn't really help, does it? The whole tree will still > be walked collecting myelem elements, to be filtered with the > predicate. (I don't think there's a way to avoid walking the whole > tree one way or another to get those myelems, since the whole idea > is not to miss any.) The other approach would be to work down from the top of the tree, keeping track of the values of @att1 and @att2 as you go. Something like: <xsl:template match="*"> <xsl:param name="att1" select="/.." /> <xsl:param name="att2" select="/.." /> <xsl:apply-templates> <xsl:with-param name="att1" select="($att1 | @att1)[last()]" /> <xsl:with-param name="att2" select="($att2 | @att2)[last()]" /> </xsl:apply-templates> </xsl:template> until you finally get to the 'myelem' elements and can test the values: <xsl:template match="myelem"> <xsl:param name="att1" select="/.." /> <xsl:param name="att2" select="/.." /> <xsl:if test="$att1 = 'd' and $att2 = 'c'"> ... </xsl:if> </xsl:template> Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|