|
Blogs
This blog will show you the basics of XI, XSLT and the Graphical mapping tool. This should give the XI beginner a very basic idea of how to use the SLD, Repository, namespaces, data types and mappings. If you are like me you are probably just itching to get your hands dirty. So first up let's assume you have a XI userid - note that probably at first logon you will need to first logon to XI via SAPGUI to reset the password. You'll also need Java version 1.4+ and Java webstart installed on your PC - get this from Sun website http://java.sun.com/products/javawebstart/download.jsp Then you can use the webinterface http://<yourXIserver>:50000/rep/start/index.jsp or fire it up via SAP GUI XI transaction SXMB_IFR.
SLDI will not be explaining the SLD in this blog, suffice to say that we just need some place to place the work we are going to do. Assuming that your userid has the rights to add or even view components in the SLD you'll need to go to the SLD Software Catalog. It is not usual for this to be locked out for developers and if so then you'll probably need to ask Basis to do this. That will teach them for being so restrictive!.
Click on Product and Select New Product Then it will prompt for Software Unit Component - so type that in.
And now add the Software Component - this will be the one imported into the Integration Builder.
Integration BuilderStart the Integration Builder from the XI webpage menu. Add the Software Component you just created to the list
Notice that it is empty to start with. You need to add a namespace to it. This allows you to group all your stuff under the namespace. I prefer to use urn: rather than http: for my namespaces.
Quick XML guideOK now we have set up a place for us to create something. What we will do is create a very simple XSLT conversion. An XML about Coffee will be converted by a XSLT into another XML.
That is very easy to do if you have a reasonable idea of how XSLT works. It will help you, even using the XI Graphic mapping, to understand the concepts - tree navigation, nodes, context etc. I would recommend you go and buy XSLT for Dummies or one of the many teach yourself XSLT sites and study further on this subject see http://www.w3schools.com/Xsl/default.asp If you don't have one then get an XSLT editor. E.g. Download this free tool - http://xmlcooktop.com/ You can use Cooktop to quickly check any XSLT you prepare before diving into XI. Here is some XML and XSLT for you to try - these are from the XSLT for Dummies book by Richard Wagner The Source XML <?xml version="1.0"?> <coffees> <region name="Latin America"> <coffee name="Guatemalan Express" origin="Guatemala"> <taste>Mild and Bland</taste> <price>11.99</price> <availability>Year-round</availability> <bestwith>Breakfast</bestwith> </coffee> <coffee name="Costa Rican Deacon" origin="Costa Rica"> <taste>Exotic and Untamed</taste> <price>12.99</price> <availability>Year-round</availability> <bestwith>Dessert</bestwith> </coffee> </region> <region name="Africa"> <coffee name="Ethiopian Sunset Supremo" origin="Ethiopia"> <taste>Exotic and Untamed</taste> <price>14.99</price> <availability>Limited</availability> <bestwith>Chocolate</bestwith> </coffee> <coffee name="Kenyan Elephantismo" origin="Kenya"> <taste>Solid yet Understated</taste> <price>3.99</price> <availability>Year-round</availability> <bestwith>Elephant Ears</bestwith> </coffee> </region> </coffees>
And it's assoiciated DTD <!ELEMENT availability ( #PCDATA ) > <!ELEMENT bestwith ( #PCDATA ) > <!ELEMENT coffee ( taste, price, availability, bestwith ) > <!ATTLIST coffee name CDATA #REQUIRED > <!ATTLIST coffee origin CDATA #REQUIRED > <!ELEMENT coffees ( region+ ) > <!ELEMENT price ( #PCDATA ) > <!ELEMENT region ( coffee+ ) > <!ATTLIST region name CDATA #REQUIRED > <!ELEMENT taste ( #PCDATA ) >
The XSL <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <coffeemerge> <xsl:apply-templates/> </coffeemerge> </xsl:template> <!-- Merge elements to create tagline element --> <xsl:template match="coffee"> <coffee> <tagline>This Coffee Is <xsl:value-of select="taste"/> And Best Enjoyed With <xsl:value-of select="bestwith"/></tagline> <taste><xsl:value-of select="taste"/></taste> <price><xsl:value-of select="price"/></price> <availability><xsl:value-of select="availability"/></availability> <bestwith><xsl:value-of select="taste"/></bestwith> </coffee> </xsl:template> </xsl:stylesheet>
And an associated DTD to describe the resulting XML. Tip : If you don't have one but you have the XML you can use a convertor. You can use a online tool to import and create a DTD http://www.hitsw.com/xml_utilites/ <!ELEMENT coffeemerge ( coffee+ ) > <!ELEMENT availability ( #PCDATA ) > <!ELEMENT bestwith ( #PCDATA ) > <!ELEMENT coffee ( tagline, taste, price, availability, bestwith ) > <!ELEMENT price ( #PCDATA ) > <!ELEMENT tagline ( #PCDATA ) > <!ELEMENT taste ( #PCDATA ) >
XSL ArchiveOK got a handle on XML ? Good now let's do it in XI.
First Zip up the XSLs or ones that you might have created during your visit and learning in the world of XSLT. Import them into XI - as can only import these via a zip file.
Within the Integration Builder Designer - go to your Software Component Version and namespace you created before. Expand it and expand Mapping Objects. Right Click on Imported Archives. Create a new Imported Archive to hold all our XSL for this exercise Import the zipped files
Save it. Then on the left hand navigation pane it will appear.
External DefinitionCreate an external definition to hold the DTD for the Source XML file. With that created select the DTD category and in the Messages choose the First Element. Import the DTD file and Save it.
Create another External Definition for the Target XML file. Remember to choose Category DTD and Messages from First Element
Message InterfaceNow we'll need to describe the message interfaces for both the Source and Target files.
Again within your SWC Interface Objects, right click on Message Interface - create a new one for the source file. This is the source's outbound interface - so the category is Outbound. Choose the corresponding DTD.
We create another for the Target file. This is the target's inbound interface - so the category is Inbound. Choose the corresponding DTD. Leave the fault message type empty.
Interface MappingCreate a interface mapping for the Source to the Target via the XSL. In the left hand navigation pane, Open the Mapping Objects, right click on Interface Mappings and create. You can drag and drop or select the Source Interface And for the Target Interface Now choose the mapping program as XSL using the one you imported from the zip file you previously set up.
Select the Test Tab and click the xmlbutton to import the source XML file (via the XMLimport icon Press the Test button
So that is a very simple example that introduces some of the concepts of XSLT and XI - you may like to now try some more. In my next blog I'll show you how to do this via the Graphical Mapping tool. Peter Munt is a SAP Netweaver Consultant (XI/EP/ABAP/JAVA) for Supply Chain Consulting Australia Add to: del.icio.us | Digg | Reddit
| |||||||||||||||||||||