This discussion is archived
2 Replies Latest reply: Oct 24, 2012 1:03 AM by 970125 RSS

OSM Order Data Rule - XQuery doesn't loop

970125 Newbie
Currently Being Moderated
Hi
I'm using OSM 7.2.0.3 and I have cartridge with an Order Recognition Rule, with its Order Data Rule (inside Transformation tab)

In the ODR I have this XQuery code:

declare namespace im="http://xxx";
declare namespace xs="http://www.w3.org/2001/XMLSchema";

declare variable $ord := fn:root(.)/im:Order;

<_root>
<Order>
{
for $moli in $ord/MainOrderLineItem
return
$moli/LineItemAttributeInfo/LineItemAttribute
}
</Order>
</_root>


The XML input to the OSM is:

<?xml version="1.0" encoding="UTF-8"?>
<ord:CreateOrder
     xmlns:ord="http://xmlns.oracle.com/communications/ordermanagement">
     <im:Order xmlns:im="http://xxx"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://xmlns.oracle.com/communications/sce/dictionary/BaseOrderCommonCartridge/DataDictionary_BaseOrderCommon ../dataDictionary/DataDictionary_BaseOrderCommon.xsd">

<OrderHeader>
<OrderID>12345</OrderID>
<RevisionNumber>1</RevisionNumber>
</OrderHeader>

<MainOrderLineItem>
<LineItemAttributeInfo>
<LineItemAttribute>
<AttributeID>1234</AttributeID>
</LineItemAttribute>
</LineItemAttributeInfo>
</MainOrderLineItem>
<MainOrderLineItem>
<LineItemAttributeInfo>
<LineItemAttribute>
<AttributeID>5678</AttributeID>
</LineItemAttribute>
</LineItemAttributeInfo>
</MainOrderLineItem>
<MainOrderLineItem>
<LineItemAttributeInfo>
<LineItemAttribute>
<AttributeID>abcd</AttributeID>
</LineItemAttribute>
</LineItemAttributeInfo>
</MainOrderLineItem>

     </im:Order>
</ord:CreateOrder>

(sorry I don't know how to make the code shown formatted)


There are 3 occurences of <MainOrderLineItem>'s but the output is only 1:

<LineItemAttribute xmlns:im="http://m1.com.sg/bcc/osm/com/ordermain" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<AttributeID>1234</AttributeID>
</LineItemAttribute>


Why is it not looping?

Thanks a lot for your replies.

Edited by: 967122 on Oct 24, 2012 1:41 AM
  • 1. Re: OSM Order Data Rule - XQuery doesn't loop
    882807 Explorer
    Currently Being Moderated
    Hi,

    I just corrected two lines of your XQuery

    xquery version "1.0";
    declare namespace ord="http://xmlns.oracle.com/communications/ordermanagement";
    declare namespace im="http://m1.com.sg/bcc/osm/com/ordermain";
    declare namespace xs="http://www.w3.org/2001/XMLSchema";


    declare variable $ord :=  fn:root(.)/ord:CreateOrder/im:Order;

    <_root>
    <Order>
    {
    for $moli in $ord/MainOrderLineItem
    return
    $moli/LineItemAttributeInfo/LineItemAttribute
    }
    </Order>
    </_root>


    Thanks
    Naveen Jabade
  • 2. Re: OSM Order Data Rule - XQuery doesn't loop
    970125 Newbie
    Currently Being Moderated
    That doesn't work. When you submit an order XML to OSM, by default it looks for <CreateOrder>, <CreateOrderBySpecification>, <GetOrder>, <CancelOrder>, etc and removes that element. So what OSM processes is only elements that are <CreateOrder>'s children. Hence "declare variable $ord := fn:root(.)/im:Order;" is correct.

    Edited by: 967122 on Oct 24, 2012 1:02 AM

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points