ancestor

How to declare variables

A colleague of mine and I have been discussing how to declare variables in a function. Let's say you have a class called TStrings (using Delphi for the sake of explanation) that has at least one abstract method and a descendant class called TStringList which obviously implements the abstract method, but it introduces nothing else you ne...

Google App Engine Query (not filter) for children of an entity

Is the parent of an entity available in a Query? Given: class Factory(db.Model): """ Parent-kind """ name = db.StringProperty() class Product(db.Model): """ Child kind, use Product(parent=factory) to make """ @property def factory(self): return self.parent() serial = db.IntegerProperty() Assume 500 fa...

XPath: Recursive Ancestor Search

With my current node selected I wish to find an element <name> [./name] and return the text content. If an element <name> does not exist in the currently selected node I wish to check the parent element [./parent::name] and so on recursively up to the root, returning the value of the nearest parent where the element exists. Can it be do...

Getting consistent menu tree data from menu tables in MySQL

Hi everybody, I have a tree / ancestor / query problem I'm not able to solve: I have a table holding menu data and a table containing all the ancestors of the menu: table menu table ancestors +-----+------------+--------+ +---------+--------------+-------+ | id | title | active | | menu_id | ancestor_id | l...

How to find the first ancestor node whose tag is <tbody> with jQuery?

Suppose the jQuery object is $obj,how to select the desired ancestor? ...

jQuery select ancestor

Is is possible to use jQuery to select an ancestor of an element? Markup: <div id="ancestor-1"> <div> <a href="#" class="click-me">Click me</a> </div> </div> <div id="ancestor-2"> <div> <a href="#" class="click-me">Click me</a> </div> </div> Script: $(".click-me").click(function(){ // var ancestor...

Jquery: get ancestors (or descendants) and self

One can use matchedset.find(selector) / matchedset.parents(selector) to get the descendants/ancestors of the current matched set filtered by a selector, but that doesn't include the matched set itself (if it happens to match the selector too). Is there a better (more concise and/or faster) way to get it than matchedset.find(selector).ad...

Can someone explain this javascript code to me?

var vTableExp = "//a[contains(@href,'newdid')]/ancestor::td/ancestor::tr/ancestor::tbody"; var vTable = dom.find(vTableExp, XPFirst); thanks ...

How can I get the common ancestor directory for two or more files in Cocoa/Obj-C?

I have a bunch of files, either NSStrings or NSURLs (it doesn't matter; they are, for the most part, interchangeable), and I need a way to find the common ancestor directory. Does anyone know how to do this? ...

Is there a better way to find lowest common ancestor in a binary search tree?

I know similar questions have been asked before, but I think my solution is far simpler. Especially compared to [http://en.wikipedia.org/wiki/Tarjan's_off-line_least_common_ancestors_algorithm]. Please prove me wrong! If you have a tree with nodes that have the given data structure: struct node { node * left; node * right; ...