Release 10.1A: OpenEdge Development:
Programming Interfaces

> ## Inferring definitions from XML data

> If the temp-table or ProDataSet has no definition, and the `READ-XML()` method does not specify a `schema-location`, and the XML document does not contain references to XML Schema, `READ-XML()` will attempt to construct schema from the XML data. This is known as inferring schema.

> If an element in the instance data contains the `"xsi:type"` attribute, the field is assigned a Progress data type based on XML Schema mapping rules. See Appendix D "XML Reference of Data Type and Code Page mappings." If the element is not typed, the field will be `CHARACTER`. All attributes and text elements will become `CHARACTER` fields.

> ##### Inferring schema for a temp-table

> Suppose you have an XML document for a single temp-table, but you have no XML Schema for it. You can either call the `READ-XML()` method on a temp-table handle and create a dynamic temp-table object in Progress; or, you can call the `READ-XML()` method on a ProDataSet handle and create a dynamic ProDataSet object with a single temp-table buffer in Progress.

> For example, examine this XML document:

>     <?xml version="1.0"?>
>     <Rows>
>       <ttFam RelativeName="Ken Koberlein">
>         <Relation>Spouse</Relation>
>         <IncludedOnBenefits>true</IncludedOnBenefits>
>         <EmpNum>1</EmpNum>
>       </ttFam>
>       <ttFam RelativeName="Kelly Smith">
>         <Relation>Daughter</Relation>
>           <IncludedOnBenefits>true</IncludedOnBenefits>
>           <EmpNum>3</EmpNum>
>       </ttFam>
>       <ttFam RelativeName="Mark Smith">
>         <Relation>Spouse</Relation>
>         <IncludedOnBenefits>true</IncludedOnBenefits>
>         <EmpNum>3</EmpNum>
>       </ttFam>
>       <ttFam RelativeName="Sam Smith">
>         <Relation>Son</Relation>
>           <IncludedOnBenefits>false</IncludedOnBenefits>
>           <EmpNum>3</EmpNum>
>       </ttFam>
>     </Rows>

> Using `READ-XML()` on a temp-table object with this XML document will create a temp-table named `ttFam`, with four `CHARACTER` fields: `RelativeName`, `Relation`, `IncludedOnBenefits` and `EmpNum`.

> Using `READ-XML()` on a ProDataSet object with this XML will create a ProDataSet named `Rows`, with one temp-table buffer, `ttFam,` with all its buffer-fields.

> ##### Inferring schema for a ProDataSet

> Suppose you have an XML document for a dataset, but you have no XML Schema for it. You can call the `READ-XML()` method on a ProDataSet handle and create a dynamic ProDataSet object in Progress.

> For example, examine this XML document:

>     <?xml version="1.0"?>
>     <myDataSet>
>       <Department>
>         <DeptCode>400</DeptCode>
>         <DeptName>Sales</DeptName>
>       </Department>
>       <Employee EmpNum="3">
>         <DeptCode>400</DeptCode>
>         <LastName>Smith</LastName>
>         <FirstName>Lee</FirstName>
>         <Address>1342 Atlantic Ave</Address>
>         <City>Boston</City>
>       </Employee>
>       <Family RelativeName="Ken Koberlein">
>         <Relation>Spouse</Relation>
>         <IncludedOnBenefits>true</IncludedOnBenefits>
>         <EmpNum>3</EmpNum>
>       </Family>
>     </myDataSet>

> Using `READ-XML()` on a ProDataSet object will create a ProDataSet named `myDataSet` with three temp-table buffers: `Department`, `Employee` and `Family`. The `Department` temp-table has two `CHARACTER` fields: `DeptCode` and `DeptName`. The `Employee` temp-table has six `CHARACTER` fields: `EmpNum`, `DeptCode`, `LastName`, `FirstName`, `Address` and `City`. The `Family` temp-table has four `CHARACTER` fields: `RelativeName`, `Relation`, `IncludedOnBenefits`, and `EmpNum`.

> Using `READ-XML()` on a temp-table object will fail, since there is more than one temp-table represented in the XML document.

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