[xquery-talk] changing structure based on input value
rick schochler
schochler3 at yahoo.com
Thu Jul 31 07:20:09 PDT 2003
Well, you could have two distinct queries on the set
of foobar docs, both looking similar.
The first one looking something like this:
<myoutput>
{
for $x in /foobar[child::abc/text() = '4']
return
<value>{$x/xyz}</value>
}
</myoutput>
and the second one looking like this:
<somethingelse>
{
for $x in /foobar[child::abc/text() = '5']
return
<value>{$x/xyz}</value>
}
</somethingelse>
Or, you could do a conditional test (you may have to
tweek this a bit):
for $x in /foobar/abc
return
if($x = '4')
then <myoutput><value>{$x}</value></myoutput>
else
if($x = '5')
then <somethingelse><value>{$x}
</value></somethingelse>
Hope this helps,
Rick
--- Dmitri.Colebatch at toyota.com.au wrote:
> hey all,
>
> firstly, I'm new to this list, so if this has been
> discussed already could
> someone please point me at the appropriate archive
> (I did have a short look
> at them with no joy)..
>
> I want to select one document or another based on
> the content of my input
> document... I think this is better explained by
> example:
>
> given
>
> <foobar>
> <abc>4</abc>
> <xyz>blah</xyz>
> </foobar>
>
> I want to create
>
> <myoutput>
> <value>blah</value>
> <myoutput>
>
> but based on
>
> <foobar>
> <abc>5</abc>
> <xyz>blah</xyz>
> </foobar>
>
> I want to create
>
> <somethingelse>
> <value>blah</value>
> </somethingelse>
>
> Does this make sense? I'm not sure if its possible
> or not. Any pointers
> would be appreciated. The closest thing I can think
> of is to use xpath to
> check the value, but I'm not sure how to completely
> change the structure
> based on that...
>
> cheers
> dim
>
> - - - - - - - - - - - - - - - - - - - - - - - - - -
> - - - - - - - - -
> DISCLAIMER
> * This email and any attachment may contain
> confidential information.
> If you are not the intended recipient you are not
> authorised to copy
> or disclose all or any part of it without the
> prior written consent
> of Toyota.
> * Opinions expressed in this email and any
> attachment are those of the
> sender and not necessarily the opinions of Toyota.
> * Please scan this email and any attachment for
> viruses. Toyota does
> not accept any responsibility for problems caused
> by viruses, whether
> it is Toyota's fault or not.
> - - - - - - - - - - - - - - - - - - - - - - - - - -
> - - - - - - - - -
>
>
> _______________________________________________
> talk at x-query.com
> http://www.x-query.com/mailman/listinfo/talk
More information about the talk
mailing list