[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Find elements whose ancestors are the same
Hi,
Thanks again to everyone who has replied to these messages. I had no idea how hard this would be. It seemed so simple when I explained it to the client ;-) I'm looking for an XPath expression that will find all elements whose ancestors are the same. By "same" I mean their @name is the same at each level of ancestry (and they appear in the same order). For example, this expression would return a count of 2 for the following XML when filtered on the "daughter" folder (or "mother" or "grandfather" for that matter). <root> <folder name="grandfather"> <folder name="mother"> <folder name="daughter" /> </folder> </folder> <folder name="grandfather"> <folder name="mother"> <folder name="daughter" /> </folder> </folder> <folder name="grandmother"> <folder name="father"> <folder name="son" /> </folder> </folder> </root> I know it's going to be something like this, but I just can't get my head around it! <xsl:copy-of select="/root//folder[@name = following-sibling::*/@name and ancestor-or-self::*/@name = following-sibling::*/@name/ancestor-or-self::*/@name" /> Thanks in advance! Ted
|
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
|