BI Publisher | Allowing Special Characters in BI Publisher data files.
A. Defining the Problem
Like much of the content on BareFoot PeopleSoft, this particular tip came about from an actual production issue. We had created a number of BI Publisher reports using an XML File as the data source. In the original ‘Dev’ environment, no special characters appeared in any of the name fields. However, once we moved the reports to Production, we realised that some of names had special characters, such as the Spanish characters á and ñ. By default, the XML file had not been coded to use a special character set, meaning that run-time errors were encountered when users attempted to generate reports based on that data.
Fortunately the fix was relatively straightforward. We just needed to modify the existing header line in the XML data file.
B. Solution
The following code will create a new XML file by replicating the original file. The first line of the new file includes a special character set (in this case, character set ISO 8859).
/* Create a second version of the file. */ /* Include encoding information for special characters. */ &file_path = "/tmp/data_file_old.xml"; &file_path2 = "/tmp/data_file_new.xml"; /* Open old file for reading and new file for writing */ &XMLFile = GetFile(&file_path, "r", "a", %FilePath_Absolute); &XMLFile2 = GetFile(&file_path2, "w", "a", %FilePath_Absolute); &first_line = True; While &XMLFile.ReadLine(&line_data) /* Specify the first line with the character set */ If &first_line Then &XMLFile2.WriteLine("<?xml version='1.0'" | " encoding='iso-8859-1'?>"); &first_line = False; Else &XMLFile2.WriteLine(&line_data); End-If; End-While; &XMLFile.Close(); &XMLFile2.Close();
Optionally, you may choose to delete one or both XML files after the process has completed. Refer to Tips 046 and 050 for more details on how to delete files.
See Also:
Tip 046: File Manipulation in PeopleCode
Tip 050: File Manipulation using Java Objects