× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



You need to either use CDATA tags or escape the ampersand.

<CCCURR><![CDATA[CAD&]]></CCCURR>

Or

<CCCURR>CAD&amp;</CCCURR>

Check out the following link for reference to the "XML spec":
http://www.w3.org/TR/REC-xml/#syntax

HTH,
Aaron Bartell
http://mowyourlawn.com


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of ANN GERLING
Sent: Thursday, July 05, 2007 10:39 AM
To: RPG400-L@xxxxxxxxxxxx
Subject: XML creation of iSeries UDB data - Characters that are not allowed.

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 &amp; 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>
--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.