NAMESPACE-URI and NAMESPACE-PREFIX
- Last Updated: July 25, 2014
- 1 minute read
- OpenEdge
- Version 13.0
- Documentation
NAMESPACE-URI and NAMESPACE-PREFIX
NAMESPACE-URI and NAMESPACE-PREFIX interact
in a WRITE-XML method call in the following ways:
- If
NAMESPACE-URIis specified andNAMESPACE-PREFIXis not, theWRITE-XMLmethod 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-URIandNAMESPACE-PREFIXare specified, all elements in the XML document will start with theNAMESPACE-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-PREFIXis specified andNAMESPACE-URIis not, theWRITE-XMLmethod will ignore the prefix and write the document with no namespace information. TheWRITE-XML methodbehaves as if neitherNAMESPACE-URInorNAMESPACE-PREFIXis 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>