Follow-On Topics

Related Topics

# Defining the XML Schema

Click the image to view full size.

The Schema Configuration dialog box is used to define the schema of the XML to be used as the input data source for the XML to Recordset step. An XML schema defines the structure of the XML, in terms of what tags are present, and the nesting of the tags. The format used by the Convert XML to Recordset tool is the industry standard XSD format.

If an XSD schema file is available for the XML that is to be used as the input data, then this can be loaded in from a file on disk (via the Import XSD/XML File button, which displays a file selection dialog box) or pasted directly into the text box shown. Any XML passed into the step at runtime must conform to this schema, otherwise an error is reported.

Using an XSD schema file is the recommended way of defining the XML schema. However, if an XSD schema is not available, then an example of the XML that is used at runtime can be loaded in or pasted into the text box. From this example XML, the tool tries to infer the schema that defines the XML that has been input.

When using XML and schema inference, there are some important caveats that apply:

- All possible elements should be included in the example XML used. If the example used omits some possible fields that may be present in the data at runtime, a validation error occurs at runtime as the inferred schema does not contain those fields.
- Care should be taken to ensure that at least two instances of the elements are present, if appropriate. For instance, if the example XML used looks like this:

      <root>
           <ActivityData>
                <Field1/>
                <Field2/>
           </ActivityData>
      </root>

  a schema is inferred from this, but it specifies that only one ActivityData element should be present. If, in the XML at runtime two elements are present, like so:

      <root>
           <ActivityData>
                <Field1>Act1</Field1>
                <Field2>notes1</Field1>
           </ActivityData>
           <ActivityData>
                <Field1>Ac21</Field1>
                <Field2>notes2</Field1>
           </ActivityData>
      </root>

  then a validation error is reported. In this case, the example XML used should include at least two ActivityData elements, as this marks the inferred schema so that multiple ActivityData elements are allowed at runtime.

Copyright © 2018 Quadrant Software B.V. All rights reserved.