FlexSim command cmdsavetree(somenode, "path.fsx") saves a tree in XML format. All code is saved as text data on some of the tree nodes. FlexSim uses predefined character entities like <, >, & to escape characters '<', '>', '&' which are very common in Flexscript code. FlexSim doesn't support other human-readable formats to save code.
The code sections written to XML and escaped this way are much less readable than code written verbatim. Also, it is inconvenient to edit XML files by hand or simply searching for some expressions in such files.
An alternative solution is to use XML CDATA sections for longer text and code nodes. In this case only "]]>" sequence has to be escaped, and special characters can be used verbatim.
Above: FSX with CDATA, code is easily readable and can be edited by hand.
Below: FSX as saved by FlexSim.
Currently (FlexSim 2017 LTS and FlexSim 2018 Beta):
- FlexSim doesn't use CDATA when saving files
- FlexSim cannot load valid XML if it contains CDATA sections (cmdsavetree silently fails and only some nodes are loaded)
The proposal is:
- Update XML reader to allow CDATA in XML, as it is valid XML 1.0 (Sec 2.7 of the spec) and should not lead to data loss
- Consider using CDATA sections when saving code nodes