Order Transformation Manager XQuery Expressions

The following topics provide reference information about order transformation manager XQuery expressions.

About Transformation Sequence XQuery Expressions

When working with Transformation Sequence editor, see the following topics for information about defining XQuery expressions related to transformation sequences:

About Order Item Context XQuery Expressions

This topic describes how to use the Transformation Sequence editor, Dependencies tab, Order Item Context subtab, Expression area, XQuery subtab to write an expression that defines the context order items for the order transformation. To see the Order Item Context subtab, you must select a transformation stage in the tree on the Dependencies tab.

  • Context: The input document is the complete set of source order items.

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

            declare namespace prop='http://oracle.communications.centralom';
    
  • Body: The XQuery body returns the source order items that should be considered the context for the transformation stage.

The following example shows an XQuery expression for selecting an order item context.

        declare namespace prop='http://oracle.communications.centralom';
        osm:orderItem[osm:properties/prop:serviceIntance = 'Y']

About Related Order Item Selector XQuery Expressions

This topic describes how to use the Transformation Sequence editor, Dependencies tab, Related Order Item Selector subtab, Expression area, XQuery subtab to write an expression that defines the related order items for a particular context order item. To see the Related Order Item Selector subtab, you must select a transformation stage in the tree on the Dependencies tab.

  • Context: The input document is a context order item.

  • Prolog: You can declare the order item namespace and the namespace for the order transformation manager functions in the XQuery prolog. For example:

            declare namespace prop='http://oracle.communications.broadband;
    declare namespace otmfn=”java:oracle.communications.ordermanagement.orchestration.transformation.XQueryFunctions.”;
    
  • Body: The XQuery body returns the source order items related to the context order items.

The following example shows an XQuery expression that returns sibling order items as related order items to the order transformation.

        declare namespace prop='http://oracle.communications.broadband;
declare namespace otmfn=”java:oracle.communications.ordermanagement.orchestration.transformation.XQueryFunctions.”;
        let $siblings := otmfn:siblings (., ’{http://oracle.communications.broadband}default')
        return $siblings[! fn:exists(osm:properties[prop:serviceInstance = 'Y'])]

For more information about the transformation.XQueryFunctions class, install the OSM SDK and extract the OSM Javadocs from the OSM_home/SDK/osm7.w.x.y.z-javadocs.zip file (where OSM_home is the directory in which the OSM software is installed and w.x.y.z represents the specific version numbers for OSM). See OSM Installation Guide for more information about installing the OSM SDK.

About Stage Condition XQuery Expressions

This topic describes how to use the Transformation Sequence editor, Dependencies tab, Stage Condition subtab, Expression area, XQuery subtab to write an expression that determines whether a particular transformation stage should be run. To see the Stage Condition subtab, you must select a transformation stage in the tree on the Dependencies tab.

  • Context: The input document is the complete set of target order items.

  • Prolog: You can declare the order item property and parameter namespaces in the XQuery prolog. For example:

            declare namespace prop='http://oracle.communications.broadband';
    
    declare namespace parm='http://oracle.communications.broadband';
    
  • Body: The XQuery body returns a Boolean, with true meaning that the transformation stage should be run and false meaning that the transformation stage should not be run.

The following example shows an XQuery expression that returns true if certain parameters have not been defined, and false if the parameters are already defined.

declare namespace prop='http://oracle.communications.cso';
declare namespace parm='http://oracle.communications.broadband';
not(fn:exists(osm:properties/prop:Parameters[fn:exists(parm:uploadSpeed) and fn:exists (parm:downloadSpeed)]))    

About Mapping Rule XQuery Expressions

When working with Mapping Rule editor, see the following topics for information about defining XQuery expressions related to order decomposition:

About Mapping Condition XQuery Expressions

This topic describes how to use the Mapping Rule editor, Mapping tab, Condition subtab, Expressions area, XQuery subtab to write an expression that defines a condition that must be satisfied to apply this mapping.

  • Context: The input document is a target order item.

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

            declare namespace prop='http://oracle.communications.broadband';
    
  • Body: The XQuery body returns a Boolean, with true meaning that the mapping rule should be run and false meaning that the mapping rule should not be run.

The following example shows an XQuery expression that will execute the rule only if the target action is None.

declare namespace prop='http://oracle.communications.cso';
osm:properties/prop:Action/text() = 'None'

About Action Mapping XQuery Expressions

This topic describes how to use the Mapping Rule editor, Mapping tab, Actions subtab Action Mappings area, XQuery subtab to write an expression that defines the mapping for an action code for a particular mapping rule. To access this field, you must deselect Use Relationship Action Map and select the Advanced option.

  • Context: The input document is a source order item.

  • Prolog: You can declare the following variables within the prolog to determine the action code.

    • You can declare $sourceValue to access the action code of the source order item. This is the Order Item Action property value for the source order item.

    • You can declare $currentTargetValue to access the action code of the target order item. This is the Order Item Action property value for the target order item.

  • Body: The XQuery body returns an action code, or returns () to leave the current value unchanged.

The following example shows an XQuery expression that returns the source action code if the target action code is not already set and otherwise leaves the target action code unchanged.

                declare $sourceValue external;
        declare $currentTargetValue external;
        if (! fn:empty($currentTargetValue)) 
            $sourceValue
        else 
           ()

About Entity-to-Entity Advanced Mapping XQuery Expressions

This topic describes how to use the Mapping Rule editor, Mapping tab, Mapping subtab, Mapping Rule Item area, XQuery subtab to write an expression that defines an advanced mapping between two entities. This field is displayed when you select the target of an entity-to-entity mapping. This is the only type of mapping available for entity-to-entity mapping.

  • Context: The input document is a source order item.

  • Prolog: You can declare any namespaces needed to construct the target property (or properties) in the XQuery prolog. For example:

    declare namespace prop='http://oracle.communications.cso;
    
  • Body: The XQuery body returns a list of order item properties to be set on the target order item. If the property already exists on the target order item, it will be overwritten by the value returned from this XQuery expression.

The following example shows an XQuery expression that returns the structured Parameters property for the target order item.

declare namespace prop='http://oracle.communications.cso;
<prop:Parameters xmlns:param="http://oracle.communications.broadband">
   <parm:AAAAccount>Account1</parm:AAAAccount>
   <parm:DownloadSpeed>6</parm:DownloadSpeed>
   <parm:UploadSpeed>0.6</parm:UploadSpeed>
   <parm:MAC/>
   <parm:Brand>Siemens</param:Brand>
   <parm:Model>4200</parm:Model>
   <parm:Firewall>Y</parm:Firewall>
</prop:Parameters>

About Entity-to-Data-Element Advanced Mapping XQuery Expressions

This topic describes how to use the Mapping Rule editor, Mapping tab, Mapping subtab Mapping Rule Item area, XQuery subtab to write an expression that defines an advanced mapping between an entity and a data element. This field is displayed when you select the target of an entity-to-data-element mapping and select the Advanced option in the Mapping Rule Item topic.

  • Context: The input document is a source order item.

  • Prolog: There is no prolog for this XQuery.

  • Body: The XQuery body returns a data element value or returns () to leave the current value unchanged.

The following example shows an XQuery expression that returns "Y" if a particular parameter exists, and () if it does not exist.

if fn:exists(vf:instance("checkMe")/somevalue) 
   "Y"
else 
   ()

About Data-Element-to-Data-Element Advanced Mapping XQuery Expressions

This topic describes how to use the Mapping Rule editor, Mapping tab, Mapping subtab Configuration subtab, XQuery subtab to write an expression that defines an advanced mapping between two data elements. This field is displayed when you select the target of a data-element-to-data-element mapping and select the Advanced option in the Mapping Rule Item topic.

  • Context: The input document is a source order item during normal transformation. If invoked during forward data propagation, the input document is empty.

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

    declare namespace prop='http://oracle.communications.centralom';
    

    You can also declare the following variable within the prolog to determine the action code.

    • You can declare $value to contain the values of the target data elements.

  • Body: The XQuery body returns one or more data element values or returns () to leave the current value unchanged.

The following example shows an XQuery expression that returns the target value of a data element based on the value of the source data element.

declare variable $value external;
if (fn:empty($value)) then ('unknown') else (fn:concat('Loc: ', $value))

The following example shows an XQuery expression that returns the target value of a data element based on characteristics of the source order item.

declare namespace prop='http://oracle.communications.centralom';
if (fn:exists(osm:properties/prop:ServicePoint/text())) 
then (fn:concat('Loc: ', fn:normalize-space(osm:properties/prop:ServicePoint/string()))) 
else ('unknown')

About Reverse Mapping XQuery Expressions

This topic describes how to use the Mapping Rule editor, Mapping tab, Mapping subtab, Bi-Directional Mapping subtab, XQuery subtab to write an expression that defines an advanced mapping between two data elements. This field is displayed when you select the target of a data element-to-data element mapping and select the Advanced option in the Mapping Rule Item topic, if
Supports Bi-Directional Mapping is selected in the Details subtab of the Mapping tab for the selected mapping.

  • Context: The input document is empty.

  • Prolog: You can declare the following variables within the prolog to determine the action code.

    • You can declare $value to access the updated target value.

  • Body: The XQuery body returns the updated source value.

The following example shows an XQuery expression that returns () if the return value is unknown and otherwise returns the updated value.

declare variable $value external;
if ('unknown' = $value) then() else (fn:substring($value, 5))

About Multi-Instance XQuery Expressions

This topic describes how to use the Mapping Rule editor, Mapping tab, Mapping subtab, Multi-Instance Expression subtab, XQuery subtab to write an expression that defines key mapping for a multi-instance structure. This field is displayed when you select the target of a data element-to-data element mapping and select the Advanced option in the Mapping Rule Item topic, if the target data element is a member of a multi-instance structure.

  • Context: The input document is a source order item.

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

            declare namespace prop='http://oracle.communications.broadband';
    
  • Body: The XQuery body returns a key value that identifies a source order item instance.

The following example shows an XQuery expression that returns the concatenation of two source order item properties for the key value.

fn:concat(prop:areaCode, '-', prop:localNumber)

About Order Item Parameter Binding XQuery Expressions

This topic describes how to use the Order Item Parameter Binding editor, Parameter Bindings tab, Binding Expression area, XQuery subtab to write an expression that defines the bindings for one or more parameters on a conceptual model entity from an order item.

  • Context: The input document is an input order item. Each order item element in this node set is passed into the XQuery as the context.

  • Prolog: You can declare the namespace for the incoming order and the namespace for the conceptual model entity in the XQuery prolog. For example:

    declare namespace im="http://xmlns.oracle.com/InputMessage";
    declare namespace otm="CommonModelBroadbandCart/1.0.0.0.0";
    
  • Body: The body of the XQuery will return a node set of elements that correspond to the conceptual model entity data elements. Since you can have as many separate bindings between the entities as you like, this can return anything from one data element to all of them.

The following example shows an XQuery expression that returns an UploadSpeed and a DownloadSpeed parameter from two name-value pairs where the names are Upload Speed and Download Speed.

declare namespace fulfillord="http://xmlns.oracle.com/InputMessage";
declare namespace otm="OSMCom_3Play/1.0.0.0.0";

<otm:UploadSpeed>{fn:normalize-space(fulfillord:itemReference/fulfillord:specificationGroup/fulfillord:specification[fulfillord:name='Upload Speed']/fulfillord:value)}</otm:UploadSpeed>

<otm:DownloadSpeed>{fn:normalize-space(fulfillord:itemReference/fulfillord:specificationGroup/fulfillord:specification[fulfillord:name='DownloadSpeed']/fulfillord:value)}</otm:DownloadSpeed>

About Transformed Order Item Fulfillment State XQuery Expressions

This topic describes how to use the Transformed Order Item Fulfillment State Composition Rule Set editor, Composition Rules tab, Source Order Item subtab, XQuery field to write an expression that defines the conceptual model entities that should be present if the condition is to be evaluated. This field is only available when you have a condition selected in the tree in the tab, and you have selected the Advanced option on the subtab.

  • Context: The input document is the order.

  • Prolog: You can declare $orderItemIndex to access the index of the order item being considered.

  • Body: The body of the XQuery will return a Boolean value indicating whether the current rule should be used to calculate the fulfillment state.

The following example shows an XQuery expression that returns true if a particular order item property has a specific value.

declare variable $orderItemIndex external;
 
let $orderData := fn:root(.)/GetOrder.Response
let $orderItem := $orderData/_root/ControlData/OrderItem[@index=$orderItemIndex]
return 
    if (fn:exists($orderItem) and fn:data($orderItem/AnyProperties) = 'ABC')
    then fn:true()
    else fn:false()