XMLSplitter

 

XMLSplitter can be used to split XML documents based on the configured XPath. This component is useful when there are repeated elements in the documents that can be processed by independently by subsequent components.

Configuration and Testing

Interaction Configuration

The following attributes can be configured in the interaction configuration panel.

Figure 1: Interaction Configuration Properties

Attributes

Schema:

The XSD of the input XML message has to be specified here. The XSD can be provided using schema editor which opens up on clicking ellipsis button  against this property. If the schema has any namespaces then they will be automatically populated in the Namespaces table shown in figure 2.

Namespaces:

Namespace prefixes that are used instead of complete namespace in XPath expression can be specified by clicking the ellipsis button  against this property which opens a Namespaces table as shown in the figure 2.  The namespaces present in the input schema, if any, are automatically populated in the table.  If the user wish to provide XPaths manually and wish to use namespaces which are not present in the schema provided, they can be added using the namespaces table.

Figure2: Namespace Table

The prefix with which a given namespace is identified. Prefix fsoa is reserved.

The URI of the namespace.

Operations that can be performed in the namespace table:

Namespaces present in the schema provided against property Schema are populated by default in the table. To use any namespaces that are not present in that schema, this option can be used. When the add button is clicked, a new namespace will be added with default prefix and URI. The columns are editable and thus an appropriate value can be specified in place of the default values.

Existing namespaces can be deleted from the table using this option. When namespaces are fetched from connected components or some XSD, there is a possibility that namespaces with same URI are added with different namespace prefix. In such cases, redundant namespaces can be deleted. This will not affect the schemas in which the namespaces are present.

Deletes all the namespaces in the table.

Fetches namespaces from the schemas present on ports of other components connected to XMLSplitter component. Thus it is advisable to configure the connected components completely before using this option.

Loads namespaces from the schema which is provided in the text editor opened when this button is clicked. This option can be used when there are XSDs whose namespaces are required for configuration. One schema must be loaded a time. The schemas are not stored in the component.

XPath

The XPath of the element based on which the split or group operation has to be performed is configured here. Click the ellipsis button  to open XPath editor. Choose an element/attribute from the list displayed in the left side panel of XPath editor and drag it onto the easel on the right side. The configured XPath expression must always evaluate an element or an attribute. XPath expressions that evaluate to any other types are not valid.

Note: There is no validation check for the XPath provided at configuration time, so the user has to configure XPath to return element.

Operation

The operation that has to be performed on the input XML message.

Splits the input XML at XPath defined and sends out output XMLs. The number of output XMLs is equal to the number of times the element/attribute defined by the property XPath is present in the input message.

'Processor' property is visible when this option is selected and 'Root Element Name' and 'Root Element Namespace' are hidden.

Note: when the XPath is specified as an attribute, then the value of the attribute is sent as the output message.

Example: If the input contains all the Employees details conforming to schema as shown in figure 3 and if it is required to split individual Employee details into separate messages then configure ‘XPath’ to ns1:Employee_Schema/ns1:Employee and select ‘Operation’ as Split. Refer to scenario 1 under Functional demonstration section.

Figure 3: Schema for Employees details

Splits the input XML at the element whose XPath is specified by the property XPath and then regroups the split XMLs which have the same value for that element into a single message. Thus the number of messages sent onto the output port depends on number of unique values present in XML for the element whose XPath is specified by the property XPath.

'Root Element Name' and 'Root Element Namespace' properties are visible when this option is selected and 'Processor' property is hidden. XSLT Processor is used for this operation.

Note:  When an element is selected using property XPath then those elements having same value will be grouped. If an attribute is selected as XPath then those elements for which this attribute is defined and having same value for this attribute will be grouped.

Example: If the input contains all the Employees details conforming to schema shown in figure 4 and if it is required to group individual employee details which are in the same group. (group information is stored in the attribute Group of Employee element), then configure ‘XPath’ to ns1:Employee_Schema/ns1:Employee/@Group and choose property ‘Operation’ as Group.  Employee elements whose group attribute is same will be combined into a single message.

Figure 4 Schema for Employees details with a group attribute

Root Element Name:

Root Element Name for the output XML(s). This property will be visible when the Operation is selected as Group.

Root Element NameSpace:

Namespace for the root element in output XML(s). If the default value is selected, then the root element namespace will be same as the target namespace of the input XSD provided. This property will be visible when the Operation is selected as Group.

Processor:

The Processor to be used for splitting.

Uses XPath Processor for splitting.

Uses XSLT for splitting. When the ‘Operation’ is ‘Group’, XSLT processor will be used for processing, so this property will not be visible in that case.

Note: Prefer XSLT for simple split Paths and XPath for complex paths. All kinds of split paths may not be supported by XSLT.

Output Schema:

Schema for the output message can be specified. Schema can be specified exclusively or can be generated with the help of input schema and XPath by clicking Get schema based on input and XPath button in the schema editor. This is not guaranteed to give a valid schema always. Please verify when using this feature.

Sample Input and Output

The configuration can be tested by clicking the Test button in the interaction Configuration panel.

Figure 5: Sample Input Message

Figure 6: Response Generated for XPath /ns1:BookStore/ns1:Book/ns1:Author

Functional Demonstration

Scenario 1

Splitting the input XML with respect to an element.

Configure the XMLSplitter as shown in Figure 7.

Figure 7: configuration for scenario 1

Use feeder and display component to send sample input and to check the response respectively. In the example given below, the split element selected is Author.

Figure 8: Scenario demonstration with sample input and output

Scenario 2

Grouping the input XML based on the XPATH provided.

Configure the XMLSplitter as described in Configuration and Testing section. The configuration for this example is shown below. In the example given below, the xpath element selected is Author.

Observe the two outputs shown in below figure

Figure 9: Configuration Properties panel

Figure 10: Sample input and output for Scenario 2.

Use Case Scenario

In the Bond Trading sample Event Process, XML splitter is used to split the Isin data into individual Isin elements.

Figure 11: Sample use case scenario

The event process demonstrating this scenario is bundled with the installer.

Documentation of the scenario and instructions to run the flow can be found in the Help tab of flow when open in Studio.

Useful Tips

The output schema can be computed from the input schema and the XPath used to split the XML document using the Get Schema based on Input and XPath   button in the schema editor for property OutputSchema. This is not guaranteed to give a valid schema always. Please verify when using this feature.

Prefer XSLT for simple split paths and XPath for complex paths. All kinds of split paths may not be supported by XSLT.

When component configuration sends multiple messages, messages contain the following JMS properties to identify first and last messages.

First document -  START_EVENT=true

All documents -  RECORD_INDEX=<index of output message>

Last document -  CLOSE_EVENT=true

When the input XML does not contain the element specified at Xpath, splitting/grouping is not performed and there will be no output messages in this case.

The output generated has the same instance id for all the split elements. This causes issues when document tracking, if you try to track both documents on the output of the splitter, you only get a single entry (due to the duplicate instance ID's).

To have different Instance IDs for different documents, workflow items in the flow have to be set properly.

The Instance ID is set at the first "Workflow Item" encountered in the event process, so if the 1st workflow item is set before OUT_PORT of XMLSplitter then there will be only one "Instance ID" for all splitted messages, however all splitted messages can have different "Document ID". On the other hand if the first "Workflow Item" is set at OUT_PORT of XMLSplitter each element will have a different "Instance ID".
 


Copyright © 2008-2010, Fiorano Software Pte. Ltd. and affiliates.

All rights reserved.

This software is the confidential and proprietary information of Fiorano Software ("Confidential Information"). You shall not disclose such Confidential Information and shall use it only in accordance with the terms of the license agreement enclosed with this product or entered into with Fiorano.