I am creating a process to archive data in iSeries database files to XML in an
IFS file.

Some of the data in the iSeries UDB file has special characters in the text
data that cause the document to "not be well formed". For example the use of &
(ampersand) for and in names.

I have resarched writing out XML and am trying to write the data out in UNICODE
and I thought this would take care of the errors that it found unacceptable
characters.

I was wondering if anyone could see where I am going wrong. I have thought
about scanning and replacing the 5 known characters that cause this error. For
example replace & with & works. But I was hoping to convert the text to
UNICODE and that solve the problem. Thanks for any ideas.

Ann Gerling
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Here is my code for creating the file and writing to it on the IFS.
D Flag1 S 10U 0
D Flag2 S 10U 0
D ccsid S 10U 0 inz(819)
D txtcreatid S 10U 0 inz(1208)
D CRLF C x'0d25'
D Slash C x'61'
D LCarot C x'4C'
D RCarot C x'6E'
D Dash C x'60'

. (other code)

* To Create File
C Eval Flag1 = O_WRONLY + O_CREAT + O_CODEPAGE
C + O_TRUNC
* To write to the file
C Eval Flag2 = O_RDWR + O_TEXTDATA
*
C Eval Mode = S_IRUSR + S_IWUSR + S_IRGRP
C + S_IWGRP + S_IROTH + S_IWOTH
* Open file setting code page
c callp unlink(%Trimr(FILEWP))
c Eval fd = open(%Trimr(FILEWP):Flag1:Mode:ccsid
c :txtcreatid)
c callp close(fd)
*
* Open file to write data
c Eval fd = open(%Trimr(FILEWP): Flag2)

.(other code)


* Write out Start and End of Field Element
C If FieldValue <> *blanks
C EVAL RecOut = LCarot + %TrimR(WHFLDEX) + RCarot
C + %Trim(FieldValue)
C + LCarot + Slash + %TrimR(WHFLDEX)
C + RCarot + CRLF
C Else
C EVAL RecOut = LCarot + %TrimR(WHFLDEX) + ' '
C + Slash + RCarot + CRLF
C EndIf
*
C Eval RecLen = %len(%Trim(RecOut))
c callp write(fd:%addr(RecOut):
C RecLen)

Here is my test result file contents. It errors on the record (line 18) with
the ampersand:

<?xml version="1.0"?>
<!-- File = HPS02/TESTXML/P973 - Currency Conversion Table-->
<P973>
<R973>
<RowInfo>
<CCCURR>CA D</CCCURR>
<CCFRDT>20070705</CCFRDT>
<CCTODT>20070711</CCTODT>
<CCRATE>.870110</CCRATE>
</RowInfo>
<RowInfo>
<CCCURR>CAD</CCCURR>
<CCFRDT>20061214</CCFRDT>
<CCTODT>20061220</CCTODT>
<CCRATE>.870110</CCRATE>
</RowInfo>
<RowInfo>
<CCCURR>CAD&</CCCURR>
<CCFRDT>20061221</CCFRDT>
<CCTODT>20070103</CCTODT>
<CCRATE>.865230</CCRATE>
</RowInfo>
<RowInfo>
<CCCURR>CA/D</CCCURR>
<CCFRDT>20070705</CCFRDT>
<CCTODT>20070711</CCTODT>
<CCRATE>.870110</CCRATE>
</RowInfo>
</R973>
</P973>

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.