[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: What's wrong with my ancestor syntax?
>> <xsl:for-each select="//menuItem[pageID = >> $pageID]/descendant-or-self::menuItem"> >I think it says: > >Select any menuItem (//menuItem) >That has a pageID of x ([pageID = $pageID]) >And is or is a descendant of said page (/descendant-or-self::menuItem) > >Did I get that about right? No, you have to read each step of an xpath in the context of where you ended up at the last step (er, rather like walking:-) so you read it as Select any menuItem (//menuItem)That has a pageID of x ([pageID = $pageID]) Then FROM THERE select that node and any descendant menuItem nodes (descendant-or-self::menuItem), return the resulting set of nodes. This is just the same as an xpath of /a/b/c which means select all child a then from those nodes, select all child b then from there select all child c nodes return the resulting node set (or sequence in xpath 2) whenever you see an an xpath of the form //blrgh[fidget=$wibble] you should be asking yourself whether you should be using instead <xsl:key name="x" match="blrgh" use="fidget"/> ... select="key('x',$wibble)" since an key essentially just tells the system to optimise such lookups, but get working first, before optimising! David
|
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
|