on 08-13-2006 3:12 PM
Hi
I have cr8ed rfc lookup in UDF,and I want to parse this xml and use only the value I need
I read in the forum that there are 2 ways of doing it :
DOM and SAX
any1 knows good weblogs/threads which ellaborates on how or explain how it should b done ?
thx,Shai
HI,
For Mapping Lookups~
/people/alessandro.guarneri/blog/2006/03/27/sap-xi-lookup-api-the-killer
/people/sravya.talanki2/blog/2005/12/21/use-this-crazy-piece-for-any-rfc-mapping-lookups
Hope this helps,
Moorthy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thx Abhy for your detailed answer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Shai,
you don't have to do it in another UDF.
You can use some parsing method in the same one.
If you want to use DOM, you'll also have to choose a parser, since DOM's specification doesn't specify a parser, just document and element handlers, so there are various implementations of parsers for DOM. I've used Xerces's DOMParser (org.apache.xerces.parsers.DOMParser) on Java Mappings with success (never tried on UDF, though) and it's very simple.
After you get the output stream from the rfc lookup, just use:
DOMParser parser = new DOMParser();
InputSource input = new InputSource(in);
parser.parse(input);
Document MyDoc = parser.getDocument();
to get the Document object. Then you can use regular DOM methods to get the value.
For example, with
String value = MyDoc.getDocumentElement().getFirstChild().getNodeValue();
you'd get the value of the first child of the root element.
Regards,
Henrique.
Hi Shai,
This blog and article deals with calling your RFC from your JAVA MAPPING / User Defined Function.
/people/sravya.talanki2/blog/2005/12/21/use-this-crazy-piece-for-any-rfc-mapping-lookups
And now going to the next half of your question regarding SAX and DOM parsers....
The user defined functions that you write in your Graphical Mapping has nothing to do with Java Mapping.
In your Graphical Mapping, the parsing of source structure is handled interannly by XI.
But, when you go for an explicit mapping technique like Java Mapping, you have to parse the source XML structure, so that you can write the logic for your mapping.
Java Mapping will execute a method called Execute, that will take the source XML structure as the Input Stream and then, you have to parse the Input STream and to do this parsing, you use SAX or DOM parser.
DOM processor loads the entire XML into the memory and is processor intenseive, SAX does it element by element and so is not processor intensive.
If you are using SAX parser, there are 5 methods . They are:
1) Start of the document(startDocument)
2) start of the element(startElement)
3) end of the element(endElement)
4) end of the document(endDocument)
5) chars()
Also check with any java site about SAX events how it works etc.
Java Mapping
http://help.sap.com/saphelp_nw04/helpdata/en/e2/e13fcd80fe47768df001a558ed10b6/content.htm
DOM parser API
http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/package-frame.html
On how to create XML docs with SAX and DOM go thruugh these links:
http://www.cafeconleche.org/books/xmljava/chapters/ch09.html
http://www.cafeconleche.org/books/xmljava/chapters/ch06.html
Also go through these Blogs....
/people/prasad.ulagappan2/blog/2005/06/08/sax-parser
/people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-i
/people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-ii
/people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-iii
I hope this helps...
Regards,
Abhy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.