Loading SEF Files Programmatically


The SetEDIExtension() method allows you to reference a SEF file programmatically. This method is a member of the Configuration class. Following is its definition:

void   SetEDIExtension(DDTek.XmlConverter.Source source) 

DataDirect XML Converters reads the source object and parses the data as a SEF file, creating an Extender object. All XML Converters created using that Configuration object use that Extender object as if it had been supplied with the user= option in the URI.

The source object may be one of the following:

UriSource 
InputStreamSource 
TextReaderSource 

Using SEF Files Created with Stylus Studio

In addition to custom segment and message definitions, SEF files created using the Stylus Studio EDI to XML Module can contain a converter: URI in a .PRIVATE section. This converter: URI can contain XML Converters properties (val=no and len=yes, for example).

If you specify such a SEF file in your application, XML Converters uses the converter properties from that URI when performing the XML conversion. That is, XML Converter properties specified in the SEF become the new default values for the XML Converter properties. This behavior is also true when the SEF file is loaded with the user= URI property.

Using a SEF File for Multiple Conversions

The Configuration object owns the Extender. If you want to use a SEF file for multiple conversions, you can do so as follows:

ConverterFactory factory = new ConverterFactory(); 
factory.Configuration.SetEDIExtension (sefSource); 

All Converter and SchemaGenerator objects created from that factory have access to the loaded SEF file, but they do not parse the SEF file each time they are created.

If SetEDIExtension is called two times, then the first SEF file is replaced by the second one. Any Converter or SchemaGenerator objects already created will still use the first SEF file.

If you want to use a SEF file for one Converter or SchemaGenerator object only, you can do so as follows:

ConverterFactory factory = new ConverterFactory(); 
Converter converter = factory.NewConvertToXML(…); 
Converter.Configuration.SetEDIExtension (sefSource);