FX Model Editor Advanced
Adding input/output modules
Model Editor handles load and save operations via a customizable and extensible method of plug-in modules. These modules are stored in the "Translators" directory underneath the root Model Editor directory.
All modules are XSLT translation files (that must end in ".xslt"). In all cases, the translation file is expected to either begin with Model Editor's raw XML format (output) or to produce that format (input). A good way of determining how to write a translator is to examine a test model saved in the "Raw XML" format, which is the same internal format that Model Editor expects a translation module to deliver.
Although modules are encouraged to be as error-resistant as possible, if an input filter detects that it has been asked to open a file of entirely the wrong type, it may elect to return an empty string (that is, no nodes in the result tree). If Model Editor is returned an empty model, it will not detect this as an error. On the other hand, if the tree that is returned to it has no root element (no output), it will display an error to the user which may help the user to understand the problem.
An XSLT file must have a processing instruction to be recognized by Model Editor. This instruction contains the following information, as shown in this example:
<?ModelEditor Version="1.0" Name="MORPH-DSL" Type="Input" Filter="MORPH-DSL (*.xsd)|*.xsd" RootElements="xs:schema"?>
- Version: Optional. The version of the translator. Model Editor does not currently make use of this number, but it is provided in case a future use is needed.
- Name: Required. The identification of the translator.
- Type: Required. One of "Input" or "Output" to denote whether this is a load or a save module, respectively.
- Filter: Required. A filter string as used in the Open/Save dialog boxes. This string contains the display name of the filter, followed by a '|' bar character, followed by the extension or extensions of files that the module can handle. Extensions are separated by semicolons.
- RootElements: Optional. A comma-delimited list of possible root elements for input files parsed by this translator. This is not enforced--the user may choose files with other root elements using the File->Open command--but it is used by Model Editor when auto-selecting a filter. Needed for "Input" modules only.
- UnsupportedElements: Optional. A list of nodes (as declared in ModelEditor.xml) which will not be included in the saved file. When a node is listed here, all of its children are included automatically. Model Editor uses this list to display a warning to the user about potential loss of data when saving. Needed for "Output" modules only.
- Warning: Optional. Use is coupled with "UnsupportedElements" above. When Model Editor detects that there will be information loss when saving a file, it will display the string provided here as part of its warning message. This string should inform the user which parts of the model will not be saved. This string is used instead of listing "UnsupportedElements" raw in order to provide a user-friendly message. Needed for "Output" modules only.
Because XSLT files operate only on XML data, it is currently not possible to input files which are not some form of XML. (Outputting such files is, however, possible.)
It is possible to have an input- or output-only module, in which Model Editor can read a particular file format but cannot write it, or vice versa.
Altering the model tree
Model Editor's tree is completely customizable through the use of the following configuration files:
- ModelEditor.xml - This contains all of the configuration information for the editor, including what types of nodes can be edited, what data they contain, and how that data is validated.
- ModelNode.xml - This file contains the default model tree that is produced when the user selects "New" from the File menu. It is passed through the In.xslt file, below, before the final tree is generated.
- In.xslt - This file is the final arbiter of the format of the tree--that is, what nodes are placed where. All input files, including the ModelNode.xml, are passed through In.xslt before the tree view of the model is built. A change made to ModelNode.xml may not show up until In.xslt is adjusted.
All of the above files must exist within the same directory as the executable file itself.
Although customizing Model Editor is very powerful, beware that the save and load modules might expect the data to be in a specific format. Changes to the model tree may cause previously-saved files to be inaccessible, and may cause load and save to fail, until the translators are also updated.
Languages
Model Editor supports displaying all aspects of its user interface in any language that can be represented in the XML files. The translation strings are found in the ModelEditor.xml file, under the <ResourceStrings> branch.
Copyright © 2003 Magnetar Games Corporation