matigro
16th July 2010, 21:14
hi, great people!

I'm having a big problem with reading XMl files.
My first language is spanish and for our clientes too, so in an xml you could read accents or another characters that they are from extended ascii (á, é, í, etc)

This is an example, the file si formatd as PC (CR/LF) and PlainText:

<?xml version="1.0" encoding="iso-8859-1"?>
<lote:lote_comprobantes_response xmlns:lote="http://lote.schemas.cfe.ib.com.ar/">
<lote:lote_response>
<lote:estado>Aquí hay acento</lote:estado>
</lote:lote_response>
</lote:lote_comprobantes_response>

So, in script I've got this:
|Open file for reading
fd = seq.open(i.file.c, "rt")

|Open XML file
cmfId = xmlRead(fd, error.string)
ret = seq.close(fd)

And session, bw.exe and everything tilt (I don`t know how to explain that I have to kill via taskmanager all Baan in my client becs)

Well, my quasi-solution is change every character that is not in english ascii for a similar one. ie: á to a, é to e and so on.

But is not working for al cases. Sometimes cannot replace and it breaks.



for "every character in XML":
char.asc.c = asc(i.record(i;1))
if (char.asc.c >= 32 | standard ascii characters
and char.asc.c <= 126) then
new.record(i; 1) = i.record(i;1)
else
new.record(i; 1) = replace.non.ascii.char(i.record(i;1))
endif
endfor

function domain tcmcs.str1 replace.non.ascii.char(domain tcmcs.str1 i.char)
{
domain tcmcs.str30 chars.from.c, chars.to.c
domain tcmcs.long posno


chars.from.c = "áéíóúñÁÉÍÓÚÑàèìòùÀÈÌÒÙçÇ"
chars.to.c = "aeiounAEIOUNaeiouAEIOUcC"

posno = pos(chars.from.c, i.char)
if posno = 0 then
return("#")
|return(i.char)
endif
return(chars.to.c(posno; 1))
}

I've seen too little questions about this problem in baanboard, one is Problem using Baan XML-functions (http://www.baanboard.com/baanboard/showthread.php?t=26749) but solution is changing file format out of baan scripts, and in my case, that is not an option.

Can everybody give me a hint?

Thanks in advance.

Matias

Marnix Klooster
17th July 2010, 10:07
That other thread you mention says (in this post (http://www.baanboard.com/baanboard/showthread.php?t=26749#post96827)) that "the parser has a bug when it comes to ISO-8859-1 encoding and special characters. [...] The moral of the story: Convert your XML files to Unicode before import!"

I agree that this is a bug. But my moral would be different: report this bug to Infor Support, after having tested with the latest available BaanIV Porting Set to see whether it has perhaps been fixed already. Thanks!

matigro
19th July 2010, 15:57
Hi Marnix Klooster, thanks for your response.
That post was on 30th March 2006 and I thought that this bug was fixed, 4 years! I thought wrong :(

I will check in Infor Support and check latest available BaanIV Porting Set too.

Thanks again.