More complex links can be built with the Constraints tab. You can constrain the relationship between source and target nodes using the functionally of the Constraints tab.
The following table provides information on which features of the Constraints tab, you should use to depending on how you want to constraint or manipulate your data, as shown in the following table:
Combine the contents of two different schemas. Sub-elements of the repeating elements are not merged. |
||
Merge the contents of repeating elements. Sub-elements of repeating elements are merged. |
||
Combine sets of data of the same type (same schema) into larger sets of data. Sub-elements of the repeating elements are not merged. |
||
Combine data and repeating elements based on a passed in key value. |
Example: Using the Group by Key Fields Option of the Constraints Tab |
|
Add a condition constraint which limits the repeating elements that are returned. TODO: Maybe make this a complex condtional constraint? or add another row? |
Example: Creating a Conditional Constraint Using the Constraints Tab |
|
Return a different value for target node based on the outcome of condition(s) in if-then-else(s). |
||
Convert data from a XML Schema simple type to a complext type. |
Figure: Non-Repeating Target Element to Repeating Source Group |
Example: Creating a Transformation Between a Non-Repeating Source Element and Repeating Target Group |
Convert data from a XML Schema complex type to a simple type. |
Figure: Repeating Source Group to Non-Repeating Target Element |
Example: Creating a Transformation Between a Repeating Source Group and Non-Repeating Target Element |
You can use the mapper functionality to combine the contents of two different schemas, as shown in the following figure:
Figure : Combining Data From Different Schemas
In this case, the customer information is merged with the line-items repeating element to form one combined XML document.
This example describes how to create a transformation which combines the data from two different XML Schemas. This example shows how to combine the XML sample data shown in the preceding figure. In this example, the source data is not constrained or limited to produce the target data—a where clause was not added to the for loop iterating over the purchase-order/line-items/line-items using the Constraints tab.
To Combine Data From Different Schemas
For this example, import the files: CustInfo.xsd and PO.xsd files. If you installed WebLogic Platform in the c:\bea directory, import these files from the c:\bea\weblogic81\workshop\help\doc\en\integration\reffiles\transform\dataDiffSchemas directory.
For this example, import the file: POCustInfo.xsd. If you installed WebLogic Platform in the c:\bea directory, import this file from the c:\bea\weblogic81\workshop\help\doc\en\integration\reffiles\transform\dataDiffSchemas directory.
Importing schemas files triggers a build of the current Schemas project folder. Wait until the current Schemas project folder is built before proceeding to the next step. (The representations of the schemas will not be available in Available Input Types and Available Output Type panes until build is complete.)
To select an existing method, in the Design View of the Transformation file:
The elements and attributes that make up the selected element are displayed in the Selected Input Types pane.
For this example, select and add the CustInfo.xsd/customer and PO.xsd/purchase-order nodes.
For this example, expand the POCustInfo.xsd schema folder.
For this example, select the POCustInfo.xsd/purchase-order element.
The elements and attributes that make up the selected element are displayed in the Selected Output Types pane.
The Design View of the XQ file is displayed.
For this example, link the $purchase_orderDoc/line-items/line-item repeating element to the purchase-order/line-items/line-item repeating element.
A dashed line linking the two repeating elements is displayed. The dashed line with short dashes represents a structural link—a link between two parent structures that does not map data directly. The dashed-line representation for a structural link is shown in the following figure:
To learn more about links, see Link Representations.
For this example, link the $purchase_orderDoc/line-items/line-item/part-no element to the purchase-order/line-items/line-item/part-no element. In addition, link the $purchase_orderDoc/line-items/line-item/quantity element to the purchase-order/line-items/line-item/quantity element.
A dashed line linking the two sub-elements is displayed. The dashed line with long dashes represents a data structural link—a data link that also links two structures. The dashed-line representation for a data structural link is shown in the following figure:
To learn more about links, see Link Representations.
A data structural link between the $customerDoc/customer-id node and the $purchase-order/customer/customer-id node is created.
A data structural link between the $customerDoc/customer-name node and the $purchase-order/customer/customer-name node is created.
A data structural link between the $customerDoc/customer-address node and the $purchase-order/customer/customer-address node is created.
The map between the source and target elements is shown in the following figure.
For this example, in the Source Data pane, select the $purchase_orderDoc node and import the file: InputPO.xml. In the Source Data pane, select the $customerDoc node and import the file: InputCust.xml. If you installed WebLogic Platform in the c:\bea directory, import these files from the c:\bea\weblogic81\workshop\help\doc\en\integration\reffiles\transform\dataDiffSchemas\XML directory.
Note: You can cut and past directory paths into the Name field of the Open File to Test pane to jump to directory locations. If you installed WebLogic Platform in the c:\bea directory, you can jump to the directory that contains the XML files for this example, by pasting the following directory path into the Name field: c:\bea\weblogic81\workshop\help\doc\en\integration\reffiles\transform\dataDiffSchemas\XML and then pressing enter.
If not currently running, the WebLogic Server for the current application will be started. In order for a query to run, the WebLogic Server for the current application must be running.
In the Result Data pane, after the query is run a graphical representation of the output data is displayed.
You can use mapper functionality to merge the contents of repeating elements, as shown in the following figure:
Figure : Merging the Contents of Repeating Elements
The join, shown in the preceding figure, merges the price and availability from the two input documents to one output document called Quote.xml. Specifically, the price (element: price) and widget Id (element: widgetId) for the widgets is supplied by the PriceQuote.xml document and the number of widgets available (element: requestedQuanity) is supplied by the AvailQuote.xml document. The widgetId and requestedQuanity elements are part of the availRequest repeating element and price element is part of the priceRequest repeating element. These subelements to repeating elements are merged into subelements of the quoteResponse repeating element.
For this example, a complete merge of the two sets of elements resulting in four elements as shown in Figure: Merging the Contents of Repeating Elements is not desired. Instead a conditional constraint is needed that will return the merged element only if the condition is true. To learn more, see Example: Creating a Conditional Constraint Using the Constraints Tab.
For a step-by-step walk through of using the mapping functionality to create a join with a conditional constraint, see Tutorial: Building Your First Data Transformation. Specifically, the join is created in Step 4: Mapping a Repeating Element (Join) in the Tutorial: Building Your First Data Transformation.
You can use the Union option of the Constraints tab to combine sets of data of the same type into larger sets of data, as shown in the following figure:
Figure : Combining Sets of the Same Data
In this union, repeating elements of the same type are combined into a larger set but in the preceding join example in Example: Merging the Contents of Repeating Elements, the contents of repeating elements are merged.
<xs:choice maxOccurs="unbounded">
LIZ COMMENT: I made this change to the PO.xsd schema.
This section describes how to create a transformation which combines two sets of repeating elements using the Union option. This section shows how to combine the example XML data shown in the preceding figure.
To Combine Sets of Data of the Same Type
For this example, import the file: PO.xsd. If you installed WebLogic Platform in the c:\bea directory, import this file from the c:\bea\weblogic81\workshop\help\doc\en\integration\reffiles\transform\u
For this example, import the file: Ouput.xsd. If you installed WebLogic Platform in the c:\bea directory, import this file from the c:\bea\weblogic81\workshop\help\doc\en\integration\reffiles\transform\union directory.
Importing schemas files triggers a build of the current Schemas project folder. Wait until the current Schemas folder is built before proceeding to the next step. (The representations of the schemas will not be available in Available Input Types and Available Output Type panes until build is complete.)
To select an existing method, in the Design View of the Transformation file:
The elements and attributes that make up the selected element are displayed in the Selected Input Types pane.
For this example, add the PO.xsd/purchase-order element twice.
The elements and attributes that make up the selected element are displayed in the Selected Output Type pane.
The Design View of the XQ file is displayed.
For this example, link the $purchase_orderDoc/line-items/line-item repeating element in the Source pane to the order/items/item repeating element in the Target pane.
A dashed line linking the two repeating elements is displayed. The dashed line with short dashes represents a structural link—a link between two parent structures that does not map data directly. The dashed-line representation for a structural link is shown in the following figure:
To learn more about links, see Link Representations.
For this example, link the $purchase_orderDoc1/line-items/line-item repeating element in the Source pane to the order/items/item repeating element in the Target pane.
A dashed line linking the two repeating elements is displayed. The dashed line with short dashes represents a structural link—a link between two parent structures that does not map data directly. The dashed-line representation for a structural link is shown in the following figure:
At this point, in the Constraint Type pane of the Constraints tab, the Repeatability/Join option is selected.
Keep the last link selected for the next step.
In the Source pane, select each of the sub-elements of the repeating element and drag them to the analogous sub-element of the repeating element in the Target pane.
For this example, link the nodes shown in the following table:
Solid blue lines linking the two sub-elements are displayed. These solid lines represents a data link—a link that converts the value of the source node directly to the value of the target node The solid line representation for a data link is shown in the following figure.
Since the two structural links have the union constraint applied to them, a set of implied data links between the second set of subelements are generated as shown in the following figure.
The solid gray lines represents implied links.
For this example, in the Source Data pane, select the $purchase_orderDoc node and import the file: InputPO1.xml. In the Source Data pane, select the $purchase_orderDoc1 node and import the file: InputPO2.xml. If you installed WebLogic Platform in the c:\bea directory, import these files from the c:\bea\weblogic81\workshop\help\doc\en\integration\reffiles\transform\union\XML directory.
Note: You can cut and past directory paths into the Name field of the Open File to Test pane to jump to directory locations. If you installed WebLogic Platform in the c:\bea directory, you can jump to the directory that contains the XML files for this example, by pasting the following directory path into the Name field: c:\bea\weblogic81\workshop\help\doc\en\integration\reffiles\transform\union\XML and then pressing enter.
If not currently running, the WebLogic Server for the current application will be started. In order for a query to run, the WebLogic Server for the current application must be running.
In the Result Data pane, a graphical representation of the output data is displayed.
Note: The nodes are being joined in the union and not the data in the nodes. For example, if you are merging repeating elements in which the value of the part-no element is equal to 1, both part-no elements appear in the output as shown in the following figure:
The query returns both repeating elements because it determines the repeating nodes are unique, even if the values of the part-no element are both equal to 1.
You can use the Group by Key Fields option of the mapper functionality to group data based on a key value, as shown in the following figure:
Figure : Merging Data Using a Key Value
In the example shown in the preceding figure, the in-warehouse-id element is the key field that is used to group the output. Both the first and third instances of the in-line-item repeating element in the input document contain the same value of the in-warehouse-id element (Warehouse1), so these elements are grouped together in the output document.
This section describes how to group data by a key field using the Group by Key Fields option. This section shows how to group the example XML data shown in the preceding figure.
To Group Sets of Data Based on a Key Field
For this example, import the files: GroupKeyFldIn.xsd and GroupKeyFldOut.xsd. If you installed WebLogic Platform in the c:\bea directory, import these files from the c:\bea\weblogic81\workshop\help\doc\en\integration\reffiles\transform\groupKeyFields directory.
Importing schemas files triggers a build of the current Schemas project folder. Wait until the current Schemas folder is built before proceeding to the next step. (The representations of the schemas will not be available in Available Input Types and Available Output Type panes until build is complete.)
The elements and attributes that make up the selected element are displayed in the Selected Input Types pane.
For this example, complete this step for the GroupKeyFldIn.xsd/in-warehouse-inventory element.
For this example, expand the GroupKeyFldOut.xsd schema folder.
For this example, select the GroupKeyFldOut.xsd/out-inventory element.
The elements and attributes that make up the selected element are displayed in the Selected Output Type pane.
The Design View of the XQ file is displayed.
For this example, make the following links:
A dashed line linking the two repeating elements is displayed. The dashed line with short dashes represents a structural link—a link between two parent structures that does not map data directly. The dashed-line representation for a structural link is shown in the following figure:
To learn more about links, see Link Representations.
For this example, link the $in_warehouse_inventoryDoc/in-line-item repeating element to the out-inventory/out-line-item repeating element.
A dashed line linking the two repeating elements is displayed. The dashed line with short dashes represents a structural link—a link between two parent structures that does not map data directly. The dashed-line representation for a structural link is shown in the following figure:
To learn more about links, see Link Representations.
At this point, in the Constraint tab, the Constraint Type is Repeatability/Join but in a preceding step, the Constraint Type will be set to Group by Key Fields)
For this example, link the $in_warehouse_inventoryDoc/in-line-item repeating element to the out-inventory/out-warehouse-inventory repeating element.
Keep this link selected for the next step.
The following is displayed in the Design View as shown in the following figure:
For this example, in the Source Data pane, select the $in_warehouse_inventoryDoc node and import the file: GroupKeyFldIn.xml. If you installed WebLogic Platform in the c:\bea directory, import this file from the c:\bea\weblogic81\workshop\help\doc\en\integration\reffiles\transform\groupKeyFields\XML directory.
If not currently running, the WebLogic Server for the current application will be started. In order for a query to run, the WebLogic Server for the current application must be running.
In the Result Data pane, a graphical representation of the output data is displayed.
In Merging the Contents of Repeating Elements, both of the input documents (PriceQuote.xml and AvailQuote.xml) share the common element widgetId. A constraint (as a condition) can be added to the join that specifies if the widgetId of the availRequest element is equal to the widgetId of the priceRequest element the merged repeating element quoteResponse be returned. Adding this constraint would change the resulting data as shown in Figure: Merging the Contents of Repeating Elements to the data shown in Figure: Using a Conditional Constraint to Merge Data.
Figure : Using a Conditional Constraint to Merge Data
For a step-by-step walk through of using the mapping functionality to create a join with a constraint, see Tutorial: Building Your First Data Transformation. Specifically, the join is created in Step 4: Mapping a Repeating Element (Join) in the Tutorial: Building Your First Data Transformation.
This example shows how to map a XML Schema simple type (for example: a non-repeating single element) to a XML Schema complex type (for example: a repeating element) as shown in the following figure. In this example, you will create a transformation that during run time will take a single source element and maps it to repeating target element as shown in the following figure.
Figure : Non-Repeating Target Element to Repeating Source Group
To Create and Run a Transformation Between a Non-Repeating Source Element and a Repeating Target Group
For this example, import the file: .xsd. If you installed WebLogic Platform in the c:\bea directory, import this file from the c:\bea\weblogic81\workshop\help\doc\en\integration\reffiles\transform\singleToRepeat directory.
For this example, import the file: Dates.xsd. If you installed WebLogic Platform in the c:\bea directory, import this file from the c:\bea\weblogic81\workshop\help\doc\en\integration\reffiles\transform\singleToRepeat directory.
Importing schemas files triggers a build of the current Schemas project folder. Wait until the current Schemas folder is built before proceeding to the next step. (The representations of the schemas will not be available in Available Input Types and Available Output Type panes until build is complete.)
To select an existing method, in the Design View of the Transformation file:
The elements and attributes that make up the PODate.xsd/PODate element are displayed in the Selected Input Types pane.
For this example, select the Dates.xsd/date element.
The elements and attributes that make up the Dates.xsd/date element are displayed in the Selected Output Type pane.
The Design View of the XQ file is displayed.
A dashed line linking the two elements is displayed. The dashed line with short dashes represents a structural link—a link that does not map data directly. The dashed-line representation for a structural link is shown in the following figure.
To learn more about links, see Link Representations.
A dashed line (representing a structural link) between two elements is displayed and the two dates (PODateDoc/delivery-date and PODateDoc/billing-date) are automatically unioned together. In addition, the Structural Link variable PODate is automatically created and displayed in the Data Palette.
The following XQuery is code is generated:
<ns1:dates> { for $PODate in $PODateDoc/ns0:billing-date union $PODateDoc/ns0:delivery-date return <ns1:date/> } </ns1:dates>
$PODateDoc is the source or input variable to the transformation, while $PODate is the iteration variable for union of the elements: $PODateDoc/ns0:billing-date and $PODateDoc/ns0:delivery-date.
During run time, the for loop in the preceding XQuery code is executed twice. The first time the for loop is run, the iteration variable $PODate is equal to the first element in the union: $PODateDoc/ns0:billing-date and the second time the for loop is run the iteration variable $PODate is equal to the second element in the union: $PODateDoc/ns0:delivery-date. The XML data returned by the preceding query returns two empty elements: <ns1:date/>. The following steps will add the XQuery code to return the billing and delivery dates to the query.
Two data links are created as shown in the following figure.
Since the structural links (PODateDoc/billing-date to dates/date) and (PODateDoc/delivery-date dates/date) are unioned together, when you created the link from the PODateDoc/billing-date element to the dates/value element (dates/value), a second data link between the PODateDoc/deilivery-date element and dates/value element is automatically created.
Keep the PODateDoc/billing-date to dates/type link selected for the next step.
The XQuery if-then-else construct is added to the link. For example, the following XQuery source code segment for the link is replaced:
data($PODate)
By the following XQuery source code segment for the link:
if (xf:boolean("true")) then data($PODate) else ()
The If Condition pane appears.
Note: You must enter double quotes around the "billing-date" string.
The condition is added to the if section of the if-then-else.
data($PODate)
"BILLING"
Note: You must enter double quotes around the "BILLING" string.
Note: You must enter double quotes around the "DELIVERY" string.
The following XQuery code is displayed:
if (xf:local-name($PODate) = "billing-date") then "BILLING" else "DELIVERY"
During run time, this if-then-else statement is executed twice by the XQuery for loop. The if part of the if-then-else executes the following conditon:
xf:local-name($PODate) = "billing-date"
In the left-hand expression of the if condtion, the iteration variable $PODate is passed into the local-name function as a parameter. The local-name function returns the name of the XML element. For example: if the $PODate iteration variable contains the XML element named billing-date, the string: billing-date is returned by the local-name function and therefore, the left-hand expression of the if condtion evaluates to the string: billing-date.
The right-hand expression of the if condition is equal to the string: "billing-date".
In the if condition, the left-hand expression is compared with the right-hand expression, and if the two strings are equal, the if condition evaluates to true and the string: "BILLING" is returned as the value of the target node: dates/date/type.
Note: For simplistly, in this example it is assumed that if $PODate does not equal "billing-date", it must equal "delivery-date".
For this example, in the Source Data pane, select the $datesDoc node and import the file: InputDates.xml. If you installed WebLogic Platform in the c:\bea directory, import this file from the c:\bea\weblogic81\workshop\help\doc\en\integration\reffiles\transform\singleToRepeat\XML directory.
Note: You can cut and past directory paths into the Name field of the Open File to Test pane to jump to directory locations. If you installed WebLogic Platform in the c:\bea directory, you can jump to the directory that contains the XML files for this example, by pasting the following directory path into the Name field: c:\bea\weblogic81\workshop\help\doc\en\integration\reffiles\transform\singleToRepeat\XML and then pressing enter.
If not currently running, the WebLogic Server for the current application will be started. In order for a query to run, the WebLogic Server for the current application must be running.
In the Result Data pane, a graphical representation of the output data is displayed.
This example shows how to map a XML Schema complex type (for example: a repeating element) to a XML Schema simple type (for example: a non-repeating single element). In this example, you will create a transformation that during run time will take a source repeating element and maps it to single target field using constraints as shown in the following figure.
Figure : Repeating Source Group to Non-Repeating Target Element
To Create and Run a Transformation Between a Repeating Source Group and a Non-Repeating Target Element
For this example, import the file: Dates.xsd. If you installed WebLogic Platform in the c:\bea directory, import this file from the c:\bea\weblogic81\workshop\help\doc\en\integration\reffiles\transform\repeatToSingle directory.
For this example, import the file: PODate.xsd. If you installed WebLogic Platform in the c:\bea directory, import this file from the c:\bea\weblogic81\workshop\help\doc\en\integration\reffiles\transform\repeatToSingle directory.
Importing schemas files triggers a build of the current Schemas project folder. Wait until the current Schemas folder is built before proceeding to the next step. (The representations of the schemas will not be available in Available Input Types and Available Output Type panes until build is complete.)
To select an existing method, in the Design View of the Transformation file:
The elements and attributes that make up the Dates.xsd/dates element are displayed in the Selected Input Types pane.
For this example, select the PoDate.xsd/PODate element.
The elements and attributes that make up the PoDate.xsd/PODate element are displayed in the Selected Output Type pane.
The Design View of the XQ file is displayed.
Keep this link selected for the next step.
A dashed line linking the two elements is displayed. The dashed line with short dashes represents a structural link—a link that does not map data directly. The dashed-line representation for a structural link is shown in the following figure.
To learn more about links, see Link Representations.
During run time, the constraint created in this step, just tests if constraint: datesDoc/date/type is equal to the string: "BILLING". The next step will add the XQuery code to return data if during run time the constraint is equal to true.
During run time, this data link will return the value of datesDoc/date/value as the value of billing-date if the constraint: data($date/ns0:type) = "BILLING" evaluates to true.
A dashed line linking the two elements is displayed.
Keep this link selected for the next step.
During run time, the constraint created in step, tests if datesDoc/date/type is equal to the string: "DELIVERY".
During run time, this data link will return the value of datesDoc/date/value as the delivery-date if the constraint: data($date/ns0:type) = "DELIVERY" evaluates to true.
For this example, in the Source Data pane, select the $datesDoc node and import the file: InputDates.xml. If you installed WebLogic Platform in the c:\bea directory, import this file from the c:\bea\weblogic81\workshop\help\doc\en\integration\reffiles\transform\repeatToSingle\XML directory.
Note: You can cut and past directory paths into the Name field of the Open File to Test pane to jump to directory locations. If you installed WebLogic Platform in the c:\bea directory, you can jump to the directory that contains the XML files for this example, by pasting the following directory path into the Name field: c:\bea\weblogic81\workshop\help\doc\en\integration\reffiles\transform\repeatToSingle\XML and then pressing enter.
If not currently running, the WebLogic Server for the current application will be started. In order for a query to run, the WebLogic Server for the current application must be running.
In the Result Data pane, a graphical representation of the output data is displayed.
This example shows how to create mappings with schemas that have recursive elements. A recursive element contains a child element of the same type as the parent as shown in the following example XML Schema listing:
<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.acme.org/Product" xmlns="http://www.acme.org/Product" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:complexType name="product"> <xs:sequence> <xs:element name="part-description" minOccurs="0" maxOccurs="unbounded" type="xs:string" /> <xs:element name="child-product" minOccurs="0" maxOccurs="unbounded" type="product" /> </xs:sequence> </xs:complexType> </xs:schema>
In this example, the product element is a recursive because it contains a child-product element which is type product as shown in bold in the preceding code listing.
Figure : Transformation Between a Non-Recursive Source Elements and a Recursive Target Element
To Create and Run a Transformation Between a Non-Recursive Source Elements and a Recursive Target Element
For this example, import the files: SupplierAcme.xsd and Product.xsd files (step 2 in General Steps to Open or Create a Query in the Mapper.) If you installed WebLogic Platform in the c:\bea directory, import these files from the c:\bea\weblogic81\workshop\help\doc\en\integration\reffiles\transform\recursive directory.
For this example, select and add the SupplierAcme.xsd/supplier-acme node as an input type (step 4 in General Steps to Open or Create a Query in the Mapper.)
For this example, select and add the Product.xsd/Global Types/product node as an output type (step 4 in General Steps to Open or Create a Query in the Mapper.)
A second parent node appears under the child-product node as shown in the following figure.
A third parent node appears under the second-level child-product node as shown in the following figure.
For this example, in the Source Data pane, select the $supplier_acmeDoc node and import the file: InputRecursive.xml. If you installed WebLogic Platform in the c:\bea directory, import this file from the c:\bea\weblogic81\workshop\help\doc\en\integration\reffiles\transform\recursive\XML directory.
Note: You can cut and past directory paths into the Name field of the Open File to Test pane to jump to directory locations. If you installed WebLogic Platform in the c:\bea directory, you can jump to the directory that contains the XML files for this example, by pasting the following directory path into the Name field: c:\bea\weblogic81\workshop\help\doc\en\integration\reffiles\transform\recursive\XML and then pressing enter.
If not currently running, the WebLogic Server for the current application will be started. In order for a query to run, the WebLogic Server for the current application must be running.
In the Result Data pane, a graphical representation of the output data is displayed.
![]() |
![]() |