on 2005 May 18 11:47 AM
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Roberto,
Thank you for your time. Points awarded
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
> 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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
63 | |
10 | |
7 | |
7 | |
6 | |
6 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.