Defining a document model for XML documents

A document model for XML documents allows you to define how a node found in an XML document is mapped to a field, a document attribute, or both.

Here is an example of an XML document:

<?xml version="1.0"?>
<purchaseOrder orderDate="2001-01-20">             [4]  
    <shipAddress countryCode="US">                [1]
        <name>Alice Smith</name>                  [2] 
        <street>123 Maple Street</street>
        <city>Mill Hill</city>
        <state>CA</state>
        <zip>90999</zip>
    </shipAddress>
    <item partNo="123" quantity="1">           
        <name>S&B Lawnmower Type ABC-x</name> 
        <price>239.90</price>
        <shipDate>2001-01-25</shipDate>
    </item>
    <item partNo="987" quantity="1">     [3]
        <name>Multifunction Rake ZYX</name>
        <price>69.90</price>
        <shipDate>2001-01-24</shipDate>
    </item>
</purchaseOrder>

Here is an example of an XML document model:

<?xml version="1.0"?>
<XMLModel>

<XMLFieldDefinition                   [1]
name="addresses"
locator="/purchaseOrder/shipAddress"

<XMLFieldDefinition                  [2]
name="customerName"
locator="//shipAddress/name" 

<XMLAttributeDefinition                  [3]
name="partNumber"
type="NUMBER"
locator="/purchaseOrder//item/@partNo" />

<XMLFieldDefinition                  [4]
name="none"
locator="/purchaseOrder/@orderDate"
exclude="yes" />

</XMLModel>

The first line, <?xml version="1.0"?>, specifies that the model is written using XML. Each field is defined within a XMLFieldDefinition or XMLAttributeDefinition tag, which contains element parameters.

Note that all the text field definitions must be contained within the <XMLModel> tag. For restrictions, see Limitations for text fields and document attributes.