Wednesday, March 16, 2016

Special Characters in XML for BI Publisher/XMLP



Have you already encountered the following error when generating XMLP report?

Caught exception: Error generating report output: (235,2309) PSXP_RPTDEFNMANAGER.ReportDefn.OnExecute Name:ProcessReport 

One of the reason why you are encountering this error is that there is a special character in the XML generated by your program that is being used by the BI Publisher.

Since PeopleSoft system currently supports only the UTF-8 for XML which does not accept special characters, here's a trick that you can use when generating the XML for XMLP/BI Publisher.

One encoding type for XML that accepts special character is  ISO-8859-1. Unfortunately, even if you set this as your encoding type, PS will still change it by default to UTF-8. If you are building your XML via peoplecode (CreateXML), the header of the XML will be just <?xml version="1.0"?> even if you put encoding type there.

The question now is how do you make the XML's encoding type to ISO-8859-1 so that it will accept the special characters and to avoid the error mentioned above?

What you can do is use the function GenFormatterXMLString() and replace manually the header from "<?xml version=""1.0""?>" TO "<?xml version=""1.0"" encoding=""ISO-8859-1""?>". Since your XML object has been converted into string, you can now use a string function to change the header of the XML. Once changed, you can now write that whole string (XML) to your file to generate the XML file. If you will open the file generated, it will now have the header <?xml version="1.0" encoding="ISO-8859-"?> which accepts special characters.

Sample: Local string &strXML = Substitute(&xmlDoc.GenFormattedXmlString(), "<?xml version=""1.0""?>", "<?xml version=""1.0"" encoding=""ISO-8859-1""?>"); &FILE.WriteString(&strXML); 




5 comments: