Release 10.1A: OpenEdge Development:
Programming Interfaces

> ## Creating dynamic 4GL objects from XML Schema

> Both the `READ-XML()` and `READ-XMLSCHEMA()` methods can take an XML Schema and create a temp-table or ProDataSet definition from it.

> The `READ-XML()` method can find and use XML Schema from the following sources, in the order defined below:

> 1. The XML Schema specified with the `schema-location` option of the `READ-XML()` method. If this option is used, XML Schema references embedded in XML data are ignored.

> 2. A `<schema>` child element of the root element of the XML data document. Provided the method does not specify a `schema-location`, then any one or combination of this and the remaining list item are used.

> 3. An `xsi:schemaLocation` or `xsi:noNamespaceSchemaLocation` attribute on an instance data in the XML data document.

> In the following example, the `READ-XMLSCHEMA()` method will produce a temp-table named `Person` with fields `name`, `height`, `weight`, and `gender`.

>            <xsd:schema
>            <!-- namespace declarations go here -->
>     <xsd:element name="Person">
>              <xsd:complexType>
>                <xsd:sequence>
>                  <xsd:element name="PersonRow" minOccurs="0" maxOccurs="unbounded">
>                    <xsd:complexType>
>                      <xsd:sequence>
>                        <xsd:element name="name" type="xsd:string" nillable="true"/>
>                        <xsd:element name="height" type="xsd:int" nillable="true"/>
>                        <xsd:element name="weight" type="xsd:int" nillable="true"/>
>                      </xsd:sequence>
>                      <xsd:attribute name="gender" type="xsd:string"/>
>                    </xsd:complexType>
>                  </xsd:element>
>                 </xsd:sequence>
>                </xsd:complexType>
>              </xsd:element>
>            </xsd:schema>

> In the next example, the `READ-XMLSCHEMA()` method produces a ProDataSet named `dsGarden` with two temp-tables: one for holding information about the plots in the garden and another for holding information about vegetables in the garden.

>     <?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="dsGarden" prodata:proDataSet="true">
>         <xsd:complexType>
>           <xsd:sequence>
>             <xsd:element name="ttPlots" minOccurs="0" maxOccurs="unbounded">
>               <xsd:complexType>
>                 <xsd:sequence>
>                   <xsd:element name="plotId" type="xsd:int" nillable="true"/>
>                   <xsd:element name="plotDesc" type="xsd:string" nillable="true"/>
>                   <xsd:element name="isFallow" type="xsd:boolean" nillable="true"/>
>                 </xsd:sequence>
>               </xsd:complexType>
>             </xsd:element>
>             <xsd:element name="ttVeggies" minOccurs="0" maxOccurs="unbounded">
>               <xsd:complexType>
>                 <xsd:sequence>
>                   <xsd:element name="veggieId" type="xsd:int" nillable="true"/>
>                   <xsd:element name="veggieDesc" type="xsd:string" nillable="true"/>
>                   <xsd:element name="plotId" type="xsd:int" nillable="true"/>
>                 </xsd:sequence>
>               </xsd:complexType>
>             </xsd:element>
>           </xsd:sequence>
>         </xsd:complexType>
>       </xsd:element>
>     </xsd:schema>

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