cancel
Showing results for 
Search instead for 
Did you mean: 

Add and Remove DOCTYPE from cXML

Former Member
0 Kudos

Hi,

I'm currently using Message mapping from cXML to idoc and vice versa. I need a remove the DOCTYPE declaration on the inbound cXML and add DOCTYPE for outbound. I understand, it is possible to have a JAVA mapping or XSLT to resolve this problem, since i'm not expert in Java. Can someone send me a Java code which could help me resolve this issue. Any ideas or help is greatly appreciated.

Thanks!.

Accepted Solutions (1)

Accepted Solutions (1)

udo_martens
Active Contributor
0 Kudos

Hi Ganesh,

i think most easy would be ABAP:

Do not parse the message, just call a fm to convert to string:

DATA:
* xml message
    l_message TYPE string.

*create a string to search (and replace) in it
  CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING'
    EXPORTING
      im_xstring  = source
      im_encoding = 'UTF-8'
    IMPORTING
      ex_string   = l_message.

Then use the right string operation for example REPLACE:

REPLACE FIRST OCCURRENCES OF
    '<!DOCTYPE...'
  IN
    l_message
  WITH
    ''.

Finally switch back to XString:

* create a XString: Ready, no use of DOM!
  CALL FUNCTION 'ECATT_CONV_STRING_TO_XSTRING'
    EXPORTING
      im_string   = l_message
      im_encoding = 'UTF-8'
    IMPORTING
      ex_xstring  = result.

Regards,

Udo

Former Member
0 Kudos

Hi Udo.

Thanks for the info. However it does not solve my problem. I'm using standard message mapping on invbound and outbound transformation. I tried to write a JAVA or XSL mapping and use it interface mapping before the actual transformation but im facing issues since im not a java expert Please advise how can i use the ABAP mapping you have provided in this scenario

Thanks!

udo_martens
Active Contributor
0 Kudos

Hi Ganesh,

>However it does not solve my problem

I think it does. Just add this abap mapping to your interface mapping. It has only one task: Change the payload (delete or add the DTD reference) WITHOUT parsing (because much easier).

Please have a look to sap.help for allowing ABAP mappings at all: (2 important points: set that referred exchange profile parameter and create a ABAP class implementing the interface IF_MAPPING): [Mapping Development with the ABAP Workbench|http://help.sap.com/saphelp_nw2004s/helpdata/en/10/5abb2d9df242f6a62e22e027a6c382/frameset.htm]

Regards,

Udo

Former Member
0 Kudos

Thanks Udo! your suggestion was the easiet , but i was forced to use java mapping to remove the DOCTYPE and XSL to add doctype, however i got the issue resolved.

In our XI, ABAP mapping is not enabled and i have jump hoops to get that enabled by basis. since i dont have necessary authorization to get it done.

Thanks for all your help.

Former Member
0 Kudos

Hi Ganesh,

I had similar issue to generate the tag doctype to the output xml file, can you tell me how you resolved using xslt mapping.

My Scenario is JDBC to XML, in the XML output file doctype tag is to be included.

Thanks for your help.

Srinivas

Former Member
0 Kudos

Hi Ganesh,

I am trying to resolve the same problem, but so far not successful. Please see my question in the thread

Can you please explain , how you resolved it?

Regards,

Subhendu

Answers (0)