[xquery-talk] changing structure based on input value
Mark R Maxey
Mark_R_Maxey at raytheon.com
Thu Jul 31 09:03:31 PDT 2003
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
More information about the talk
mailing list