[xquery-talk] changing structure based on input value

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


Mark,

Thats exactly what I was looking for, thanks... apologies for the simple
question (o:

btw - I had to make two changes, the "else if" needed a "then" and the
whole thing needed an "else":

for $input in $this
return
   if ($input/foobar/abc/text() = 4) then
      <myoutput>
          <value>{ $input/foobar/xyz/text() }</value>
      </myoutput>
   else if ($input/foobar/abc/text() = 5) then
      <somethingelse>
          <value>{ $input/foobar/xyz/text() }</value>
      </somethingelse>
   else
      <rubbish>{ $input/foobar/abc/text() }</rubbish>

but it does what is required.

thanks again.

cheers
dim






Mark R Maxey <Mark_R_Maxey at raytheon.com> on 31/07/2003 11:03:31 PM

Please respond to Mark_R_Maxey at raytheon.com

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

You can do something like this:


for $indoc in doc("inputDocument.xml")
return
   if (data($indoc/abc) = 4) then
      <myoutput>
          <value>{ $indoc/xyz/text() }</value>
      </myoutput>
   else if (data($indoc/abc) = 5)
      <somethingelse>
          <value>{ $indoc/xyz/text() }</value>
      </somethingelse>


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

--
Mark Maxey
(972)205-5760
Mark_R_Maxey at Raytheon.com








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