Subject:Search a sequence of siblings (for each ??) within a delimited range Author:Peter Robert Date:08 Jul 2009 11:12 AM
Hi,
I need to treat the result of flat file conversion, which results in a flat XML structure.
Now, I want to grab each occurence of 3 elements within a certain delimited range (between each LETTERHEAD, as this is the delimiter).
As of now, I'm working with "following-sibling", but I'm stuck somewhat:
for $Service_dig in root/LETTERHEAD/following-sibling::*[local-name()="DSQ"][1]
let $DSD := $Service_dig/following-sibling::*[local-name()="DSD"][1]
let $DSR := $Service_dig/following-sibling::*[local-name()="DSR"][1]
return
<SERVICE_DIG>
{$DSD/SERVICE_NAME}
{$Service_dig/QUANTITY}
{$DSR/GROSSAMOUNT}
</SERVICE_DIG>
If I set the sibling position to [1], I only get the first element, although there are several (1 - x) within a letter (LETTERHEAD to next LETTERHEAD)
If I remove the sibling position, I get every DSQ sequence of the whole file.
How can I tell it to take only those until the next LETTERHEAD occurence?
Subject:Search a sequence of siblings (for each ??) within a delimited range Author:Ivan Pedruzzi Date:08 Jul 2009 02:03 PM
Peter,
You should be able to use a more efficient form like the following, but I am not sure about the semantic. Can you share a sample of the XML input you are trying to process
for $Service_dig in root/LETTERHEAD/following-sibling::DSQ[1]
let $DSD := ($Service_dig/following-sibling::DSD)[1]
let $DSR := ($Service_dig/following-sibling::DSR)[1]
Subject:Search a sequence of siblings (for each ??) within a delimited range Author:Peter Robert Date:09 Jul 2009 03:18 AM Originally Posted: 09 Jul 2009 03:17 AM