Sunday, June 26, 2011

How to Enrich Existing XML Using XSL in SOA 11g

Many times you have a requirement to enrich existing xml objects in a BPEL. I have seen developers using assign activity for that. Assign activity is appropriate if you are adding few mappings. It will be little bit difficult to use assign activity if
  • You need to map optional elements. Assign will fail at runtime if the element is not present in the payload. To prevent selection failure you need to add a Switch activity to check for element existence.
  • You need to add/append/update a collection of xml elements. It requires a While activity to iterate the collection.

  • You need to add mappings for multiple elements.
If you try to do it using Assign your BPEL will be flooded with Switch, Assign and While activities. Your BPEL process become unmanageable its will increase the development time as well. Generally people think the following about XSL transformations:
  • XSL transformations are very complex to write.

  • They may loose some elements if they use XSL.
So they go with Assign activity and bear all the pains I have mentioned earlier. You can pass multiple source XML objects to an XSL map in SOA 11g. See this post to learn how to pass multiple XML objects to the XSL map. Enriching existing XML using XSL maps is easy in SOA 11g, You just need to follow the steps given below:

1. Add a Transform activity and select the same xml variable as source and target.

2. Add additional variables as source. These variables will be passed as parameters to XSL transformation. See the image given below:

3. Click on Apply and it will open the XSLT map.

4. Map at least one element from each of the additional variables to the target variable. When you add mappings for additional variables, XSL designer defined parameters for additional variables in the XSL. If you want to define parameters manually you can ignore this step.

5. Go to XSL source view and remove the default template and mappings added by the map designer. You can keep XPath expressions in a separate text editor window.

6.Copy the following template in the XSL file:

<xsl:template match="@*|node()">
<xsl:apply-templates select="@*|node()"/>

This map copies all the elements from source to the target XML. As you are enriching the existing XML, this template will make sure that you don’t loose any xml element.

7. Now it’s the time for customization. You need to add one template per XML element you want to customize. See the following sample template:

sample:Line xmlns:sample="">
select="@* | *"/>
<!-- ADD you custom mappings here. You can also add new elements here-->

Please note that if you add a template for an XML element it will be applied to that element and its children. You can add new elements, change element values in the XSL templates. Make changes to the above XSL template as per you requirement. Add proper namespace prefixes and declarations.

8. Once done with the XSL, test it in JDeveloper to make sure that it is working fine.

9. Deploy your composite on SOA 11g server and test it.


Amit sirswa said...

hotel management colleges in jaipur,
best hotel management colleges in jaipur
hotel management courses
college of hospitality administration jaipur,
cha hotel management jaipur

Thank you sir And keep it up More Post And Its A Awesome Web page sir Thank You So Much ,

Amit sirswa said...

HOme Automations system
IP CAmera in jaipur at Rajasthan
Home security system in jaipur
Wireless Home Security System in jaipur
Realtime attendance machine in jaipur
cctv camera dealer in jaipur
Boom Barriers system in jaipur at Rajasthan
security system solutions in jaipur

its really great information Thank you sir And keep it up More Post

Nagendra Reddy said...

Yes sir I have the requirement to enrich existing xml objects in a BPEL and I am using assign activity for this thank for exposing different cases and guide to how to deal with this.
The Lucidtechsystems providing quality online and Classroom Oracle SOA suite development training and Oracle SOA suite 12c administration training in hyderabad,India.

payal jhanwar said...

A Pioneer Institute owned by industry professionals to impart vibrant, innovative and global education in the field of Hospitality to bridge the gap of 40 lakh job vacancies in the Hospitality sector. The Institute is contributing to the creation of knowledge and offer quality program to equip students with skills to face the global market concerted effort by dedicated faculties, providing best learning environment in fulfilling the ambition to become a Leading Institute in India.

cha jaipur
management college in jaipur
management of hospitality administration jaipur
cha management jaipurs
Hotel management in jaipur
Best hotel college in jaipur
Best management college in jaipur
College of Hospitality Administration, Jaipur
Top 10 hotel management in jaipur
Hotel managementin Rajasthan

Dharmesh Mittal said...

Makeup is an avenue for self expression and its possibilities are endless
Celebrity Makeup Artist in jaipur
Top 10 beauty parlor in rajasthan
Fiza Makeup and Hair Artist.
Wedding Makeup Artist in jaipur.
Professional Makeup Artist in jaipur
Bridal Makeup Artist in jaipur
Fiza Makeup Academy.
Top 10 beautyparlor in jaipur
Creative Makeup Artist in jaipur
Bollywood Makeup Artist in jaipur
Character Makeup Artist in jaipur
Fiza Makeup Academy Rajasthan
Top 10 beauty parlor in india
Hair and Makeup Artist in jaipur