Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

XQuery For Loop Index variable not working

794954Feb 1 2011 — edited Oct 10 2011
Hi,

I am using the below syntax for the for loop implementation in xquery


for $Reading at $Position in $MiddlewareMessage1/ns1:Data/ns1:Message/ns1:Reading
return
<ns0:Event latitude="{xs:decimal(data($MiddlewareInboundMessage1/ns1:Data/ns1:Message/ns1:Reading[$Position]/ns1:Lat))}"
longitude="{xs:decimal(data($MiddlewareInboundMessage1/ns1:Data/ns1:Message/ns1:Reading[$Position]/ns1:Long))}">

</ns0:Event>


}

Reading is a repeatable element under the source schema of Xquery at $MiddlewareMessage1/ns1:Data/ns1:Message and Event is a repeating element of the atrget schema of xquery.
When i test this using just one complex of Reading element it works fine. But if i try giving multiple records for Reading then i get an error - expected zero or one item, got two or more items
I am not sure what the problem is. Is there any error with the usage of for loop Position variable. Please suggest. Thanks in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 7 2011
Added on Feb 1 2011
3 comments
2,051 views