on 10-17-2008 10:53 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can be done by using xslt mapping......
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
One way is java mapping.
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 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.