on 11-13-2007 7:38 PM
Hello,
I'd like to ask you if and how it is possible to use XPath expressions in Java Mapping. There is a way with Xalan but SAP is using their own XML parser...
Many Thanks,
Milan
In Java mapping, you have to explicitely parse the XML.
If you want to use XALAN (for Java 1.4, pay attention to that), you can use the .jar in the mapping development and then include it as an imported archive in Integration Repository.
Regards,
Henrique.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Bhavesh,
I'd like to create a mapping XML file where will be the mapping described. So for example take the value of elemnt A, put it in element B in reasult message. The incommig message will be parsed by SAX of course, because of the memory, but this mapping XML I'd like to parse in DOM way and I also would like to use XPath for finding stuff.
Nice isn't it?
Milan
actually he can't use XPath with Java 1.4 DOM and SAX based parsers.
For example, suppose you want to get the value of field <value> of XML below:
<xml>
<data>
<field>F001</field>
<value>123</value>
</data>
</xml>
In DOM parser, after parsing, you do something like:
...
Node xml = doc.getDocumentElement();
xml.normalize();
String value = xml.getFirstChild().getChildNodes().item(1).getNodeValue();
With XALAM, you do something like:
doc.getNoveValue("xmldatavalue");
They work pretty differently.
Regards,
Henrique.
Henrique,
Thanks for that explanation. I now see the difference.. Pooh, looks likes there is some reading for me to do over the weekend.
Regards
Bhavesh
PS : Btw, did you check out the number of articles that have come out on 7.1 over the course of this week? You now know what my weekend plans are Have a good day!
Hi Henrique,
actually I can: please check this out: http://www.exampledepot.com/egs/org.w3c.dom/xpath_GetAbsElem.html
And it will be very easy for me to create needed xpath expression during mapping which I need. I also think about looking for elements by tag name somethink like this:
NodeList list = doc.getElementsByTagName("TagName") limitation are that I cannot have the same name for incomming elements because then it will returm all of them and I will have to do more logic there.
With XPath it will be more easy because you have more control where to look for element.
User | Count |
---|---|
80 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.