Stitch Editor Use Cases
Review the following stitch editor use cases.
Use the Three Stitch Operations (Assign, Remove, and Append) in an Integration
The following use case shows an integration that includes two stitch actions. All three stitch operations (assign, remove, and append) are used in this integration. This use case also describes how global variables are created and added to a stitch action.
- In the integration canvas, click . For this example, two global variables are defined for the stitch
action to use:
- The Count scalar variable maintains the count in a for-each loop in the integration.
- The GV_bookstore complex variable stores book information.
- If you want to create additional global variables, click the plus sign.
- From the Type list, select
Object to define a complex type variable. All other
available selections (String,
Boolean, and so on) are used for creating scalar type
variables.
The Sources schema tree is displayed to show all data structures used in the integration.
- Name the variable (for this example,
gv_sample is used) and expand the schema tree to
select the element to use (for this example, book is
selected). You can also drag book to the
Type field of gv_sample.
You are now ready to define complex assignments in the stitch editor.
- Return to the integration and open the first stitch action.
Note that two assignments are defined to perform different operations for this example.
- The first assignment performs an assign operation. The
Count variable to use in the for-each loop is
initialized to zero.
- The second assignment performs an operation to append new
book information to the existing book list.
- The first assignment performs an assign operation. The
Count variable to use in the for-each loop is
initialized to zero.
- Click to view the complete XPath expression of the
book variable. The book information is appended to
the book list.
- Click X in the upper right corner to close the first stitch action.
- Click the second stitch action, which is executed inside the
for-each loop. This stitch action removes price information from each book
during the looping iteration. The count index is executed in the for-each loop
until the entire book list is read.
- Activate and invoke the integration. For this example, the payload
removes the price details and appends additional author details (for this
example,
Joe
Smith
).<?xml version="1.0" encoding="utf-8"?> <bookstore xsl:noNamespaceSchemaLocation="schema.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <book> <title lang="en">Java</title> <price>100USD</price> <author> <firstName>Joe</firstName> <lastName>Smith</lastName> </author> </book> </bookstore>
- View the results of the integration execution in the activity stream.
TO Element Does Not Exist in the Variable DOM
The following TO
element use cases and their expected
results are described.
ASSIGN into an Unbounded Element that Does Not Exist in the TO DOM
- Expected Result: The
TO
element is created and theFROM
element is assigned. - Assignment:
($OutputVarNameOnEB/ns0:root/ns0:b[1]/ns0:bch1).ASSIGN($V1/ns0:root/ns0:b[1]/ns0:bch1)
$OutputVarNameOnEB before assign | $V1Content | $OutputVarNameOnEB Result |
---|---|---|
|
|
|
APPEND a List into an Unbounded Element that Does Not Exist in the TO DOM
- Expected Result: The
FROM
list is inserted in theTO
DOM at the right location, conforming with the schema. - Assignment:
($OutputVarNameOnEB/ns0:root/ns0:b[1]/bch3).APPEND($V1/ns0:root/ns0:b[1]/ns0:bch3)
$OutputVarNameOnEB before assign | $V1Content | $OutputVarNameOnEB Result |
---|---|---|
|
|
|
Predicate Usage
The following predicate use cases and their expected results are described.
Assign or Append - The FROM Predicate Selects Zero Nodes (Out of Bounds)
- Expected Result: An exception is thrown at runtime. At design time, the system cannot detect if the predicate can select data.
- Runtime Error Assignment Example:
($t1).ASSIGN($v1/globalElement/element2[count(.)+1])
Note:
The[count(.)+1]
predicate is always out of bounds.This assignment fails at runtime and an exception is thrown.
Append to an Indexed TO - The TO Element Has a Predicate for an APPEND Operation - Not Supported
- Expected Result: The system at design time does not enable you to
predicate the repeating element where the
APPEND
happens (last step on theTO
). TheAPPEND
always appends at the end of the list. - Example:
($OutputVarNameOnEB/client:processResponse/client:c[2]).APPEND($InputVarNameOnEB/client:process/client:c)
- Not Supported:
"Predicated TO".APPEND()
(Assignment example 1)($<OutputVarNameOnEB>/client:processResponse/client:c[@attr1='some existing value']).APPEND($InputVarNameOnEB/client:process/client:c[1])
Note:
The[@attr1='some existing value']
predicate filters/selects a subset of nodes. Appending into a subset of nodes makes no intuitive sense. - Not Supported:
"APPEND After"
(Assignment example 2)($OutputVarNameOnEB/client:processResponse/client:c[2]).APPEND($<InputVarNameOnEB>/client:process/client:c)
Note:
The[2]
predicate is not intuitive. Do youAPPEND
to single instance 2,APPEND
after instance 2, orAPPEND
before instance 2.Design-time error: The system throws an error at design time for both examples.
- Not Supported:
Assign to Predicated TO - The Predicate References an Existing Node
- Expected Result: The assignment is done into the
TO
element referenced by the predicate.
Assign to Indexed TO - The TO Indexed Predicate References a Node that Does Not Exist
- Expected Result: The system creates the missing nodes, but the missing nodes are created empty.
- Example:
($v1/ns0:po/ns0:header/ns0:customer/ns0:email[2]).ASSIGN("jim@yahoo.com")
Note:
The indexed predicate refers to a predicate whose execution resolved into a positive number. - Missing
TO
Nodes Assignment Example:($OutputVarNameOnEB/client:processResponse/client:c[count(.)+4]).assign($InputVarNameOnEB/client:process/client:c[1])
Note:
The[count(.)+4]
predicate is always out of bounds.
$OutputVarNameOnEB before assign | $InputVarNameOnEB Content | $OutputVarNameOnEB Result |
---|---|---|
|
|
|
Assign to Indexed Ancestor TO - The TO Indexed Predicate References a Node that Does Not Exist
- Expected Result: The system creates the ancestor instances up to the index if they do not exist and then performs the assignment.
- Example:
($v1/ns0:po/ns0:details/ns0:item[$i]/itemName).ASSIGN("iPhone X") ...whereas $i is a number having value 4
$v1 before assign | $v1 after assignment |
---|---|
|
|
Assign - The TO Logical Predicate References a Node that Does Not Exist
- Expected Result: An exception at runtime is thrown.
- Definition: A logical predicate is a predicate whose execution
resolves into a boolean result: true or false. This case refers to when the
result becomes false. Therefore, there is no
TO
element selected. - Runtime Error Assignment Example:
($OutputVarNameOnEB/client:processResponse/client:c[@attr1='eng']).assign($InputVarNameOnEB/client:process/client:c[1]
)Note:
Below the DOM, there is noc
node with itsattr1
havingeng
as a value.
$OutputVarNameOnEB before assign | Result |
---|---|
|
This assignment fails at runtime with an exception. |
- Runtime Error Assignment
Example:
($OutputVarNameOnEB/client:processResponse/client:c[ns05:aCustomFunction(.)]).assign($InputVarNameOnEB/client:process/client:c[1])
- Details: At runtime, the
ns05:aCustomFunction(.)
may returnfalse
or a number. Using the following DOM:- If
ns05:aCustomFunction(.)
returns1
, the assignment occurs. - If
ns05:aCustomFunction(.)
returns2
, this is the same as use case Append to an Indexed TO - The TO Element Has a Predicate for an APPEND Operation - Not Supported. - If
ns05:aCustomFunction(.)
returns false, a runtime error occurs.
- If
$OutputVarNameOnEB before assign | Result |
---|---|
|
This assignment fails at runtime with an exception. |
Extended Data Types
The following extended data types use cases and their expected results are described.
Schema Validation when <xsd:any> or xsd:anyType are in the location path - Use Case - ASSIGN - The "FROM" and/or "TO"
- Expected Result: You cannot type the location path steps after the
xsd:anyType
(or<xsd:any>
's parent). The location path is accepted, as long as the syntax is valid. - Example Details: Populating the
AnyType
Element with complex content.($v1/globalElement/element3AnyType).ASSIGN($list/ns1:items/ns1:item_Undoulded)
$v1 before assign $list content outputVariable expected result <globalElement xmlns="http://jorge.com/AssignAnyType2"> <element1 lang="esperanto"/> <element4>2017-09-27T14:31:00</element4> </globalElement>example
<items xmlns="http://xmlns.XYZ.com"> <item_Unboulded> <name>Music</name> <price>98.99</price> </item_Unboulded> <item_Unboulded> <name>Fighter</name> <price>300.99</price> </item_Unboulded> <item_Unboulded> <name>Lover</name> <price>20.99</price> </item_Unboulded> </items>example
<globalElement xmlns="http://jorge.com/AssignAnyType2"> <element1 lang="esperanto"/> <element3AnyType> <item_Unboulded xmlns="http://xmlns.XYZ.com"> <name>Music</name> <price>98.99</price> </item_Unboulded> <item_Unboulded xmlns="http://xmlns.XYZ.com"> <name>Fighter</name> <price>300.99</price> </item_Unboulded> <item_Unboulded xmlns="http://xmlns.XYZ.com"> <name>Lover</name> <price>20.99</price> </item_Unboulded> </element3AnyType> <element4>2017-09-27T14:31:00</element4> </globalElement>
- Example Details: Referencing data within the
any
Type.If you now want to reference the price ofitem_Unboulded
2:($vFigtherPrice).ASSIGN($v1/ns0:globalElement/ns0:element3AnyType/ns1:item_Unboulded[2]/ns1:price)
$vFighterPeice resultExample
:300.99
If you now want to assign the name of element 2:($v1/ns0:globalElement/ns0:element3AnyType/ns1:item_Unboulded[2]/ns1:name).ASSIGN("Me Ma Mu")
outputVariable
expected result:<!-- note the instance 2 name is changed from fighter to Me Ma Mu <globalElement xmlns="http://jorge.com/AssignAnyType2"> <element1 lang="esperanto"/> <element3AnyType> <price xmlns="http://jorge.com/price">300</price> </element3AnyType> <element3AnyType> <item_Unboulded xmlns="http://xmlns.XYZ.com"> <name>Music</name> <price>98.99</price> </item_Unboulded> <item_Unboulded xmlns="http://xmlns.XYZ.com"> <name>Me Ma Mu</name> <price>300.99</price> </item_Unboulded> <item_Unboulded xmlns="http://xmlns.XYZ.com"> <name>Lover</name> <price>20.99</price> </item_Unboulded> </element3AnyType> <element4>2017-09-27T14:31:00</element4> </globalElement>
Use Cases for <xsd:anyType>, <xsd:any>, and xsd:Any Defined in the Schema
The following XSD use cases and their expected results are described.
- For
<xsd:anyType>
and<xsd:any>
:Error rendering macro 'excerpt-include' No link could be created for 'Expected Result - xsd:anyType and xsd:any'.
- For
xsd:Any
defined in the schema:Error rendering macro 'excerpt-include' No link could be created for 'Expected Result - 2 XSD:ANY'.