Featured Post

Applying Email Validation to a JavaFX TextField Using Binding

This example uses the same controller as in a previous post but adds a use case to support email validation.  A Commons Validator object is ...

Saturday, December 18, 2010

XSDs and Structured Schema Designer

For simple applications, XML can be shipped around without a detailed specification like an XSD (XML Schema) or DTD. An informal agreement about the elements and their contents can be made and if there is little ambiguity or change expected in the future, this may suffice. However, for cases where there is the potential for ambiguity in the XML contents, optional and wildly varying document structures, multiple versions, and multiple authors, an XSD is essential.



An XSD (XML Schema Document) is a description of a range of XML documents. The description contains the names, namespaces, structure, and annotation of the XML document. XSDs are composable, meaning that XML types defined in one XSD can be extended or included in other XSDs. For example, industry standard data types can be repackaged for new uses while retaining their well-known and agreed upon definitions.

To use an XSD in Pervasive Data Integrator, you should first use Structured Schema Designer. This reads in an XSD file and related imports. The list of supported types in the file and related imports is presented in Structured Schema Desginer to the user for building an XML document. After selecting the data types (possibly all) to be read in or output, the user saves the structured schema for use in a map.

For simple XSDs, where all of the data types reside in a single file, follow this procedure to build a source or target structured schema.

1. Start Structured Schema Designer. From Repository Explorer, select File > New > Structured Schema.
2. Specify Source Schema or Target Schema in the toolbar.
3. Select XML from the Datatype Filter select.
4. Select XML Schema (W3C XSDL) from the "Copy from" select.
5. Navigate to the XSD file.
6. Select the toplevel elements and types to be used in the target.
7. Press ok.
8. Save the file

The Structured Schema is now ready to be used in Map Designer. To do this, enter "XML" in Map Designer's Source or Target Connection. Then, select the Structured Schema saved in the previous operation.

For a narrated video tutorial on working with XML within Map Designer, visit RDBMS to XML with Map Designer.

It's almost always a good idea to build an XSD when working with XML. This isn't limited to SOA-initiatives. RESTful web services can benefit greatly too, especially if the data is at all ambiguous. As time moves on and the data changes, XSD has mechanisms for versioning and extending the definitions so that new deployments can be rolled out without breaking existing systems.

This post is replicated from http://my.opera.com/walkerca/blog/xsds-and-structured-schema-designer.

No comments:

Post a Comment