Namespace missing in java mapping DOM ?
Hi,
I am creating java mapping using DOM, but why i cannot create a namespace using this code ?
Document targetDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Node docRoot = targetDoc.appendChild(targetDoc.createElementNS("urn:sap-com:atp:ABC40:base", "ns1:Vendor_SQL"));
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
// create source and result wrappers and perform transformation
DOMSource source = new DOMSource(targetDoc);
StreamResult result = new StreamResult(outputStream);
transformer.transform(source, result);
expected result in xml :
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Vendor_SQL xmlns:ns0="urn:sap-com:atp:ABC40:base">
</ns0:Vendor_SQL>
result :
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Vendor_SQL>
</ns0:Vendor_SQL>
Please advise whether i was missing any other required step ?
Note : testing using NWDS 7.0 SP 17
Thank You and Best Regards
Fernand
Hi Lesmana,
Can you change the second line in the code like below and give a try::
Node docRoot = targetDoc.appendChild(targetDoc.createElementNS("ns1:urn:sap-com:atp:ABC40:base", "ns1:Vendor_SQL"));
Regards,
---Saish
Similar Messages
-
Hi Guys,
Can i test my JAVA Mapping (DOM).
I create all coding as per the requirment . Is it a way that in the NWDS in can give input XML Document and test there in Eclipse before am using it in the XI Mapping.
How to pass "InputStream in" XML document and read the output.
Am bit new to JAVA programing.
If there is anyu way plz do provide me an idea , that help me in debigging well my JAVA Programing
regards
Srinivashi venkateshwarulu
check the below blogs
XI Java Mapping Helper (DOM)
The specified item was not found.
Think objects when creating Java mappings
Think objects when creating Java mappings
Testing and Debugging Java Mapping
Testing and Debugging Java Mapping in Developer Studio
reward pionts if helpfull
regards
kummari
Edited by: kummari on Jul 9, 2008 7:28 AM
Edited by: kummari on Jul 9, 2008 7:51 AM -
Java mapping of application triggered an exception
Hi,
We have ascenario where a vendor will be sending us a cXML file which has the second line as <!DOCTYPE cXML SYSTEM "http://xml.cxml.org/schemas/cXML/1.2.009/InvoiceDetail.dtd">. If I open it in XMLSpy, it is saying the file as invalid. XI is unable to map this file. So we decided to remove that line using Java mapping and then do the regular graphical mapping.
I took the java code from the SAP note 812966 and used the aii_map_api.jar, dom.jar, jaxp-api.jar to create the class of that java file and used that class file by importing that into XI as a jar file.
I'm getting this error in the request message mapping of SXMB_MONI
<SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">
<SAP:Category>Application</SAP:Category>
<SAP:Code area="MAPPING">STREAM_TRANSFORMATION_EX</SAP:Code>
<SAP:P1>mypackage/DeleteDTDDeclarationWithDOM</SAP:P1>
<SAP:P2>Failed to load resource from the context classloa~</SAP:P2>
<SAP:P3 />
<SAP:P4 />
<SAP:AdditionalText />
<SAP:ApplicationFaultMessage namespace="" />
<SAP:Stack>Java mapping of application triggered an exception</SAP:Stack>
<SAP:Retry>M</SAP:Retry>
</SAP:Error>
I'm new to this java mapping, Can you please provide me some details about what files need to be loaded into the XI along with the class file.
Appreciate you help.
Thanks,
MT.Hi Prateek,
Thanks for your quick reply. Yes I have downloaded the aii_map_api.jar from <SAP_install_dir>/<system_name>/<instance_name>/j2ee/cluster/server<number>/apps/sap.com/com.sap.xi.services/
And also I have compiled my java code using the dom.jar, sax.jar, jaxp-api.jar and aii_map_api.jar.
I took the class file of my javacode and all the class files of the above mentioned jar files and prepared one single jar file, which I imported into XI.
It is not allowing me to make a single jar of the actual class file and all the supporting jar files.
What is the actual method of doing it.
Appreciate all your help. Thanks very much.
Thanks,
Maulik. -
Java mapping how to use com.sap.tc.logging
Hi I would like to know how to use logging within a java mapping.
I know i have to use theese classes : Location, Category, ConsoleLog but i dont know how.
1) How to load the P1, P2, P3 and P4 tags in the Error tag of the SOAP header watched in SXMB_MONI
- <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">
<SAP:Category>Application</SAP:Category>
<SAP:Code area="MAPPING">STREAM_TRANSFORMATION_EX</SAP:Code>
<SAP:P1>SwissMedical/Interfaces/IFI002/LiquidacionMapping~</SAP:P1>
<SAP:P2 />
<SAP:P3 />
<SAP:P4 />
<SAP:AdditionalText />
<SAP:ApplicationFaultMessage namespace="" />
<SAP:Stack>Java mapping of application triggered an exception</SAP:Stack>
<SAP:Retry>M</SAP:Retry>
</SAP:Error>
2) How to load and activate log in the DIAGNOSTIC tag of the SOAP Header.
- <SAP:Diagnostic xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="1">
<SAP:TraceLevel>Information</SAP:TraceLevel>
<SAP:Logging>Off</SAP:Logging>
</SAP:Diagnostic>
Thanks!!As already suggested, you can display custom messages using AbstractTrace.
trace = (AbstractTrace)param.get( StreamTransformationConstants.MAPPING_TRACE );
trace.addInfo("G1-CYCLE is missing");
For more on coding front refer:
http://help.sap.com/javadocs/NW04/current/pi/com/sap/aii/mapping/api/StreamTransformation.html
To get this trace seen in MONI, set parameter TRACE_LEVEL in SXMB_ADM to 2. -
Context change by DOM parsing Java Mapping in XI
Hi Team,
I would like to know that how can I handle Context Change by DOM Parser Java Mapping in XI.?
Suppose the source XML structure I have like below:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Header xmlns:ns0="urn:bp:xi:hr:edm:test:100">
<FileName>
<filesub>
<subname>a</subname>
<subname>b</subname>
<subname>c</subname>
</filesub>
</FileName>
<FileName>
<filesub>
<subname>d</subname>
<subname>e</subname>
<subname>f</subname>
</filesub>
</FileName>
</ns0:Header>
Where the field FileName can occur maximum thrice(0...3) but the subname field is (0....unbounded) but in the target source I would like to have as given below:
<?xml version="1.0" encoding="UTF-8" ?>
- <MT_Test4 xmlns="urn:bp:xi:hr:edm:test:100">
- <Header>
<FileName>a</FileName>
<FileName1>d</FileName1>
</Header>
- <Header>
<FileName>b</FileName>
<FileName1>e</FileName1>
</Header>
Header>
<FileName>c</FileName>
<FileName1>f</FileName1>
</Header>
</MT_Test4>
That means the first value from every context of the source field is forming my first and second value in my target first context.Thensecond value from every context is forming my 1st and 2nd value of my target 2nd context and finally 3rd value of every context is forming my 1st and 2nd value of my target 3rd context.Is this possible to done through DOM parsing or we have to do it by UDF only?Hi Atanu,
In my last post I gave an alogorithm to solve the mapping problem. Here is the complete program for the mapping.
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.sap.aii.mapping.api.StreamTransformation;
import com.sap.aii.mapping.api.StreamTransformationException;
public class DOMParser1 implements StreamTransformation{
public void execute(InputStream in, OutputStream out)
throws StreamTransformationException {
try
DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
DocumentBuilder builderel=factory.newDocumentBuilder();
/input document in form of XML/
Document docIn=builderel.parse(in);
/document after parsing/
Document docOut=builderel.newDocument();
TransformerFactory tf=TransformerFactory.newInstance();
Transformer transform=tf.newTransformer();
Element root,child,child1=null;
Node textChild;
NodeList l;
int i,n1,j,div,k;
String s[];
root=docOut.createElement("MT_Test4");
root.setAttribute("xmlns","urn:bp:xi:hr:edm:test:100");
l=docIn.getElementsByTagName("subname");
n1=l.getLength();
s=new String[n1];
for(i=0;i<n1;++i)
s<i>=l.item(i).getFirstChild().getNodeValue();
l=docIn.getElementsByTagName("filesub");
div=l.getLength();
j=n1/div;
for(i=0,k=0;i<j;++i)
child1=docOut.createElement("Header");
root.appendChild(child1);
child=docOut.createElement("FileName");
textChild=docOut.createTextNode(s[k]);
child.appendChild(textChild);
child1.appendChild(child);
child=docOut.createElement("FileName1");
textChild=docOut.createTextNode(s [ k + j ]);
child.appendChild(textChild);
child1.appendChild(child);
++k;
docOut.appendChild(root);
transform.transform(new DOMSource(docOut), new StreamResult(out));
catch(Exception e)
e.printStackTrace();
public void setParameter(Map arg0) {
public static void main(String[] args) {
try{
DOMParser1 genFormat=new DOMParser1();
FileInputStream in=new FileInputStream("C:/Apps/my dw/sdnq/apps.xml");
FileOutputStream out=new FileOutputStream("C:/Apps/my dw/sdnq/tgt1.xml");
genFormat.execute(in,out);
catch(Exception e)
e.printStackTrace();
source -> apps.xml
<?xml version="1.0" encoding="UTF-8" ?>
- <ns0:Header xmlns:ns0="urn:bp:xi:hr:edm:test:100">
- <FileName>
- <filesub>
<subname>a</subname>
<subname>b</subname>
<subname>c</subname>
</filesub>
</FileName>
- <FileName>
- <filesub>
<subname>d</subname>
<subname>e</subname>
<subname>f</subname>
</filesub>
</FileName>
</ns0:Header>
target structure -> tgt1.xml
<?xml version="1.0" encoding="UTF-8" ?>
- <MT_Test4 xmlns="urn:bp:xi:hr:edm:test:100">
- <Header>
<FileName>a</FileName>
<FileName1>d</FileName1>
</Header>
- <Header>
<FileName>b</FileName>
<FileName1>e</FileName1>
</Header>
- <Header>
<FileName>c</FileName>
<FileName1>f</FileName1>
</Header>
</MT_Test4>
Hope this helps
one more thing in this line "textChild=docOut.createTextNode(s k + j );" somehow the the third braces one opening before k and one closing after j is missing for unknown reasons. Please correct it when you actually run this code.
regards
Anupam
Edited by: anupamsap on Mar 7, 2011 12:47 PM -
Java mapping & namespace issue
Hello,
I am doing a java mapping from a flat file to an IDOC. After the document is mapped succesfully I call an RFC via the Adapter. When monitoring the adapter I get the error:
com.sap.aii.af.rfc.RfcAdapterException: failed to read funtionname from XML document: missing namespace declara
so I added the namespace reference to my java mapping to look like this :
<ns0:IDOC_INBOUND_ASYNCHRONOUS xmlns:ns0="urn:sap-com:document:sap:rfc:functions">
But when I test my java mapping in the builder (interface mapping) the namespace xmlns="urn:sap-com:document:sap:rfc:functions" is added to my above ns0:IDOC_INBOUND_ASYNCHRONOUS tag. The consequence is that while mapping in the integration engine the "ns0" prefix is then removed and I get the error:
Delivery of the message to the application using connection AFW failed, due to: error while processing message to remote system:com.sap.aii.af.rfc.core.client.RfcClientException: functiontemplate from repository was.
Any help or sample code resolving the namespace issue is welcome.
FrankHi Frank,
I am getting the same error message. You fixed yours. Can you help me with mine. The error message is
" Delivery of the message to the application using connection AFW failed, due to: error while processing message to remote system:com.sap.aii.af.rfc.core.client.RfcClientException: functiontemplate from repository was ."
I am trying to send data to SAP SRM4.0 from SAP R/3 using SAP XI. XI content is delivered by SAP.
The message is sent from R/3 to XI successfully and the XML monitor does not show any errors in XI . But the messages does not show up in SRM.
Thanks
Kishore. -
Hi All,
I need Java mapping help. I will get incomming payload as following
<orders>
<matnr>123</matnr>
<qty>10</qty>
</orders>
i need to change the above payload as follows
<ns0:orders>
<ns0:matnr>123</ns0:matnr>
<ns0:qty>10</ns0:qty>
</ns0:orders>
Please help me how to achieve this using Java mapping.
Regards
VijayHi,
Dom will be quite expensive for this type of requirement since you will have to go to each element and then append the namespace.
I suggest you use SAX parser which is more efficient for such requirement.
The code is given below you can modify it according to your requirement.
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
public class SAXDemo extends DefaultHandler{
public StringBuffer sb = new StringBuffer();
public String PREFIX = "ns0:";
int count = 1;
public static void main(String[] args)
SAXDemo demo= new SAXDemo();
demo.saxdemo();
System.out.println();
public void saxdemo()
InputStream in;
try
in = new FileInputStream(new File("Input.xml"));
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
factory.setValidating(false);
SAXParser saxParser = factory.newSAXParser();
* Parse the content of the given {@link java.io.InputStream}
* instance as XML using the specified
* {@link org.xml.sax.helpers.DefaultHandler}.
* @param inputstream InputStream containing the content to be parsed.
* @param cobject The SAX DefaultHandler to use.
* @exception IOException If any IO errors occur.
* @exception IllegalArgumentException If the given InputStream is null.
* @exception SAXException If the underlying parser throws a
* SAXException while parsing.
saxParser.parse(in, this);
System.out.println(sb.toString());
catch (FactoryConfigurationError e)
e.printStackTrace();
catch (ParserConfigurationException e)
e.printStackTrace();
catch (SAXException e)
e.printStackTrace();
catch (IOException e)
e.printStackTrace();
public void startDocument()throws SAXException
public void endDocument()throws SAXException
public void startElement(String namespaceURI, String name, String qName, Attributes attrs)
throws SAXException
if(count == 1)
sb.append("<"+PREFIX+qName+" "+PREFIX+"xmlns="+namespaceURI+">");
else
sb.append("<"+name+">");
count ++;
public void endElement(String uri, String name, String qName) throws SAXException
sb.append("</"+qName+">");
public void characters(char buf[], int offset, int len)
throws SAXException
String s = new String(buf, offset, len);
buf = null;
sb.append(s.trim());
s = null;
Regards
Fariha -
Missing method in XI java mapping
I am developing a java mapping in XI and experiencing a strange problem.
The java code I am writing works fine with oracle Jdeveloper, but when I copy it to the XI java editor - I recieve an error message indicating that the method I am using (getTextContent of the Element class) is missing.
the Jdeveloper and XI are using the same jre (1.5.0_06).
what could be the problem?what version of pi system?
if using pi 7.0 ,you should use the jdk 1.4 complie your java class.
in jdk 1.4 get the text should use the following method :
element.getFirstChild.getNodeValue();
the method getTextContent is avaiable since jdk1.5
Regards zhang peng -
Java Mapping Using DOM Parser.
Hi Experts,
I am new to Java mapping and i have followed the link
http://scn.sap.com/thread/3173071 and it is working fine. It is for only one item. I have tried to modify the code and i placed a for loop to go create the Output Node based on the No of Input Nodes and it is giving the error as below. But my requirement is
Input.xml : -
<?xml version="1.0" encoding="UTF-8" ?>
<ns0:DT_Source xmlns:ns0="urn:java_mapping2">
<Person1>
<Name>Alex</Name>
<Surname>Stewart</Surname>
</Person1>
<Person1>
<Name>Sam</Name>
<Surname>Abdreson</Surname>
</Person1>
</ns0:DT_Source>
Output.xml:-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<ns0:DT_Target xmlns:ns0="urn:java_mapping2">
<Person2>
<EmpName>
<Emp>Alex Stewart</Emp>
</EmpName>
</Person2>
<Person2>
<EmpName>
<Emp>Sam Abdreson</Emp>
</EmpName>
</Person2>
</ns0:DT_Target>
I am unable to get the output. I am getting the following error.
org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted.
at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.insertBefore()
at com.sun.org.apache.xerces.internal.dom.NodeImpl.appendChild()
Please suggest me how i can resolvoe this error.
Regards,
GIRIDHARComplete code
package test;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;
import java.io.IOException;
import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
public class RemoveTag extends AbstractTransformation {
public void execute(InputStream in,OutputStream out) throws StreamTransformationException, SAXException, IOException {
try
DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
DocumentBuilder builderel=factory.newDocumentBuilder();
/*input document in form of XML*/
Document docIn=builderel.parse(in);
/*document after parsing*/
Document docOut=builderel.newDocument();
TransformerFactory tf=TransformerFactory.newInstance();
Transformer transform=tf.newTransformer();
Element root,child,child1,child2;
Node textChild;
Node name,surname;
String fullname="";
root=docOut.createElement("ns0:DT_Target");
root.setAttribute("xmlns:ns0","urn:java_mapping2");
NodeList nList = docIn.getElementsByTagName("Person1");
for (int temp = 0; temp < nList.getLength(); temp++)
child1=docOut.createElement("Person2");
child=docOut.createElement("EmpName");
child2=docOut.createElement("Emp");
child.appendChild(child2);
child1.appendChild(child);
root.appendChild(child1);
name=docIn.getElementsByTagName("Name").item(temp);
surname=docIn.getElementsByTagName("Surname").item(temp);
fullname=name.getFirstChild().getNodeValue()+" ";
fullname+=surname.getFirstChild().getNodeValue();
textChild=docOut.createTextNode(fullname);
child2.appendChild(textChild);
docOut.appendChild(root);
transform.transform(new DOMSource(docOut), new StreamResult(out));
catch(Exception e)
e.printStackTrace();
public static void main(String[] args) {
try{
RemoveTag genFormat=new RemoveTag();
FileInputStream in=new FileInputStream("C:\\Users\\Desktop\\aa.xml");
FileOutputStream out=new FileOutputStream("C:\\Users\\Desktop\\output1.xml");
genFormat.execute(in,out);
catch(Exception e)
e.printStackTrace();
@Override
public void transform(TransformationInput arg0, TransformationOutput arg1)
throws StreamTransformationException {
// TODO Auto-generated method stub
try {
this.execute(arg0.getInputPayload().getInputStream(), arg1.getOutputPayload().getOutputStream());
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace(); -
JAVA Mapping: Convert a W3C DOM into OutputStream
hi everybody,
how do I convert a org.w3c.dom.Document into outputStream as needed in JAVA mapping?
Thanks regards
MarioHi Mario,
even if you already found the solution, I think the information may be useful to others.
You could do something like:
import org.w3c.dom.Document;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
Document doc;
try {
TransformerFactory tf = TransformerFactory.newInstance();
Transformer trans = tf.newTransformer();
trans.transform(new DOMSource(doc), new StreamResult(out));
} catch (TransformerConfigurationException e) {
// Implement exception handling
} catch (TransformerException e) {
// Implement exception handling
Regards,
Henrique. -
Java Mapping to override namespace prefix (startPrefixMapping)
Does anyone have an example of using a Java Map to override the default XI namespace prefix. The method startPrefixMapping looks like it might do the job but I can't find any example of how this works.
You can use the Anonymizer Module Processor.
In your adapter, go to the "Modules" tab, than insert a new entry <b>before</b> the default adapter module processor. Enter module name <b>localejbs/AF_Modules/XMLAnonymizerBean</b> and <b>Local Enterprise Bean</b> type. In the parameters tab, enter parameter <b>anonymizer.acceptNamespaces</b> and parameter value <b>'<namespace>' <prefix></b>. You can enter more than one namespace, like in <b>'<namespace1>' <prefix1> '<namespace2>' <prefix2></b>.
Note that your namespace must be inside apostrophes by default. If instead you want to use quotes to define the namespace, you must use another parameter before the one above: parameter name <b>anonymizer.quote</b> and in the value enter a single quote <b>"</b>.
To define an empty prefix (meaning, that namespace is the default namespace) use '' (two apostrophes) instead of <prefix> (or "" (two quotes), if you have used anonymizer.quote).
Check SAP Note 880173 for more information.
Regards,
Henrique. -
In Java Mapping Whether to SAX or DOM ?
While implementing Java Mapping which of the following SAX , DOM parsers is the most efficient way to implement it.
I mean considering the voulume of data in the XML format is large which usage will give me most optimal performance .
It would be nice if someone could give a sample most optimal java code using JAXP where input stream is read and after processing written to output stream.
regards
Nilesh Taunk.Hi Nilesh,
>>>While implementing Java Mapping which of the following SAX , DOM parsers is the most efficient way to implement it.
there's no one good answer fot this question
except: it depends:)
SAX and DOM are a little different parsers
so it depends what will your java mapping
have to do: if it will change the
structure or maybe it will only change a few tags,
or maybe it will do something else
have a look at the page below to read a simple
comparision between SAX and DOM
http://www.scit.wlv.ac.uk/~jphb/cp2101/week4/XML_Parsing.html
or this thread:
http://www.biglist.com/lists/xsl-list/archives/200301/msg01318.html
they will give you some idea which one to choose
depending on your requirements
BTW
remember use java mappings only
if you cannot use graphical mapping (very easy debugging)
and if your document cannot be parsed (maybe huge documents)
with XSLT which is supported by many graphilal tools
Regards,
michal
<a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions">XI FAQ - Frequently Asked Questions</a> -
How to replace namespace tag with new value using -JAVA MAPPING
Hi Guys,
I need to replace namespace Tag in Target xml with a new value.
For Eg: My namespace Tag is - <ns0:TestHeader xmlns:ns0="http://0020.TestHeader.SS.com">
I want My target xml to have value- <ns0:TestHeader>
How can i achieve it using JAVA mapping?
Can you provide me the code to do so.Sarjana,
Not well-formed XML is only possible by Java Mapping. Please use below replace logic in Java map.
inputContent.replaceAll("<ns0:TestHeader xmlns:ns0=\"http://0020.TestHeader.SS.com\">", "<ns0:TestHeader>");
Link1, Link2. -
Java Mapping, XSLT Mapping, ABAP Mapping
Hi Experts,
Could any one explain what is the main features of the following Mapping. How to pick the mapping?
Java Mapping - When to use and what is the advantage.
ABAP Mapping - When to use and what is the advantage.
XSLT Mapping - When to use and what is the advantage.
Graphical Mapping - When to use and what is the advantage.
cheers,
SuneeThere are 4 types of mapping in XI
1. Graphical Mapping
2. XSLT Mapping
3. JAVA Mapping
4. ABAP Mapping
When to use Message mapping
1 When the logic for your mapping is simple and straight forward, you can use
Advantages of message mapping
1)Easy to use.
2) has GUI drag and drop.
3) used for simple mapping cases
4) it does not involve any complex logic
Disadvantages of message mapping
1)has limitation in terms of complex hierarchy
When to use Java mapping
1) Java mapping are used when graphical mapping cannot help you.
Advantages of Java Mapping
1)you can use Java APIs and Classes in it.
2) file look up or a DB lookup is possible
3) DOM is easier to use with lots of classes to help you create nodes and elements.
Disadvantages of Java mapping
1)SAX parser is not easy to develop
2)DOM parser is intensive
3) Java knowledge is required
4) bit complexer
XSLT Mapping - When to use
1)When the required output is other than XML like Text, Html or XHTML (html displayed as XML )
2)When default namespace coming from graphical mapping is not required or is to be changed as per requirements.
3)When data is to be filtered based on certain fields (considering File as source)
4)When data is to be sorted based on certain field (considering File as source)
5)When data is to be grouped based on certain field (considering File as source)
Advantages of using XSLT mapping
1)XSLT program itself defines its own target structure.
2)XSLT programs can be imported into SAP XI. Message mapping step can be avoided. One can directly go for interface mapping once message interfaces are created and mapping is imported.
3)XSLT provides use of number of standard XPath functions that can replaces graphical mapping involving user defined java functions easily.
4)File content conversion at receiver side can be avoided in case of text or html output.
5)Multiple occurrences of node within tree (source XML) can be handled easily.
6)XSLT can be used in combination with graphical mapping.
7)Multi-mapping is also possible using xslt.
8)XSLT can be used with ABAP and JAVA Extensions
Disadvantages of using XSLT mapping
1)Resultant XML payload can not be viewed in SXMB_MONI if not in XML format (for service packs < SP14).
2)Interface mapping testing does not show proper error description. So errors in XSLT programs are difficult to trace in XI but can be easily identified outside XI using browser.
3)XSLT mapping requires more memory than mapping classes generated in Java.
4)XSLT program become lengthier as source structure fields grows in numbers.
5)XSLT program sometimes become complex to meet desired functionality.
6)Some XSL functions are dependent on version of browser.
Advantages of Abap Mapping
1) A person comfortable with OOABAP can go for ABAP mapping instead.
Disadvantages of Abap Mapping
1) Abap knowledge is required
2) bit compexer
For further info on each of the mapping, refer to these links,
Graphical Mapping,
http://help.sap.com/saphelp_nw04/helpdata/en/6d/aadd3e6ecb1f39e10000000a114084/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm
XSLT Mapping
http://help.sap.com/saphelp_nw04/helpdata/en/73/f61eea1741453eb8f794e150067930/content.htm
http://www.w3.org/TR/xslt20/
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
Check this blog on Mapping:
/people/ravikumar.allampallam/blog/2005/02/10/different-types-of-mapping-in-xi
Also, check this thread for more info,
Different types of Mapping in XI -
Hi All,
After faceing so much of problem, i found that it would be better if i can go for an XSLT/java mapping:
1. It is adding an extra <b>ns0</b> to header line & end line which i dont want to be generated in the output xml file.
2. Namespace problem that basically sticking to 60 but i want 72 characters in my target xml file.
3. No carriage return at the end of each line which is not geting generated through graphical mapping.
Now i have an XSD provided by the client. So how can i use that and which mapping should best suits to solve all these problem.
Should i go for a java mapping or an XSLT/JAVA mapping.
I dont have any idea on both of them, So can you people send me the details for it.
Many Thanks & Best Regards,
JGD.Hi,
Based on the requirement and size we can choose the mapping.
If java is suitable to our requirement then we go for java.
If XSLT is suitable to our requirement then we go for XSLT.
Performance wise(high --> low) :
If data is less then
Graphical mapping -
> Java(sax parser)mapping -
> Java(dom parser)mapping -
> XSLT mapping -
> ABAP mapping.
If data is high then
XSLT mapping -
> Java(sax parser)mapping -
> Graphical mapping(internally it uses SAX)----> Java(dom parser)mapping -
> ABAP mapping.
If you choose XSLT then you can select Altova Map Force tool then no need to write the XSLT code here, it will automatically generates the code.
N:1 XSLT Mapping
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/30ac53f2-21d7-2a10-afa2-ce1a0577ca18
XSLT mapping https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/006aa890-0201-0010-1eb1-afc5cbae3f15
Maybe you are looking for
-
something changed on my computer after i accidentally hit some key. when i receive e-mails now with photos the images appear in the message but no thumbnails nor way to download. these same messages are fine on the iPad and iPhone. so, it is my co
-
How do i install missing fonts into my trial?
Hi I have three fonts that I want to use in my company formats that are missing in my trial indesign download. They are Arial MT Pro Light, ITC Franklin Gothic and ITC Franklin Gothic Demi. How do I get these? Can I do it within the trial or do I nee
-
HT201303 Trying to put credit card details in put it keeps telling me that my session has timed out
Have an existing apple account and now have bought new iPad Trying to buy new apps on existing account so it asks me to verify payment details which I do straight away. However then it says that the session has timed out. Trying repeatedly but same p
-
HT1657 If you rent the wrong movie and don't download it can you receive your credit back?
I have purchased 2 iTunes movies to watch on a trip and have decided against 1 movie which has not even started to download. Can this be cancelled?
-
Tuning the performance of ObjectInputStream.readObject()
I'm using JWorks, which roughly corresponds to jdk1.1.8, on my client (VxWorks) and jdk1.4.2 on the server side (Windows, Tomcat). I'm serializing a big vector and compressing it using GZipOutputStream on the server side and doing the reverse on the