| Mapping is the way of transforming one XML | | | | document from beginning to end. Those events |
| structure to another XML Structure. As a part of | | | | are passed to event handlers, which provide |
| it we do certain operations like breaking child | | | | access to the contents of the document. |
| nodes and attaching them to its parent node and | | | | Event Handlers |
| more in an XML structure. | | | | There are three types of event handlers: DTD |
| In XI/PI we have the following mapping | | | | Handlers, for accessing the contents of XML |
| techniques | | | | Document-Type Definitions; Error Handlers, for |
| 1. Graphical Mapping | | | | low-level access to parsing errors; and, by far the |
| 2. ABAP Mapping | | | | most often used, Document Handlers, for |
| 3. JAVA Mapping and | | | | accessing the contents of the document. A SAX |
| 4. XSLT Mapping. | | | | processor will pass the following events to a |
| Among all the above mapping techniques, JAVA | | | | Document Handler: |
| mappings improve the performance and are | | | | - The start of the document. |
| preferred as they get executed on J2EE engine | | | | - A processing instruction element. |
| directly. But in case of graphical mapping, XI/PI | | | | - A comment element. |
| converts the mapping program into executable | | | | - The beginning of an element, including that |
| Java code internally based on graphical design and | | | | element’s attributes. |
| executes it on J2EE engine making it | | | | - The text contained within an element. |
| comparatively less efficiency. Java mappings are | | | | - The end of an element. |
| more useful when performance of integration | | | | - The end of the document. |
| server is concerned during runtime. Java mappings | | | | Advantages and Disadvantages SAX |
| are Parsing Programs that can be developed in | | | | Advantages: |
| NWDS (NetWeaver Developer Studio), import as | | | | DOM |
| .jar files and can be used in the mapping part of | | | | Advantages: |
| Integration Repository. NWDS provides suitable | | | | 1. It is good when random access to widely |
| Java environment and higher level tools to parse | | | | separated parts of a document is required. |
| XML documents through the Simple API for XML | | | | 2. It supports both read and write operations. |
| (SAX) and the Document Object Model (DOM) | | | | > |
| interfaces. The SAX and DOM parsers are | | | | Disadvantage: |
| standards that are implemented in several | | | | It is memory inefficient because DOM consumes |
| different languages. In the Java programming | | | | more memory to construct the XML tree Object |
| language, you can instantiate the parsers by using | | | | in the memory corresponding to the input XML its |
| the Java API for XML Parsing (JAXP). | | | | not advisable to use for parsing large XML |
| JAVA mapping can be done in two ways: | | | | documents In that case SAX is preferred over |
| 1. DOM Parsing | | | | DOM. |
| 2. SAX Parsing | | | | 1. It is simple to program. |
| At the core of the DOM API are the Document | | | | 2. It is memory efficient as SAX parser does not |
| and Node interfaces. A Document is a top-level | | | | keep any of the document tree in memory. |
| object that represents an XML document. The | | | | Disadvantage: |
| Document holds the data as a tree of Nodes, | | | | The data is broken into pieces and clients never |
| where a Node is a base type that can be an | | | | have all the information as a whole unless they |
| element, an attribute, or some other type of | | | | create their own data structure. |
| content. The Document also acts as a factory for | | | | Differences between SAX and DOM parser at a |
| new Nodes. Nodes represent a single piece of | | | | glance |
| data in the tree, and provide all of the popular | | | | SAX |
| tree operations. You can query nodes for their | | | | 1. Parses node by node |
| parent, their siblings, or their children. You can also | | | | 2. Doesn’t store the XML in memory |
| modify the document by adding or removing | | | | 3. We cant insert or delete a node |
| Nodes. | | | | 4. Top to bottom traversing |
| SAX PARSING TECHNIQUE | | | | DOM |
| SAX (Simple API for XML) is an event-driven | | | | 1. Stores the entire XML document into memory |
| model for processing XML. The SAX model is | | | | before processing |
| quite different. Rather than building a complete | | | | 2. Occupies more memory |
| representation of the document, a SAX parser | | | | 3. We can insert or delete nodes4. Traverse in |
| fires off a series of events as it reads the | | | | any direction. |