[xquery-talk] changing structure based on input value

Dmitri.Colebatch at toyota.com.au Dmitri.Colebatch at toyota.com.au
Fri Aug 1 11:45:44 PDT 2003


Rick,

Thanks for the response, I was looking to avoid having to have two distinct
queries and have gone with the suggestion Mark offered.

cheers
dim





rick schochler <schochler3 at yahoo.com>@x-query.com on 31/07/2003 11:20:09 PM

Sent by:    talk-bounces at x-query.com


To:    Dmitri.Colebatch at toyota.com.au, talk at x-query.com
cc:
Subject:    Re: [xquery-talk] changing structure based on input value

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

_______________________________________________
talk at x-query.com
http://www.x-query.com/mailman/listinfo/talk



- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                               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.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -




More information about the talk mailing list