Skip to Content

Including DOCTYPE tag in the outgoing PI message

Hi ,

Our project includes an IDoc to file (xml) scenario where we are using a dtd (data type definition) as the external definition for the messages to be sent to a remote system.

We have used a graphical mapping step and as a result PI created the output xml file in the below format.

<?xml version="1.0" encoding="UTF-8" ?> 
<root>
...message
</root>

However, the customer wants us to include the DOCTYPE tag along with output xml file.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE batch SYSTEM "xyz.dtd">
<root>
...message
</root>

Is there a way of adding this DOCTYPE information to the output xml?

Thanks & Regards,

Himanshu

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Oct 17, 2008 at 09:57 AM

    Hi,

    One way is java mapping.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 17, 2008 at 09:58 AM

    Can be done by using xslt mapping......

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 17, 2008 at 10:12 AM

    Same type of example has been given in this blog...

    https://blogs.sap.com/?p=40977

    Regards,

    Sarvesh

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 03, 2008 at 06:46 AM

    Hi,

    I have solved the problem by using java javax.xml.transform APIs.

    TransformerFactory tfactory = TransformerFactory.newInstance();
    		Transformer transformer = tfactory.newTransformer();
    		  
    			transformer.setOutputProperty(
    					OutputKeys.DOCTYPE_PUBLIC,
    					doctype_public);
    			
    			transformer.setOutputProperty(
    					OutputKeys.DOCTYPE_SYSTEM,
    					doctype_system);
    
    		
    		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();;
    		DocumentBuilder builder = factory.newDocumentBuilder();
    		Document dom = builder.parse(payload.getInputStream());	
    		DOMSource source = new DOMSource(dom);
    		ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
    		StreamResult result = new StreamResult(byteOut);
    		
    		transformer.transform(source, result);

    I have done this inside an adaptor module but the same can be done inside Java mapping program as well.

    Main reason for prefering Adapter module was having the flexibility to pass parameters (e.g. reference dtd name) which is not possible as of PI 7.0.

    Regards,

    Himanshu

    Edited by: Himanshu Bahuguna on Nov 3, 2008 7:46 AM

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Himanshu,

      Good work....Here i am facing the same problem but in my case i am getting XML message with doctype included in it which i am passing to PI for mapping. Since the dtd is on client's system, mapping generates an error about the conflict of the xml structure because it can't recognize Doctype.

      Here my question is can we write java code for excluding doctype node from xml and pass it to PI?

      Regards

      Sumit