0

Hi Progress OpenEdge dev,

I am using the following syntax to generate an XML file from temp table. All is good but for one item.

dataset dsCust:write-xml("FILE", "c:/Test/Customer.xml", true).

This is my temp table declaration

def temp-table ttCustomer no-undo         
  namespace-uri "http://WMS.URI"
  namespace-prefix "ns0"
  field PurchaseOrderNumber       as char
  field Plant                     as char.

This is my output

<ns0:GoodsReceipt xmlns:ns0="http://WMS.URI">
     <ns0:PurchaseOrderNumber/>
     <ns0:Plant>Rose</ns0:Plant>
</ns0:GoodsReceipt>

But this is my desired output

<ns0:GoodsReceipt xmlns:ns0="http://WMS.URI">
     <PurchaseOrderNumber/>
     <Plant>Rose</Plant>
</ns0:GoodsReceipt>

Notice the element inside GoodsReceipt node does not have ns0 prefix. Can this achived using write-xml? I want to avoid using DOM or SAX if possible.

Thank you

BobNoobGuy
  • 1,551
  • 2
  • 30
  • 62
  • 1
    Is what you are after that the interior elements have no namespace, or that they are included in the parent namespace without specific attribution? – Screwtape Aug 23 '18 at 08:04
  • Interior elements to have no namespace is what I am after. Thanks – BobNoobGuy Aug 29 '18 at 17:43
  • Hi! I’ve just checked the manual and it doesn’t seem to be possible to define a namespace for individual fields, so I think you are stuck with doing manually it using X-noderef etc. – Screwtape Aug 29 '18 at 17:56

2 Answers2

3

You can always manually set attributes and tag-names using XML-NODE-TYPE and SERIALIZE-NAME.

However: I've worked with lot's of xml:s and API:s together with Progress OpenEdge and have yet to fail based on namespace-problems but I guess it might depend on what you want to do with the data.

Since you don't include the entire dataset this is something of a guess. It produces more or less what you want for this specific case. I don't know how multiple "receipts" should be rendered though so you might need to change this.

DEFINE TEMP-TABLE ttCustomer NO-UNDO SERIALIZE-NAME "ns0:GoodsReceipt"
    FIELD xmlns               AS CHARACTER SERIALIZE-NAME "xmlns:ns0" INITIAL "http://WMS.URI" XML-NODE-TYPE "ATTRIBUTE"
    FIELD PurchaseOrderNumber AS CHARACTER 
    FIELD Plant               AS CHARACTER .

DEFINE DATASET dsCust SERIALIZE-HIDDEN
    FOR ttCustomer .

CREATE ttCustomer.
ASSIGN Plant = "Rose".

DATASET dsCust:write-xml("FILE", "c:/temp/Customer.xml", TRUE).
Jensd
  • 7,886
  • 2
  • 28
  • 37
0

From a quick Google on the subject, it seems the W3C suggests that the namespace prefix should be presented the way OpenEdge does it: https://www.w3schools.com/xml/xml_namespaces.asp And I'm pretty certain you can't change the behaviour with write-xml like you want to either. The documentation doesn't mention any way of overriding the behaviour. https://documentation.progress.com/output/ua/OpenEdge_latest/index.html#page/dvxml/namespace-uri-and-namespace-prefix.html

jdpjamesp
  • 762
  • 7
  • 19