Kbase P161046: ABL/4GL: How to dynamically modify a TEMP-TABLE field's XML-NODE-NAME attribute?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  3/2/2010 |
|
Status: Unverified
GOAL:
ABL/4GL: How to dynamically modify a TEMP-TABLE field's XML-NODE-NAME attribute?
GOAL:
How to modify or change a TEMP-TABLE field's XML-NODE-NAME attribute at runtime?
GOAL:
How to assign the XML-NODE-NAME attribute of the Year2 field a new value at runtime when running code similar to the following snippet?
DEFINE TEMP-TABLE Sales
FIELD Year1 AS INTEGER XML-NODE-NAME "2003"
FIELD Year2 AS INTEGER
.
CREATE Sales.
ASSIGN
Sales.Year1 = 1000
Sales.Year2 = 1500
.
TEMP-TABLE Sales:WRITE-XML("File", "C:\OpenEdge\WRK102A\Sales.xml",YES,?,?,NO).
GOAL:
How change the XML file generated by the above code from:
<?xml version="1.0"?>
<Sales xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SalesRow>
<2003>1000</2003>
<Year2>1500</Year2>
</SalesRow>
</Sales>
To the following XML file where the XML-NODE-NAME of the second field is changed from the default value of Year2 to another value, in this case 2010, derived from an INTEGER variable provided by the code or user input at runtime:
<?xml version="1.0"?>
<Sales xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SalesRow>
<2003>1000</2003>
<2010>1500</2010>
</SalesRow>
</Sales>
FACT(s) (Environment):
All Supported Operating Systems
OpenEdge 10.1x
OpenEdge 10.2x
FIX:
To dynamically modify or assign the XML-NODE-NAME attribute of a TEMP-TABLE field buffer at run time, define (a) An INTEGER variable, iNewXMLNodeValue, to store the desired year value from which the XML-NODE-NAME value will be derived, (b) A HANDLE variable, hFieldBufferHandle, to store the handle of the TEMP-TABLE buffer and (c) A HANDLE variable, iNewXMLNodeValue, to store the handle of the target field buffer itself.
Following is the above code snippet modifed to generate the desired XML file:
DEFINE VARIABLE hTableBufferHandle AS HANDLE NO-UNDO.
DEFINE VARIABLE hFieldBufferHandle AS HANDLE NO-UNDO.
DEFINE VARIABLE iNewXMLNodeValue AS INTEGER NO-UNDO.
DEFINE TEMP-TABLE Sales
FIELD Year1 AS INTEGER XML-NODE-NAME "2003"
FIELD Year2 AS INTEGER
.
CREATE Sales.
ASSIGN
Sales.Year1 = 1000
Sales.Year2 = 1500
.
ASSIGN
/* The field whose string value is desired to be the new XML-NODE-NAME attribute value for the Year2 field */
iNewXMLNodeValue = 2010
/* The TEMP-TABLE buffer handle needed to reach the field Year2 buffer handle */
hTableBufferHandle = BUFFER Sales:HANDLE
/* The field Year2 buffer handle needed to assign the new XML-NODE-NAME attribute value */
hFieldBufferHandle = hTableBufferHandle:BUFFER-FIELD ( "Year2" )
/* The assignment of the new XML-NODE-NAME attribute as the string representation of iNewXMLNodeValue INTEGER variable */
hFieldBufferHandle:XML-NODE-NAME = STRING(iNewXMLNodeValue, "9999")
.
hTableBufferHandle:WRITE-XML("File", "C:\OpenEdge\WRK102A\NewSales.xml",YES,?,?,NO).