on 12-14-2005 3:31 PM
Hi,
I need to add the namespace to a IDOC. It seens to, that XI doesn't add the namespace for IDOC.
To do that I implement a java mapping like this :
public void execute(InputStream in, OutputStream out)
throws StreamTransformationException {
Document source = null; // Source message
String sourceString = null; // Source XML message as a string
// Create out of the InputStream the Source XML document
try {
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
source = factory.newDocumentBuilder().parse(in);
// Add namespace to document
Element root = source.getDocumentElement();
String messageNamespace = null;
messageNamespace = (String)param.get(StreamTransformationConstants.INTERFACE_NAMESPACE);
root.setAttribute("xmlns",messageNamespace);
......
During runtime the result of this mapping ist the following :
<?xml version="1.0" encoding="utf-8"?>
<ORDERS05 xmlns="urn:sap-com:document:sap:idoc:messages">
<IDOC xmlns="" BEGIN="1">
<......
Why the mappingruntime add the xmlns="" in the IDOC tag ?
Any hints ?
Regards,
Gerald
Hi Gerald,
Here's a guess:
You are successfully changing the namespace only of the root node (ORDERS05) so the XML API inserts the empty namespace declaration on the first subordinate node to indicate that it is still in the default namespace. If this is the case, you would probably need to iterate over your entire document to change the namespace everywhere. I'm not too familiar with the DOM API, so there may be another way to accomplish this....
Best regards,
Thorsten
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gerald,
Indeed the IDOC message type does not have a namespace and you have to make sure, that the namespace is deleted, when the messages comes fromBizTalk.
Before you work with dom parser, you have to keep in mind, that the performance is bad for big messages > 1 MB So make sure, that the IDOC is always small.
The easiest way to apply a namspace is just parsing the XML as string and watch for <b><ORDERS05></b> and <b></ORDERS05></b>. Replace the tags with the namespaced tags.
If you want to use the DOM parser, add a namespace prefix to the tag with the namespace. Or expects BizTalk each tag belonging to the namespace?
Regards
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Gerald,
We'd the same problem here. Actually R3 didn't put a namespace inside the IDOC XML format. I opened a message some months ago. Here the answer from SAP:
+"...XML namespaces are a part of the XML syntax as attributes and elements.
Some XML documents will use them and others not. (The same as some XML
documents will contain attributes and others not). When XML namespaces
are used the syntax is with these xmlns- resp. xmlns:
In this case unfortunately there exists no BAdI or a user exit. So the
only way I see is a modification of the standard.
Within Include "LEDI7F04" there is a paragraph
Idoctyp immer
CLEAR OUT_STRING.
IF EDIDC-IDOCTP CA '_'. " enthält mind. ein _
CONCATENATE START_CONTROL_IDOCTYP CDATA_START_TAG EDIDC-IDOCTP
CDATA_END_TAG END_CONTROL_IDOCTYP
INTO OUT_STRING.
ELSE.
CONCATENATE START_CONTROL_IDOCTYP EDIDC-IDOCTP END_CONTROL_IDOCTYP
INTO OUT_STRING.
ENDIF.
This builds the "" for your scenario.
As the coding is different for Unicode and Non-Unicode, you have to
make such a coding modification for the Unicode case within Include
"LEDI7F05" in the following paragraph:
idoctyp immer
concatenate i_string start_control_idoctyp edidc-idoctp
end_control_idoctyp into i_string.
[within form "control_record_xml"]
As there is a BAdI for the Unicode case, I recommend to use the BAdI
instead of a modification.
Hope that this information could help you!!
Regards,
Gustavo Kauffman
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gerald,
Is there any specefic need for changing the idoc namespace?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.