Release 10.1A: OpenEdge Development:
Programming Interfaces

> ## Writing a temp-table definition to XML Schema

> The following code example creates a dynamic temp-table and writes its definition to an XML Schema file.

>     /* pi-tfx-write-1.p */
>     /* Writes an XSD file from a dynamic temp table. */
>     {pi-tfx-parameterVarDefs.i}
>     DEFINE VARIABLE returnValue AS LOGICAL NO-UNDO.
>     DEFINE VARIABLE httCust AS HANDLE NO-UNDO.
>     CREATE TEMP-TABLE httCust.
>     httCust:CREATE-LIKE("Customer").
>     httCust:TEMP-TABLE-PREPARE("ttCust").

>     ASSIGN
>          cTargetType = "FILE"
>          cFile = "ttCust2.xsd"
>          lFormatted = YES
>          cEncoding = ?
>          lMinSchema = NO.
>     returnValue= httCust:WRITE-XMLSCHEMA(cTargetType, cFile, lFormatted,
>                                          cEncoding, lMinSchema).

> Note that the `min-xmlschema` method option (`lMinSchema = NO`) is set to `NO`, which means that Progress will use all the XML Schema extension attributes necessary to fully restore objects in the 4GL environment. For example, here is an example piece of the `.xsd` file generated by this code:

>     <?xml version="1.0"?>
>     <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns=""
>     xmlns:prodata="urn:schemas-progress-com:xml-prodata:0001">
>       <xsd:element name="ttCust" prodata:proTempTable="true">
>         <xsd:complexType>
>           <xsd:sequence>
>             <xsd:element name="ttCustRow" minOccurs="0" maxOccurs="unbounded">
>               <xsd:complexType>
>                 <xsd:sequence>
>                   <xsd:element name="CustNum" type="xsd:int" nillable="true"
>                        prodata:format=">>>>9" prodata:label="Cust Num"
>                        prodata:help="Please enter a customer number."/>
>                   <xsd:element name="Country" type="xsd:string" nillable="true"
>                        default="USA" prodata:format="x(20)" prodata:help="Please
>                        enter a country."/>
>                   <xsd:element name="Name" type="xsd:string" nillable="true"
>                        prodata:format="x(30)" prodata:help="Please enter a
>                        name."/>
>     .
>     .
>     .

> Re-run this code with the `min-xmlschema` method option set to `YES` (`lMinSchema = YES`), which means that Progress will use only use a small subset of its XML Schema extension attributes. The XML Schema will still identify temp-tables and prodatasets, and if necessary, it will provide `datatype` and `initial` attributes. For example, here is an piece of the `.xsd` file generated by this code with `min-xmlschema` set to `YES`:

>     <?xml version="1.0"?>
>     <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns=""
>     xmlns:prodata="urn:schemas-progress-com:xml-prodata:0001">
>       <xsd:element name="ttCust" prodata:proTempTable="true">
>         <xsd:complexType>
>           <xsd:sequence>
>             <xsd:element name="ttCustRow" minOccurs="0" maxOccurs="unbounded">
>               <xsd:complexType>
>                 <xsd:sequence>
>                   <xsd:element name="CustNum" type="xsd:int" nillable="true"/>
>                   <xsd:element name="Country" type="xsd:string" nillable="true"
>                        default="USA"/>
>                   <xsd:element name="Name" type="xsd:string" nillable="true"/>
>     .
>     .
>     .

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095