Kbase P176911: READ-XML() and WRITE-XML() methods do not handle mapping of ABL INTEGER data type to xsd:time data t
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  11/11/2010 |
|
Status: Unverified
SYMPTOM(s):
READ-XML() and WRITE-XML() methods do not handle mapping of ABL INTEGER data type to xsd:time data type
WRITE-XML() fails to convert integer value to "HH:MM:SS" format required by XML standards
READ-XML() fails with one or more of the following errors:
Error reading XML file 'timewritten.xml'. (13035)
READ-XML encountered an error while parsing the XML Document: 'Datatype error: Type:SchemaDateTimeException, Message:Incomplete Time ! '47649' .'. (13064)
** Invalid character in numeric input :. (76)
Unable to convert XML to native data type for field 'timestamp' in table 'ttTimeTest'. (13052)
FACT(s) (Environment):
As documented, the default XML schema mappings do try to map ABL INTEGER to xsd:time
OpenEdge 10.1x
OpenEdge 10.2x
All Supported Operating Systems
CAUSE:
Bug# OE00201779
FIX:
Workaround:
Use a CHARACTER field mapped to an xsd:time type, convert the integer to character when writing the XML, and the character to integer when reading it.
Example code:
DEFINE TEMP-TABLE ttTimeTest NO-UNDO
FIELD timestamp AS INTEGER XML-NODE-TYPE "hidden".
FIELD timestampexport AS CHARACTER XML-DATA-TYPE "time" XML-NODE-NAME "timestamp"
.
/* Timestampexport is a shadow field. When writing the XML, we'll hide the real field and write that one out with the original name instead */
DEFINE VARIABLE hNewTT AS HANDLE NO-UNDO.
DEFINE VARIABLE iNum AS INTEGER NO-UNDO.
CREATE ttTimeTest.
ASSIGN ttTimeTest.timestamp = TIME.
/* writing everything */
TEMP-TABLE ttTimeTest:WRITE-XMLSCHEMA("FILE","timeroundtrip.xsd",YES).
/* populate the shadow field */
FOR EACH ttTimeTest:
ttTimeTest.timestampexport = string(ttTimeTest.timestamp,"HH:MM:SS").
END.
TEMP-TABLE ttTimeTest:WRITE-XML("FILE","timewritten.xml",yes,?,"timeroundtrip.xsd").
/* reading things back in */
EMPTY TEMP-TABLE ttTimeTest.
TEMP-TABLE ttTimeTest:READ-XML("FILE",
"timewritten.xml",
"EMPTY",
"timeroundtrip.xsd",
NO,
"timestampexport,CHARACTER" /* override field mapping. Required, because otherwise method will expect an INTEGER field */
) NO-ERROR.
DO iNum = 1 TO ERROR-STATUS:NUM-MESSAGES:
MESSAGE "1." ERROR-STATUS:GET-MESSAGE(iNum).
END.
FOR EACH ttTimeTest:
ASSIGN ttTimeTest.timestamp = INTEGER(ENTRY(1,timestampexport,":")) * 3600 + INTEGER(ENTRY(2,timestampexport,":")) * 60 + INTEGER(ENTRY(3,timestampexport,":")).
DISPLAY ttTimeTest.
END.