[xquery-talk] next node (sibling)

Mark R Maxey Mark_R_Maxey at raytheon.com
Fri Aug 1 09:33:49 PDT 2003


XQuery doesn't support the following-sibling axis.  However, there are 
work arounds as suggested by Michael Kay.  Instead of

following-sibling:x

use

../child::x[. >> $current]


If you're using BEA LD, you're hosed because it doesn't support the 
order comparison operators ">>" and "<<".


Dmitri.Colebatch at toyota.com.au wrote:

>hey again,
>
>Apologies for bombarding the list with questions, but you're all being very
>helpful (o:  I've also got past most of the stuff I had to do witht his
>much quicker than I thought I would, thanks to you guys...
>
>I'm now working with a document with a structure like the following:
>
><updates>
>      <item>
>            <item-type>hdr</item-type>
>            <type>update</type>
>            <id>123</id>
>      </item>
>      <item>
>            <item-type>detail</item-type>
>            <detail>
>                  <foo>bar</foo>
>                  <abc>xyz</abc>
>            </detail>
>      </item>
>      <item>
>            <item-type>hdr</item-type>
>            <type>delete</type>
>            <id>456</id>
>      </item>
>      <item>
>            <item-type>hdr</item-type>
>            <type>update</type>
>            <id>789</id>
>      </item>
>      <item>
>            <item-type>detail</item-type>
>            <detail>
>                  <foo>qwerty</foo>
>                  <abc>crazy</abc>
>            </detail>
>      </item>
></updates>
>
>as the names suggest, this is for updating data between two systems - I
>need to receive the message from system A and send it to system B in the
>appropriate format.  The structure above is how I receive it from system A.
>
>Now, its not immediately obvious how the above is intended to work, but
>essentially each "item header record" [item/item-type/text() = 'hdr' ] will
>indicate an update (or new record), or a delete.  In the case of an update,
>I know that the next item record will be an "item detail record"
>[item/item-type/text() = 'detail'] which I use to get the detail of the
>changes.
>
>The problem of course is that the structure requires a stateful approach to
>the conversion.  What I've tried to do is select all the item header
>records, and look at whether they are an update or a delete.  if they're an
>update, I somehow need to get the next item, which I know will be a "item
>detail record" and get the values out of it as they correspond to this id.
>
>I'm stuck on trying to get the next sibling.... am I missing something, or
>is this just plain not possible?  Note that I dont have an id element in
>the detail record so I cant go up to the parent and then select the child
>with the same id.
>
>any (more) help will be much appreciated.
>
>cheers
>dim
>
>ps - I want to have the output of the above look something like:
>
><updates>
>      <update>
>            <id>123</id>
>            <foo>bar</foo>
>            <abc>xyz</abc>
>      </update>
>      <delete>
>            <id>456</id>
>      </delete>
>      <update>
>            <id>789</id>
>            <foo>qwerty</foo>
>            <abc>crazy</abc>
>      </update>
></updates>
>
>which of course would be a more logical structure to start with (o:
>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>                               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