[Stackoverflow] [Progress OpenEdge ABL] WRITE-XML XMLNS initial value Progress OpenEdge 4GL ABL

Status
Not open for further replies.
B

BobNoobGuy

Guest
Hi I have a progress Code and here is the XML Output that I get.

<?xml version="1.0"?>
<ns1:Message xmlns:ns1="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns1:MessageHeader>
<ns1:MessageID>d7b4118fa86a43458f85871615fc2e86</ns1:MessageID>
<ns1:From>JOE</ns1:From>
<ns1:To>JANE</ns1:To>
<ns1:StoreID>BROAWAY</ns1:StoreID>
</ns1:MessageHeader>
<ns1:MessagePart>
<ns0:Shipment xmlns:ns0="http://C.SHIPMENT.Inbound">
<PurchaseOrderNumber>PO1</PurchaseOrderNumber>
<Items>
<Item>
<PurchaseOrderItemNumber>Item1</PurchaseOrderItemNumber>
</Item>
<Item>
<PurchaseOrderItemNumber>Item2</PurchaseOrderItemNumber>
</Item>
</Items>
</ns0:Shipment>
</ns1:MessagePart>
</ns1:Message>


But I don't know how to set the initial xmlns on "Message" Node (root Node)

Idealy I want the root xmlns to be as follow (notice xmlns:ns1="http://C.INTEGRATION.ENVELOPE")

<ns1:Message xmlns:ns1="http://C.INTEGRATION.ENVELOPE" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">


I am able to set XMLNS on Shipment Node using

"xmlns:ns0" initial "http://C.SHIPMENT.Inbound" xml-node-type "attribute"


But I don't know how to do it on root node.

Here is my full Progress code

/* temp table */
def temp-table ttMsgHdr no-undo serialize-name "ns1:MessageHeader"
field MsgId as char serialize-name "ns1:MessageID"
field SFrom as char serialize-name "ns1:From"
field STo as char serialize-name "ns1:To"
field StoreId as char serialize-name "ns1:StoreID".

def temp-table ttMsgPart no-undo serialize-name "ns1:MessagePart"
field GRId as recid serialize-hidden
field FakeFld as char serialize-hidden.

def temp-table ttShipment no-undo serialize-name "ns0:Shipment"
field xmlns as char serialize-name "xmlns:ns0" initial "http://C.SHIPMENT.Inbound" xml-node-type "attribute"
field GRId as recid serialize-hidden
field ItemsId as recid serialize-hidden
field PurchaseOrderNumber as char.

def temp-table ttItems no-undo serialize-name "Items"
field ItemsId as recid serialize-hidden
field ItemId as recid serialize-hidden
field FakeFld as char serialize-hidden.

def temp-table ttItem no-undo serialize-name "Item"
field ItemId as recid serialize-hidden
field PurchaseOrderItemNumber as char.

def dataset dsDataSet xml-node-name "ns1:Message" for
ttMsgHdr, ttMsgPart, ttShipment,
ttItems, ttItem
data-relation RelOne for ttMsgPart, ttShipment nested relation-fields (GRId,GRId)
data-relation RelTwo for ttShipment, ttItems nested relation-fields (ItemsId,ItemsId)
data-relation RelThree for ttItems, ttItem nested relation-fields (ItemId,ItemId).

def var dTempXmlFile as char no-undo.
MainBlock:
do on error undo, leave MainBlock on stop undo, leave MainBlock:
dTempXmlFile = "C/Test.xml".

create ttMsgHdr.
assign
ttMsgHdr.MsgId = "d7b4118fa86a43458f85871615fc2e86"
ttMsgHdr.SFrom = "JOE"
ttMsgHdr.STo = "JANE"
ttMsgHdr.StoreId = "BROAWAY".

create ttMsgPart.

create ttShipment.
ttShipment.PurchaseOrderNumber = "PO1".

create ttItems.

create ttItem.
ttItem.PurchaseOrderItemNumber = "Item1".

create ttItem.
ttItem.PurchaseOrderItemNumber = "Item2".

dataset dsDataSet:write-xml("FILE", dTempXmlFile, true).
end.


Thank you all!

Continue reading...
 
Status
Not open for further replies.
Top