>Using the example source document: > <a attr="1"> > <b attr="2"> > <c attr="3"/> > </b> > </a> >let's say the current node is <c> >Here's what I'd like to do: >if <c> has the attribute "attr" then return the attributes value. >else if <b> has the attribute "attr" then return the attributes value. >else if <a> has the attribute "attr" then return the attributes value. >else return a default value.
I don't think recursion is necessary. From c, ancestor-or-self::* is c and all its ancestors, ancestor-or-self::[EMAIL PROTECTED] is the subset that has an @attr, ancestor-or-self::[EMAIL PROTECTED] is the first of them, looking "upward" from c, ancestor-or-self::[EMAIL PROTECTED]/@attr is the attr attribute thereof. You can have a choose to isolate the default case, which occurs when count(ancestor-or-self::[EMAIL PROTECTED]) is 0. .................David Marston