cancel
Showing results for 
Search instead for 
Did you mean: 

JAVA mapping

Former Member
181

Hi,

I have a situation for which I require a Java mapping program to be written. The XML document I need to convert can be quite large. Having read the documentation I was hoping to use a SAX parser for this? Does anyone here have any experience of using SAX to perform the transformation? At what point would you not use DOM for transforming the XML?

Regards

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

Hi Ian,

As far as I know when you use the XI API (com.sap.aii.mapping.api, etc...) for Java mapping, you are implicitly using the internal XML parser used by XI. i.e. SAX.

However, if you choose to write your own custom Java mapping classes, then you are free to define which XML parser you want to employ.

Regarding when to use which parser; I always use the following rule of thumb:

If your XML implementation requires to navigate the XML document back and forward and performs extensive searching/matching routines, then I go for DOM. Simply because it is more flexible for this kind of operations and allows you to keep data in memory and if necessary replace/update data in your XML source.

SAX works differently, actually it does not keep your XML tree data in memory. Because of this difference SAX is much more efficient and faster than DOM, but you are not able to freely navigate your XML structure or change the XML source as is in DOM. Of course there are workarounds that allows you to perform this things in SAX, however the API is not written for this purpose.

Cheers,

Roberto.

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Roberto,

Thank you for your time. Points awarded

Former Member
0 Kudos

Hi Roberto,

Many thanks for your reply. Could you please explain what you mean by 'or change the XML source as is in DOM' as I understand I need to implement a method to parse the XML document and output another stream with the output. Have I mis-understood something here?

Former Member
0 Kudos

> Hi Roberto,

>

> Many thanks for your reply. Could you please explain

> what you mean by 'or change the XML source as is in

> DOM' as I understand I need to implement a method to

> parse the XML document and output another stream with

> the output. Have I mis-understood something here?

Ian,

With <i>'or change the XML source as is in DOM' </i>

I mean changing the XML structure i.e. adding removing elements, attributes etc.. from your XML input document.

In your case this is not the situation, so you can use SAX without have to worry about this limitation.

Cheers, Roberto

PS: Ian have also a look of this article; http://developerlife.com/saxvsdom/default.htm

Message was edited by: Roberto Viana

Former Member
0 Kudos

Hi Roberto,

So have you used SAX to transform the XML message within XI? The reason I am asking is that I am at the analysis stage and do not want to find a problem later on in the implementation. I am hoping to use SAX to allow me to re-locate the closing tags within my XML to make mapping to an IDOC easier. Does this sound feasible?

Regards

Ian

Former Member
0 Kudos

Ian,

Without knowing the exact details of your design, I think you can use SAX (having in mind what I said in my earlier post) in combination with maybe some StringBuffers to store your XML tags... We have use this mix in some projects and it works fine.

Cheers,

Roberto