XML Schema Generation
You can use the
SchemaGenerator
interface to create XML Schema files that describe the structure of XML files read or created by aConvertToXML
orConvertFromXML
object. You might want to use the SchemaGenerator interface in the following situations:
- You have a
FromXML
converter: URI, and you want to know the XML Schema that the input XML data must satisfy.- You have a
ToXML
converter: URI, and you want to know the XML Schema of the XML output.- You have a
ToXML
converter: URI and a non-XML data file, and you want to know the XML Schema of the XML output. (This functionality is available only with certain XML Converters. See XML Schema Generation Summary for more information.)The XML Schema of the generated file depends on the type of file for which the XML Schema is being created, and not on the actual data. For example, if you are creating an XML Schema for an EDI file, the XML Converter is concerned only with the file’s dialect, version, and message type/transaction set. You can specify this information by providing a sample file input, or by specifying the appropriate properties in the converter: URI. See Instance Documents and URI Parameters That Affect XML Schema for more information.
Command Line Usage
To generate XML Schema from the command line:
CmdLine /schema /converter name [:property_name
=value
[ :property_name
=value
...] ] /in filename [/out filename]Note that some XML Converters (like EDI, for example) require that you either provide an instance document or that you specify sufficient properties in the converter: URI. For ED,I for example, you need to provide dialect, version, and message type/transaction set.
Example Scenario
Consider the following example scenario: your enterprise routinely receives client data in EDI files. The data in these files needs to be converted to XML so that it can be transformed for processing by an application. After application processing, the resulting XML is again transformed to another format before being converted back to EDI.
Such a workflow can be represented with the following diagram:
In this illustration, the conversion block Convert EDI to XML represents an instance of DataDirect XML Converters™, which is used to convert the incoming EDI document – imagine it is an X12 810 transaction set (Invoice). This XML conforms to the XML Schema consistent with the X12 EDI transaction set from which it was derived. However, before the XML can be used by the processing application, it needs to be transformed into the format expected by the processing application – that is, it must conform to an XML Schema.
Imagine that XSLT is used to perform this transformation (the block XML to XML Transformation in the preceding illustration). One way to create such an XSLT is to use a mapping tool. In this case, we map nodes from the XML Schema representing the EDI X12 810 transaction set to the XML Schema representing the document format expected by the XML processing application. Here, we use DataDirect XML Converters™ to create the XML Schema for the EDI X12 810 transaction set, as shown in the following illustration.
A similar mapping process is performed to create the second XML to XML transformation (another XSLT), this time mapping XML Schema nodes from the application format to the EDI X12 810 transaction set format to create an XSLT. This XSLT transforms the XML data to a format that can be understood by the DataDirect XML Converters™.
See Creating XML Schemas from EDI for an example of using DataDirect XML Converters™ to create XML Schema from an EDI document.
Instance Documents
Some XML Converters, like those for CSV and Tab, require an instance document in order to provide DataDirect XML Converters™ with the information it needs to generate an XML Schema. Other XML Converters (like EDI) can use instance documents, but they are not required; for this type of file, you can provide information using converter: URI properties to specify characteristics of the generated XML Schema. Still others (Base64 and SDI, for example) use neither instance documents nor converter: URI properties, relying instead on DataDirect XML Converters™ built-in settings for XML Schema generation for files of that type.
See XML Schema Generation Summary for more information concerning instance document and converter: URI property usage for XML Converters.
URI Parameters That Affect XML Schema
This section describes how URI parameters affect XML Schema generation for the XML Converters that support their use. The XML Converters for which you can specify URI parameters are:
CSV XML Converter URI Parameters
The following parameters affect XML Schema generation for both CSV and tab-delimited files:
EDI XML Converter URI Parameters
The following parameters affect XML Schema generation for EDI files:
Line XML Converter URI Parameters
The following parameters affect XML Schema generation for whole-line text files:
Tab XML Converter URI Parameters
See CSV XML Converter URI Parameters.
XML Schema Generation Summary
The following table summarizes information about the XML Schema generation capabilities of DataDirect XML Converters. Note that not all XML Converters can generate XML Schema.