cancel
Showing results for 
Search instead for 
Did you mean: 

Including DOCTYPE tag in the outgoing PI message

HimanshuB
Associate
Associate
0 Kudos

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

Accepted Solutions (0)

Answers (4)

Answers (4)

HimanshuB
Associate
Associate
0 Kudos

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

sbhutani1
Contributor
0 Kudos

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

Former Member
0 Kudos

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

Regards,

Sarvesh

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi,

One way is java mapping.

Former Member
0 Kudos

You could do it very easily using XSLT.. of course you could edit the DTD as well using xml spy or something... I personally would use XSLT mapping as the last mapping step of your interface mapping.

HimanshuB
Associate
Associate
0 Kudos

Hi Arman,

Could you please explain how would editing the DTD help ?

Thanks & Regards,

Himanshu