You can move data from the Primary Document or any other document to the Process Data areas in IBM Sterling B2B Integrator (ISBI) by using the DocToDOM xpath function.
The data in the source document is required to be a valid XML document for the DocToDOM function to work correctly.
This blog aims to clarify the usage of the DocToDOM xPath function in ISBI and provide clear examples of its usage.
For the official ISBI Documentation about this function, please see links below:
xPat
DocToDOM parameters:
DocToDOM(xpath expression [, validate, loadDTD])
Xpath expression (Required): This is the xpath query to execute against ProcessData to find the node where the
document to be used is located.
The node returned needs to have an SCIObjectID attribute.
validate (Optional): whether to validate the XML document or not, Default value is true.
loadDTD (Optional): Determines if the parser loads the DTD, as specified. Default value is true.
Example usages of DocToDOM functions:
Unless stated otherwise, the examples below will be assumed to be using the following XML document as the input:
<Header>
<Body>
<Partner>
<Nam
<Con
</Partner>
<Doc
<Ord
</Body>
</Header>
----
In this example I’m attaching the entire contents of the primary document to process data.
The nodes returned will be attached to the root of ProcessData.
<assign to="." from
Results in ProcessData:
<ProcessData>
<PrimaryDocument SCIO
<BPs
<Header>
<Body>
<Partner>
<Nam
<Con
</Partner>
<Doc
<Ord
</Body>
</Header>
<BPend>ok</BPend>
</ProcessData>
----
In this example I’m attaching the entire contents of document called MyDocSave to process data.
The nodes returned will be attached to the node MyMessage.
<assign to="MyMessage" from=" DocT
Results in ProcessData:
<ProcessData>
<PrimaryDocument SCIO
<MyDocSave SCIO
<MyMessage>
<Header>
<Body>
<Partner>
<Nam
<Con
</Partner>
<Doc
<Ord
</Body>
</Header>
</MyMessage>
</ProcessData>
----
If the document you are working with is very large, it is not recommended to parse the full contents into ProcessData,
depending on how large the document is and how your system is configured, you could even get out of memory errors when using the DocToDOM function.
Instead of moving the complete document to ProcessData, it is recommended to move only the info you need to ProcessData
In this example, I’m specifying an additional xpath node (OrderNumber) that will be executed against the document in order to return only that node.
<assign to="." from=" DocT
or
<assign to="." from=" DocT
Results in ProcessData:
<ProcessData>
<PrimaryDocument SCIO
<Ord
</ProcessData>
----
You can also retrieve only the value of certain nodes of your document and assign them to a different node in ProcessData.
In the example below, we will retrieve the value of Contact in the document and assign it to the node "Cus
<assign to="
Results in ProcessData:
<ProcessData>
<PrimaryDocument SCIO
<Cus
</ProcessData>
----
When using DocToDOM, you might see validation error like below in the noapp log:
[STDERR] [Error] :1:46: Document is invalid: no grammar found.
[STDERR] [Error] :1:46: Document root element "Result", must match DOCTYPE root "null".
DocToDOM contains a validation routine, and it is set by default to validate input.
The error might occur when the document does not contain the values being searched.
The easiest way to get rid of that error is to turn the validation off for the DocToDOM function.
<assign to="." from
----
This example uses the LJDBC adapter to execute a select SQL query against the ISBI database and place the results directly into ProcessData using the DocToDOM function.
Note also the validation is turned off to avoid the validation error in the noapp log as mentioned in previous example.
Business Process example:
<process name
<sequence>
<operation name="JDBCQuery">
<participant name
<output mess
<assign to="
<assign to="
<assign to="
<assign to="
<assign to="sql">Select * from SI_VERSION</assign>
<assign to="." from="*"/>
</output>
<input message="inmsg">
<assign to="." from
</input>
</operation>
</sequence>
</process>
Results in ProcessData:
<ProcessData>
<Result>
<Row>
<PRO
<BUI
<LIC
<SI_
<SI_COMMENTS>asset upda
</Row>
<Row>
<PRO
<BUI
<LIC
<SI_
<SI_COMMENTS>B2BF upda
</Row>
</Result>
</ProcessData>
No comments:
Post a Comment