You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by An...@mro.com on 2006/01/18 17:05:36 UTC

xpath question

Hi All
I have an xml which looks something like this below. I am currently in the
invoice node and I want to select all the line nodes that have the same
invoicenum as the invoice node that I am in. It will be almost like this:

../line[invoicenum= <the current invoice elements invoicenum>]

I am not sure how to express that <the current invoice elements invoicenum>
in this xpath expr. Can any one suggest something.

<Root>
    <invoice>
        <invoicenum>aaaa</invoicenum>
    </invoice>
    <invoice>
        <invoicenum>bbbb</invoicenum>
    </invoice>
    <line>
         <desc>line1 for aaaa</desc>
         <invoicenum>aaaa</invoicenum>
    </line>
    <line>
         <desc>line2 for aaaa</desc>
         <invoicenum>aaaa</invoicenum>
    </line>
    <line>
         <desc>line1 for bbbb</desc>
         <invoicenum>bbbb</invoicenum>
    </line>
</Root>

thanks
Anamitra


Re: xpath question

Posted by Mukul Gandhi <ga...@gmail.com>.
You can write as

../line[invoicenum = current()/invoicenum]

Regards,
Mukul

On 1/18/06, Anamitra.Bhattacharyya@mro.com
<An...@mro.com> wrote:
> Hi All
> I have an xml which looks something like this below. I am currently in the
> invoice node and I want to select all the line nodes that have the same
> invoicenum as the invoice node that I am in. It will be almost like this:
>
> ../line[invoicenum= <the current invoice elements invoicenum>]
>
> I am not sure how to express that <the current invoice elements invoicenum>
> in this xpath expr. Can any one suggest something.
>
> <Root>
>    <invoice>
>        <invoicenum>aaaa</invoicenum>
>    </invoice>
>    <invoice>
>        <invoicenum>bbbb</invoicenum>
>    </invoice>
>    <line>
>         <desc>line1 for aaaa</desc>
>         <invoicenum>aaaa</invoicenum>
>    </line>
>    <line>
>         <desc>line2 for aaaa</desc>
>         <invoicenum>aaaa</invoicenum>
>    </line>
>    <line>
>         <desc>line1 for bbbb</desc>
>         <invoicenum>bbbb</invoicenum>
>    </line>
> </Root>
>
> thanks
> Anamitra