About Order Data Rule XQuery Expressions

This topic describes how to use the Order Recognition Rule editor Order Data Rule area XQuery tab to write an expression that specifies nodes in the incoming customer order that must be used in the creation task. The XQuery has the following characteristics:

  • Context: The input document for the Order Data Rule XQuery is the customer order. For more information about typical customer order structures, see OSM Modeling Guide.

  • Prolog: You can declare the customer order namespace in the XQuery prolog. For example:

    declare namespace im="http://xmlns.oracle.com/InputMessage";
    
  • Body: The Order Data Rule body must map the customer order element values to the corresponding creation task Task Data values.

    The following example shows the fields in an incoming customer order:

    <im:customerAddress>
         <im:locationType>Street</im:locationType>
         <im:nameLocation>Jangadeiros</im:nameLocation>
         <im:number>48</im:number>
         <im:typeCompl>floor</im:typeCompl>
         <im:numCompl>6</im:numCompl>
         <im:district>Ipanema</im:district>
         <im:codeLocation>5000</im:codeLocation>
         <im:city>Rio de Janeiro</im:city>
         <im:state>RJ</im:state>
         <im:referencePoint>Gen. Osorio Square</im:referencePoint>
         <im:areaCode>22420-010</im:areaCode>
         <im:typeAddress>Building</im:typeAddress>
    </im:customerAddress>
    

    Following is a sample order data in a creation task. In the example, the following data is contained in a CustomerDetails element:

    • locationType

    • nameLocation

    • number

    • typeCompl

    • numCompl

    • district

    • codeLocation

    • city

    • state

    • referencePoint

    • areaCode

    • typeAddress

    The following XQuery expression specifies a variable for the location of the customerAddress node in the customer order that can then be used to map customerAddress child element values to CustomerDetails task data elements:

    let $details := $customer/mes:customerAddress
    

    The following XQuery expression performs this mapping:

    return<_root>
    <CustomerDetails>
         <locationType>{$details/im:locationType/text()}</locationType>
         <nameLocation>{$details/im:nameLocation/text()}</nameLocation>
         <number>{$details/im:number/text()}</number>
         <typeCompl>{$details/im:typeCompl/text()}</typeCompl>
         <numCompl>{$details/im:numCompl/text()}</numCompl>
         <district>{$details/im:district/text()}</district>
         <codeLocation>{$details/im:codeLocation/text()}</codeLocation>
         <city>{$details/im:city/text()}</city>
         <state>{$details/im:state/text()}</state>
         <referencePoint>{$details/im:referencePoint/text()}</referencePoint>
         <areaCode>{$details/im:areaCode/text()}</areaCode>
         <typeAddress>{$details/im:typeAddress/text()}</typeAddress>
    </CustomerDetails>
    </_root>
    

In the following example, the XQuery expression returns the <_root> portion of the order. The ControlData portion of the order is populated by the system during the generation of the orchestration plan.

declare namespace cso="http://xmlns.oracle.com/communications/sce/dictionary/CentralOMManagedServices-Orchestration/CustomerSalesOrder";
let $customer :=  //cso:CustomerAccount
return
<_root>
<OrderHeader>
<AccountIdentifier>{$customer/cso:AccountID/text()}</AccountIdentifier>
</OrderHeader>
</_root>

For more information about order data rules, see OSM Modeling Guide.