Try OpenEdge Now
skip to main content
Working with XML
Reading and Writing XML Data from Temp-Tables and ProDataSets : Methods and attributes : Attribute interactions : NAMESPACE-URI and NAMESPACE-PREFIX
 
NAMESPACE-URI and NAMESPACE-PREFIX
NAMESPACE-URI and NAMESPACE-PREFIX interact in a WRITE-XML method call in the following ways:
*If NAMESPACE-URI is specified and NAMESPACE-PREFIX is not, the WRITE-XML method writes the XML document using a default namespace (xmlns="namespaceUri"). For example:
DEFINE TEMP-TABLE ttCustomer NO-UNDO
  NAMESPACE-URI "http://myCompanyServer.com/myNamespace"
  FIELD CustNum LIKE Customer.CustNum
  FIELD Name    LIKE Customer.Name FORMAT "x(30)".
This example produces XML like the following:
<?xml version="1.0"?><ttCustomer xmlns="http://myCompanyServer.com/myNamespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ttCustRow xmlns="http://myCompanyServer.com/myNamespace">
<CustNum>3</CustNum>
<Name>Hoops</Name>
</ttCustRow>
</ttCustomer>
*If both NAMESPACE-URI and NAMESPACE-PREFIX are specified, all elements in the XML document will start with the NAMESPACE-PREFIX. For example:
DEFINE TEMP-TABLE ttCustomer NO-UNDO
  NAMESPACE-URI "http://myCompanyServer.com/myNamespace"
  NAMESPACE-PREFIX "myPrefix"
  FIELD CustNum LIKE Customer.CustNum
  FIELD Name LIKE Customer.Name FORMAT "x(30)".
This example produces XML like the following:
<?xml version="1.0"?>
<myPrefix:ttCustomer xmlns:myPrefix="http://myCompanyServer.com/myNamespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<myPrefix:ttCustRow>
<myPrefix:CustNum>3</myPrefix:CustNum>
<myPrefix:Name>Hoops</myPrefix:Name>
</myPrefix:ttCustRow>
</myPrefix:ttCustomer>
*If NAMESPACE-PREFIX is specified and NAMESPACE-URI is not, the WRITE-XML method will ignore the prefix and write the document with no namespace information. The WRITE-XML method behaves as if neither NAMESPACE-URI nor NAMESPACE-PREFIX is specified. For example:
DEFINE TEMP-TABLE ttCustomer NO-UNDO
  NAMESPACE-PREFIX "myPrefix"
  FIELD CustNum LIKE Customer.CustNum
  FIELD Name LIKE Customer.Name FORMAT "x(30)".
This example produces XML like the following:
<?xml version="1.0"?>
<ttCustomer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ttCustRow>
<CustNum>3</CustNum>
<Name>Hoops</Name>
</ttCustRow>
</ttCustomer>