Individually I am able to receive the values from source(L.H.S) Structure using below XQuery expressions:
· $body/sfd:QLIRequestElement/sfd:inRequest/sfd:LineItems/sfd:listprice/text()
· $body/sfd:QLIRequestElement/sfd:inRequest/sfd:LineItems/sfd:Quantity/text()
· $body/sfd:QLIRequestElement/sfd:inRequest/sfd:LineItems/sfd:MaterialId/text()
· $body/sfd:QLIRequestElement/sfd:inRequest/sfd:LineItems/sfd: Netunitprice/text()
In Order to Iterate over the List of LineItems,I can use the F of FLWOR Expression,which stands for FOR.
The behavior of the for clause is straight forward: it iterates over a list of Items and calculates some value for each item in that list, and returns a list obtained by concatenating the results of these calculations.
return
File: Query.xquery <cars> { for $i in ( 1,3,5,7,9 ) return <mycar>{$i}</mycar>} </cars> | Output: <?xml version= "1.0" encoding= "UTF-8" ?> <cars> <mycar> 1 </mycar> <mycar> 3 </mycar> <mycar> 5 </mycar> <mycar> 7 </mycar> <mycar> 9 </mycar> </cars> |
Extending the above logic on XML source carrying List of <LineItems>, We need to introduce an iterator $var1 to iterateover <LineItems> having Zero or more repetition.,
And we need to return the resultant expression for each iteration in the List
<qlir:QLIRequest xmlns:qlir="http://soap.sforce.com/schemas/class/QLIRequest"> <qlir:inRequest> <qlir:EAIHeader> <qlir:applicationId>{$body/sfd:QLIRequestElement/sfd:eaiHeader/sfd:applicationId/text()}</qlir:applicationId> <qlir:transactionId>string</qlir:transactionId> <qlir:messageId>string</qlir:messageId> <qlir:messageHistory>string</qlir:messageHistory> <qlir:tracingId>string</qlir:tracingId> <qlir:timeStamp>2008-09-28T18:49:45</qlir:timeStamp> <qlir:instanceId>string</qlir:instanceId> <qlir:timeToLive>3</qlir:timeToLive> <qlir:payloadVersion>string</qlir:payloadVersion> </qlir:EAIHeader> <!--Zero or more repetitions:--> { for $var1 in $body/sfd:QLIRequestElement/sfd:inRequest/sfd:LineItems return <qlir:LineItem> <qlir:UOM>{fn:concat($var1/sfd:listprice/text(),"-", $var1/sfd:Quantity/text(),"-",$var1/sfd:MaterialId/text(),"-",$var1/sfd:Netunitprice/text())}</qlir:UOM> </qlir:LineItem> } <qlir:Quote_refnum>{$body/sfd:QLIRequestElement/sfd:inRequest/sfd:ObjectId/text()}</qlir:Quote_refnum> </qlir:inRequest> </qlir:QLIRequest> |
Analyze the result:
In fact I have replaced the entire body replace with an XML template containing Xquery Expressions.You may try a different approach of generating an XSLT using Jdeveloper and user XSLT resources to map.
Alternately you can create an XQuery( .xq )mapper file out of Eclipse with OEPE Plug-in for OSB.