Forum Discussion

Ben_Lidgey's avatar
Ben_Lidgey
Occasional Contributor
16 years ago

How to select attribute using Xquery in property transfer

Hi,

I'm want to use a property transfer to transfer an attribute. I get many attributes back, but only want the one specified in a string.
{possible fruitId's are 'ORANGE', 'APPLE', 'PEAR' }

so I need to iterate through the response and extract the fruit attribute

Not having any success with the following:

declare namespace ns5='http://example/example/example/example/example';
declare namespace ns6='http://example/platform/example/example/example';

for $x in //ns5:getAvailablefruitsResponse/ns5:fruitType
where $x/ns6:fruit[@fruitId="APPLE"]
return $x//ns6:[@fruitId]

Any ideas please....tearing my hair out!
  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    Not to trod on any support engineer toes , but if you want the attribute value, here is a simple example. For the following XML:

    [tt:3t04iip3]
    PEARS ARE GOOD FOR YOU
    SO ARE APPLES
    [/tt:3t04iip3]
    this XQuery:

    [tt:3t04iip3]for $f in //fruits/fruit
    where $f/@fruitId='apple'
    return {data($f/@fruitId)}[/tt:3t04iip3]
    will give the following:

    [tt:3t04iip3]apple[/tt:3t04iip3]

    I think the result needs to be valid XML rather than just a text value.
  • Huge Thanks for answering :-)

    Ben, is this enough to move you forward?

    regards to both of you!

    /Ole
    eviware.com
  • Ben_Lidgey's avatar
    Ben_Lidgey
    Occasional Contributor
    M McDonald, thank you thank you thank you 

    works like a charm 

    what a great start to the day

    thank you again

    as an aside...ole, the documentation could really use some work, even if it's just a soap ui cookbook
  • Hi!

    hehe.. yes.. we are *painfully* aware of the documentation shortcomings, sorry about that.. The good news is that we are reworking most of the user guide so a much improved version will be made available within a couple of months.

    regards!

    /Ole
    eviware.com