The schema bindings file is an XML file that allows customizations of certain aspects of the XSD-to-ASN.1 translation process. It is different from command-line switches in that it provides a way to associate configuration items with specific XSD information items within a schema or set of schemas.
For this release of XSD2ASN1, the only useful configuration item that can be specified is the location of individual source files for schemas included using the <xsd:include> and <xsd:import> declarations. These declarations allow a schemaLocation attribute to be specified, but this attribute does not necessarily have to contain a full path to the referenced file (it is described in the standard as only providing a hint for a schema processor to help in locating the file). Since third-party schemas cannot always be editied by developers, the schema binding file provides a mechanism to bind the file location information to the schema without requiring edits to the original schema.
At the outer level of the schema binding file is a <bindings> element. This is a container element that holds all of the binding elements for specific schemas. There can be one and only one <bindings> element in a schema bindings file. This element contains a mandatory "version" attribute that specifies the verion of the schema binding language in use. For this version of XSD2ASN1, the only supported version is 1.0. Therefore, the outer level of the schema bindings file will always look like this:
<bindings version="1.0"> .. specific binding elements here .. </bindings>
The only element supported below the <bindings> level is the <schemaBindings> element. This allows the association of configuration items with a specific schema. The schema is specified using the namespace attribute which identifies the schema using its target namespace.
The actual location of an include or import file can then be specified using the binding file <sourceFile> element. The content of this element is the full or relative pathname to the schema file on a local computer (access to a web URI is not supported at this time).
As an example, suppose a schema contained the following import directive:
<xsd:import namespace="http://example.com//ImportElement" schemaLocation="aImportElement.xsd"/>
It is possible to specify a different path for the aImportElement.xsd file if it did not reside in the current working directory using a schema binding file. Assume it was located in the c:\importSchemas directory. The binding file would be as follows:
<bindings version="1.0"> <schemaBindings namespace="http://example.com//ImportElement"> <sourceFile>c:\importSchemas\aImportElement.xsd</sourceFile> </schemaBindings> </bindings>