Subject: Re: climbing to the root element
From: António Mota <amsmota@xxxxxxxxx>
Date: Wed, 16 Feb 2005 14:16:59 +0000
|
That will be someting like
ancestor-or-self::item[itemname/@nametype='multiple']/itemname/nametext
On Wed, 16 Feb 2005 14:24:11 +0100, Ke'tszeri Csaba <csaba@xxxxxxxxxxx> wrote:
> Hello!
>
> My xml doc has a structure like the one at the end of this letter.
> If an item has a nametype=multiple, then I have to
> prefix their nametext with their containing item nametext.
> I have to repeate it as many times as multiple type items cascaded
> together, plus the one item with simple type above them.
>
> The expected output is this:
> a
> b
> bi
> biv
> bj
> c
>
> There are several other container elements between the simple and
> multiple type items, so i can't predict how deep I am, and how far
> should i look for the parent item.
>
> My real problem is that I can't make a recursive function to go back
> to the / direction.
>
> Could you give me some ideas?
>
> Thank you!
>
> Csaba
>
> <xml>
> <item>
> <itemname nametype="simple">
> <nametext>a</nametext>
> </itemname>
> </item>
> <item>
> <itemname nametype="simple">
> <nametext>b</nametext>
> </itemname>
> <item>
> <itemname nametype="multiple">
> <nametext>i</nametext>
> </itemname>
> <item>
> <itemname nametype="multiple">
> <nametext>v</nametext>
> </itemname>
> </item>
> </item>
> <item>
> <itemname nametype="multiple">
> <nametext>j</nametext>
> </itemname>
> </item>
> </item>
> <item>
> <itemname nametype="simple">
> <nametext>c</nametext>
> </itemname>
> </item>
> </xml>
|