EDIFACTTranslator Class
Properties Methods Events Configuration Settings Errors
The EDIFACTTranslator component provides a simple way to convert EDI to XML and vice versa.
Class Name
InEDIFACT_EDIFACTTranslator
Procedural Interface
inedifact_edifacttranslator_open(); inedifact_edifacttranslator_close($res); inedifact_edifacttranslator_register_callback($res, $id, $function); inedifact_edifacttranslator_get_last_error($res); inedifact_edifacttranslator_get_last_error_code($res); inedifact_edifacttranslator_set($res, $id, $index, $value); inedifact_edifacttranslator_get($res, $id, $index); inedifact_edifacttranslator_do_addrenamingrule($res, $rule); inedifact_edifacttranslator_do_config($res, $configurationstring); inedifact_edifacttranslator_do_exportxmlschema($res, $schemafile); inedifact_edifacttranslator_do_loadrenamingrules($res, $rulefile); inedifact_edifacttranslator_do_loadschema($res, $filename); inedifact_edifacttranslator_do_reset($res); inedifact_edifacttranslator_do_saverenamingrules($res, $rulefile); inedifact_edifacttranslator_do_translate($res);
Remarks
The EDIFACTTranslator class provides a way to convert EDI to XML and vice versa.
Getting Started
The class will convert to XML or EDI depending on the value of InputFormat. If InputFormat is set to ifEDIFACT the data will be converted from EDI to XML. If InputFormat is set to ifXML the data will be converted from XML to EDI.
When converting from EDI to XML optionally call LoadSchema before calling Translate so that additional information can be included in the XML. If a schema is specified the XML will include types and descriptions as element attributes which are useful for interpreting the XML.
EDI elements may optionally be renamed when creating XML. To define how an element is renamed add a renaming rule by calling AddRenamingRule.
After calling Translate the resulting output will contain the EDI or XML data. If the output data is XML the ExportXMLSchema method may be called to export a schema (.xsd) defining the structure of a valid XML document. XML documents which adhere to this document may be translated from XML to EDI.
Input and Output Properties
The class will determine the source and destination of the input and output based on which properties are set.
The order in which the input properties are checked is as follows:
When a valid source is found the search stops. The order in which the output properties are checked is as follows:- OutputFile
- OutputData: The output data is written to this property if no other destination is specified.
Property List
The following is the full list of the properties of the class with short descriptions. Click on the links for further details.
InputData | The data to translate. |
InputFile | The file to translate. |
InputFormat | The format of the input data. |
OutputData | The translated data. |
OutputFile | The file to which the translated data will be written. |
Overwrite | Whether to overwrite the file. |
RenamingRule | The rule defining how EDI elements are renamed when translating to XML. |
RenamingRuleCount | The number of renaming rules. |
RenamingRuleIndex | The index of the current renaming rule. |
SchemaFormat | The format of the schema file. |
Suffix | What to append after each segment delimiter. |
Method List
The following is the full list of the methods of the class with short descriptions. Click on the links for further details.
AddRenamingRule | This method adds a renaming rule to define how an EDI element is renamed when translating to XML. |
Config | Sets or retrieves a configuration setting . |
ExportXMLSchema | Exports a XML schema. |
LoadRenamingRules | Loads a set of renaming rules from file. |
LoadSchema | Loads a schema file describing a Transaction Set. |
Reset | Resets the state of the control. |
SaveRenamingRules | Saves the current renaming rule set to a file. |
Translate | Translates the specified data. |
Event List
The following is the full list of the events fired by the class with short descriptions. Click on the links for further details.
EndFunctionalGroup | Fires whenever a control segment is read that marks the end of an interchange. |
EndInterchange | Fires whenever a control segment is read that marks the end of an interchange. |
EndLoop | Fires when the end of a loop is detected in a transaction set. |
EndTransaction | Fires whenever a control segment is read that marks the end of a transaction. |
Error | Information about errors during data delivery. |
ResolveSchema | Fires whenever a new transaction set is encountered and no schema is found for it. |
Segment | Fires whenever a data segment in a transaction set is read. |
StartFunctionalGroup | Fires whenever a control segment is read that marks the start of a functional group. |
StartInterchange | Fires whenever a control segment is read that marks the start of an interchange. |
StartLoop | Fires when the starting of a loop is detected in a transaction set. |
StartTransaction | Fires whenever a control segment is read that marks the start of a transaction. |
Warning | Fires whenever a validation warning is encountered. |
Configuration Settings
The following is a list of configuration settings for the class with short descriptions. Click on the links for further details.
CloseStreamAfterTranslate | If true, the component will close the output stream after translation. |
CrossFieldValidationEnabled | Enables cross-field validation rules. |
Encoding | The character encoding to be applied when reading and writing data. |
IncludeFooters | Whether to include footer information in the XML. |
RenamingRulesData | The renaming rules data. |
ComponentDelimiter | The delimiter character to use to separate components. |
ElementDelimiter | The delimiter character to use to separate data elements. |
ReleaseChar | The character to use to escape delimiters within values. |
RepetitionChar | The repetition character. |
SegmentDelimiter | The delimiter character to use to separate segments. |
UseSchemaId | Specifies whether to use the Id from the schema as the XML element name. |
StrictSchemaValidation | Specifies the behavior during schema validation. |
CodePage | The system code page used for Unicode to Multibyte translations. |