write-xml for temp-table with illegal (for xml) characters in field names

EdInTheUK

New Member
Hello,

If a temp-table has % in the field name then WRITE-XML fails.

TEMP-TABLE myTable:WRITE-XML("file", "C:\Temp\MyTable.xml").

Are there any workarounds? The initial definition for the temp-table comes from a pre-existing database table:

DEFINE TEMP-TABLE myTable NO-UNDO LIKE existing-db-table-name.

I could define the temp-table longhand, and just rename the offending fields... but that would be a cumbersome solution, esp as dealing with lots of different tables that will themselves grow, slowly, over time.

Thanks,

Ed
 

EdInTheUK

New Member
Hi Cringer,

Unfortunately these database tables are long established and any change to field names would cause lots more work elsewhere. I was hoping for a less disruptive way :)

Ed
 

Cringer

ProgressTalk.com Moderator
Staff member
Fair enough... although maybe it should be a project for the future :)
 

Stefan

Well-Known Member
You can use XML-NODE-NAME to adjust the offending fields:

Code:
DEFINE TEMP-TABLE tt FIELD cc AS CHAR.


CREATE tt. tt.cc = "boo" .


DEF VAR hb AS HANDLE NO-UNDO.
DEF VAR ii AS INT NO-UNDO.
DEF VAR lcc AS LONGCHAR NO-UNDO.




hb = TEMP-TABLE tt:DEFAULT-BUFFER-HANDLE.


DO  ii = 1 TO hb:NUM-FIELDS:


   hb:BUFFER-FIELD(ii):XML-NODE-NAME = "dd".


END.


hb:WRITE-XML( "longchar", lcc, TRUE ).


MESSAGE STRING( lcc ) VIEW-AS ALERT-BOX.
 
Top