Using Your Own XSLT in the XSLT Mediation

The XSLT mediation in WebSphere ESB allows you to map data from one message type to another. Normally you do this by creating an .xmx file – an internal format – via a graphical mapping tool in WebSphere Integration Developer, which is then built into an .xslt automatically. Sometimes, though, you might want to modify that generated .xslt to do something you can’t do with the graphical mapping tool, or because you’re familiar with XSLT and it’s easier for you that way (although it’s not recommended to make lots of changes manually in the XSLT). If you just edit the file, though, it can be overwritten with changes from your .xmx.

There is a more robust way:

  • Start out normally by creating an XSLT primitive, defining the mapping using the graphical mapper, and building your project to make sure the .xslt is generated. Take note of the filename of the .xslt file that’s generated.
  • Select Window / Views / Physical Resources. Take heed of the warning; you shouldn’t normally use this view for everyday tasks. Here, we will, though.
  • Locate the .xslt file that corresponds to your XSLT primitive in your mediation module. Right-click on the file and select ‘Copy’. Then right-click on the directory it is in and select ‘Paste’. This should create a copy of it. You might want to rename the copy so it has a more meaningful name.
  • Then edit the .xslt by double-clicking on it. At the top, you will see a line that starts <!– @generated xmxFile=. This associates the file with its original .xmx, and you need to remove it. You can also make any other modifications you want to make to the XSLT now (or at a later time).
  • Once you’ve done that, save the file and return to the Business Integration view. Locate the XSLT primitive, and in the Properties view, select the ‘Browse’ button. You should see the new .xslt file listed. Select that, and you’re done. Now the XSLT primitive should use your new copy of the XSLT, and it won’t be associated with an .xmx file.

Thanks to Ian for his help with this tip.


3 Responses to Using Your Own XSLT in the XSLT Mediation

  1. Sunil Dumpala says:

    Thanks for the tip. I understand that making changes manually to a xslt file is risky but WID gui for xslt primitive is very premature. It cannot handle even a medium complexity mapping (either that or I was not able to figure out or couldn’t find enough documentation and I even attended IBM’s ESB training) and hence I manually change xslts in almost all the cases. But until now I had to leave the file names as generated by WID and trust me they are not very pretty. This tip has helped me give them better names and also makes my code feel more robust especially when I have to defend my code in audit. Thanks Andrew and Ian.

  2. You may be interested in looking at the new WebSphere Integration Developer 6.1:

    It has some improvements to the XSLT editor which may address your concerns.

  3. Pingback: Understanding the Message Manipulation Primitives « SOA Tips ‘n’ Tricks

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: