Using Your Own XSLT in the XSLT Mediation
September 13, 2007 3 Comments
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.