XML concepts/pre-requisites of XSLT mapping in SAP PI
First let’s take a look at basic concepts:
1. what is XML-
It is Extensible mark-up language. It is platform independent data format as well as manufacturer independent data format.
It has easy to read structured information, and there is separation of information and semantics.
Moreover it has metalanguage for defining description languages.
XML defines set of rules for encoding documents in a format which is both human readable and machine readable.
2. What is XSL-
It is language for expressing style sheets. Extensible stylesheet language.
It is a file that describes how to display an XML document of given type.
This style sheet describes how a document (XML/HTML) should look like on the screen/print.
Without this, there is no meaning to data in XML.
3. What is XSL-FO-
It is another language for formatting XML data, and focuses on styles that work on both screen and print such as PDF.
This formatting allows you to create files that look fantastic on any screen or print neatly.
There is no difference in XSL and XSL-FO.
www consortium (WC3) expanded on XSL theories to create XSL- FO.
4. What is XSLT-
It is XSL transformation. It is part of XSL language for XSLT processes.
XSLT defines order/frequency of processing of XML source document.
It has templates having processing instructions.
It also has various features like variable declaration, repeat instructions, conditional checks etc.
It is language for addressing specific parts of an XML document.
It models XML document as tree of nodes.
XPath expression is mechanism for navigating through and selecting nodes from XML documents.
So to conclude the relationship between above components is, we use XML language for transfer of data because of its advantages mentioned above, and XSL document is a reference, using which XSLT does transformation and produces final document.
Ex. Just like we execute mapping in SAP PI, we take input payload (say XML), take data type as reference (say XSL), and we produce output using mapping transformation (say XSLT).
We can separate content and output format using XML.
We can create numerous output documents using single source document by performing transformations.
Following are examples of applications for XML:
Following is basic syntax 1 for XML:
XML can also be viewed as tree structure.
Job of XSLT is to transform data from XML file into another format like html/xhtml. Data is sent as xhtml (format after XSLTransformation), and web browser modifies it into the required data to display (html).
SAP Business Connector:
XML in SAP PI:
1. Must have XML declaration.
2. Root element should be defined.
3. All elements have start and end tag.
4. All attribute values are in inverted commas.
5. Element groups are correctly nested
Validation of XML:
1. All points mentioned above.
2. It must contain DTD/Schema.
3. Rules of DTD/Schema are compiled.
DTD is document type definition. Under DTD, main categories comprising XML document are declared. Ex. elements, their attributes, ordering, nesting of elements etc.
XML schema have namespace and their own DTD. It is more powerful than DTD. It can have most basic program till expanded complex programs.
CSS is designed around styling a document, structured in markup language (XML/HTML).
They are cascading style sheets used to style XML markup.
To conclude, these three are data type definitions. To transfer data, we use these structures, in which XML data is passed.
Advantages of Schema over CSS:
1. It is in XML syntax.
2. Sequence of source data can be changed.
3. Elements can be repeated any number of times in output.
4. Additional information can be included in output document.
DTD vs Schema:
Has element nesting
Simple and complex data types
attribute types and standard values
Restrictions on number and order of child elements.
Special data types for elements and attributes
Entity definition for abbreviations
No restriction on length and type of character strings
The most common thing heard in SAP PI in this subject regards is XSLT mapping.
Different ways of achieving conversion in XI is:
- 1. Message Mapping (Graphical Mapping using Mapping Editor in XI).
- 2. Java Mapping.
- 3. ABAP Mapping.
- XSLT Mapping.
Steps required for developing XSLT Mapping
- Create a source data type and a target data type
- Create Message types for the source and target data types.
- Create Message Interfaces includes Inbound Message interface and Outbound Message interface.
- XSLT Mapping does not require creation of Message mapping, so don’t create any Message mapping.
- Create an .XSL file which converts source data type into target data type.
- Zip that .xsl file and import it into Integration Repository under Imported Archives.
- In Interface Mapping choose mapping program as XSL and specify this zip program. (Through search help you will get XSL Mapping programs that you imported under Imported Archives, select your corresponding XSL Program)
- Test this mapping program by navigating to Test tab.
Image courtesy: SAP e-learning hub(introduction to XML).