Data maps are the most common method used for Transformation but they have limited applications when it comes to complex transformations. Data maps are useful where you have one-to-one mapping between source and target XML tags. In case you need to apply certain logic before transformation then you cannot use Data Maps and have to revert to scripting to achieve desired transformation.
It was the solution of a complex problem that made me realize the power and potential of XSLT when it comes to Siebel EAI. Before I jump into the problem and solution let me just give you brief overview of XSLT layman’s term.
XSLT: XSLT stands for EXtensible Stylesheet Language (XSL) Transformations. XSLT uses XPath to actually traverse the XML document and apply transformations based on the user defined rules. You should have knowledge of both XPath and XSLT to use it effectively in Siebel.
Coming back to the problem in Hand. Below is the Source XML that was being generated in Siebel
Source (Obtained from Siebel using EAI Siebel Adapter – Query method)
<?xml version="1.0" encoding="UTF-8"?><
SiebelMessage MessageId="1-18J35" IntObjectName="Test Contact IO" MessageType="Integration Object" IntObjectFormat="Siebel Hierarchical">
<ContactInstance Id="1-1RUYIF" Language="ENU">
<Field Value="Unleashed" Datatype="String" Name="ContactLastName"></Field>
<Field Value="Test Company" Datatype="String" Name="InstallAddress1"></Field>
<Field Value="Test Street 3001" Datatype="String" Name="InstallAddress2"></Field>
<Field Value="TestCity" Datatype="String" Name="InstallCity"></Field>
<Field Value="CL" Datatype="String" Name="InstallState"></Field>
<Field Value="000000" Datatype="String" Name="InstallZipcode"></Field>
<Field Value="Siebel" Datatype="String" Name="ContactFirstName"></Field>
<MVFieldGroup Name="ContactDetails">
<Row>
<MVField Value="TestValue1" Datatype="String" Name="TestDetail1"></MVField>
<MVField Value="TestValue2" Datatype="String" Name="TestDetail2"></MVField>
</Row>
</MVFieldGroup></ContactInstance></SiebelMessage>
I have simplified the source XML to avoid complication the actual XML had complex hierarchical structures going upto 3 levels but the problem statement remained same.
Problem:
Every Field and MVField Tag should be replaced with value of “Name” attribute and the value of the Tag should be value of “Value” attribute. I know it’s confusing. Here is what the Final XML should look like after transformation.
Target Transformation:
<?xml version="1.0" encoding="UTF-8"?>
<SiebelMessage MessageId="1-18J35" IntObjectName="Test Contact IO" MessageType="Integration Object" IntObjectFormat="Siebel Hierarchical">
<ContactInstance Id="1-1RUYIF" Language="ENU">
<ContactLastName>Unleashed</ContactLastName>
<InstallAddress1>Test Company</InstallAddress1>
<InstallAddress2>Test Street 3001</InstallAddress2>
<InstallCity>TestCity</InstallCity>
<InstallState>CL</InstallState>
<InstallZipcode>000000</InstallZipcode>
<ContactFirstName>Siebel</ContactFirstName>
<MVFieldGroup Name="ContactDetails">
<Row>
<TestDetail1>TestValue1</TestDetail1>
<TestDetail2>TestValue2</TestDetail2>
</Row>
</MVFieldGroup>
</ContactInstance>
</SiebelMessage>
You would need to write complex scripting solution in order to achieve the same but below is the XSLT that I used to accomplish the same
XSLT Transformation rule:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Field">
<xsl:element name="{@Name}">
<xsl:value-of select="@Value"/>
</xsl:element>
</xsl:template>
<xsl:template match="MVField">
<xsl:element name="{@Name}">
<xsl:value-of select="@Value"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
The final solution was to :
- Put the XSLT transformation rule in a file
- Call EAI Siebel Adapter – Query Method
- Write the output to a File on the same location as XSLT Transformation rule file
- Call EAI XSLT Service – Transform method and provide both file name and locations as input argument
- Get the Transformed XML as output.
I will write a followup post to explain the XSLT rules used in the example above. You comments and Feedback is welcome as always.

(4 votes, average: 4.75 out of 5)


