project QadFinancials > class TConvertInstalNETXML > method DumpXMLRepresentation

Description

Modified FC DumpXMLPresentation


Parameters


icFileinputcharacterName of the file in which the XML should be dumped.
icObjectRowidinputcharacterin case not all objects in memory need to be dumped, pass tc_Rowid of main table record to be dumped
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


QadFinancials
method TConvertInstalNETXML.Convert


program code (program1/tconvertinstalnetxml.p)

assign oiReturnStatus = -98.

create X-DOCUMENT vhdocument in widget-pool "non-persistent".
create X-NODEREF vhObject in widget-pool "non-persistent".
create X-NODEREF vhClass in widget-pool "non-persistent".
create X-NODEREF vhText in widget-pool "non-persistent".

vhDocument:ENCODING = "UTF-8":U.

/* set up a root node, pointing to the right namespaces */
vhDocument:create-node-namespace (vhObject, "com.softcell.componentbuilder.class":U, "object":U, "element":U).
vhObject:namespace-prefix = "cb":U.
vhDocument:append-child(vhObject).
vhObject:set-attribute ("xmlns":U,"com.softcell.componentbuilder.class":U).
vhObject:set-attribute ("xmlns:cb":U,"com.softcell.componentbuilder.class":U).
vhObject:set-attribute ("xmlns:xs":U,"http://www.w3.org/2001/XMLSchema":U).
vhObject:set-attribute ("xmlns:xsi":U,"http://www.w3.org/2001/XMLSchema-instance":U).
vhObject:set-attribute ("xsi:schemaLocation":U,"com.softcell.componentbuilder.class ":U + lc(vcFcComponentName) + ".xsd":U).
vhObject:set-attribute ("inputORoutput":U, "output":U).

if vcXmlOldStatus <> "":U
then do:
    vhDocument:create-node-namespace (vhClass,"com.softcell.componentbuilder.class":U,"oldStatus":U,"ELEMENT":U).
    vhClass:namespace-prefix = "cb":U.
    vhObject:APPEND-CHILD (vhClass).
    vhDocument:CREATE-NODE (vhText, "":U, "TEXT":U).
    vhClass:APPEND-CHILD (vhText).
    vhText:NODE-VALUE = vcXmlOldStatus.
    vcXmlOldStatus = "":U.
end.

if vcXmlNewStatus <> "":U
then do:
    vhDocument:create-node-namespace (vhClass,"com.softcell.componentbuilder.class":U,"newStatus":U,"ELEMENT":U).
    vhClass:namespace-prefix = "cb":U.
    vhObject:APPEND-CHILD (vhClass).
    vhDocument:CREATE-NODE (vhText, "":U, "TEXT":U).
    vhClass:APPEND-CHILD (vhText).
    vhText:NODE-VALUE = vcXmlNewStatus.
    vcXmlNewStatus = "":U.
end.

vhDocument:create-node-namespace (vhClass, "com.softcell.componentbuilder.class":U, "classRepresentation":U, "element":U).
vhClass:namespace-prefix = "cb":U.
vhObject:append-child (vhClass).
vhClass:set-attribute ("classname":U, vcFcComponentName).

/* run for starting table */
assign vhFcComponent = ?.
<M-2 run MainBlock () in XML>
assign vhXMLhandle = vhFcComponent.

<M-3 run ConvertTableToXml (input  {&TARGETPROCEDURE} (ihComponent), 
                            input  '':U (icColumns), 
                            input  vhClass (ihStartingNode), 
                            input  icObjectRowid (icObjectRowid), 
                            input  no (ilHeaderOnly), 
                            input  no (ilSuppressEmptyFields), 
                            input  tNETDynRel (tXmlDynRel), 
                            output viFcReturnSuper (oiReturnStatus)) in XML>
run gipr_DeleteProcedure in vhXMLhandle.
delete procedure vhXMLHandle.
if viFcReturnSuper <> 0
then assign oiReturnStatus = viFcReturnSuper.
if viFcReturnSuper < 0
then return.

/* add company code (not below parent node, but before parent node) */
/* -----> In standard the following code is in DumpXMLRepresentation.XMLObjectDetail */
<Q-4 run CompanyPrim (all) (Read) (NoCache)
          (input viCompanyLoadedId, (LookupCompanyId)
           input '':U, (CompanyCode)
           output dataset tqCompanyPrim) in BCompany >
find first tqCompanyPrim where
           tqCompanyPrim.tiCompany_ID = viCompanyLoadedId no-error.
if available tqCompanyPrim
then do:
    create X-NODEREF vhParent in widget-pool "non-persistent".
    create X-NODEREF vhNode in widget-pool "non-persistent".
    create X-NODEREF vhText in widget-pool "non-persistent".
    vhClass:get-parent(vhParent).
    vhDocument = vhClass:owner-document.
    vhDocument:create-node-namespace (vhNode,"com.softcell.componentbuilder.class":U,"companyCode":U,"ELEMENT":U).
    vhNode:namespace-prefix = "cb":U.
    vhParent:insert-before(vhNode,vhClass).
    vhDocument:CREATE-NODE (vhText, "", "TEXT":U).
    vhNode:APPEND-CHILD (vhText).
    vhText:NODE-VALUE = tqCompanyPrim.tcCompanyCode.
    delete object vhParent.
    delete object vhNode.
end.
/* <----- In standard the previous code is in DumpXMLRepresentation.XMLObjectDetail */

vhDocument:save ("file":U, icFile).

delete object vhText.
delete object vhClass.
delete object vhObject.
delete object vhDocument.

if oiReturnStatus = -98
then oiReturnStatus = 0.