20.2 Viewing and editing document XML
TreeAge Pro documents are stored in XML format. TreeAge Pro provides the option to edit the document's XML in an XML editor or a text editor.
Warning: Unless you are quite familiar with the XML syntax used by TreeAge models, it is recommended that you use the Tree Diagram Editor to make all edits in models (in particular, adding/deleting nodes), rather than editing the XML text file itself. It is easy to render a model unreadable by making bad edits to the file XML.
However, it is simple to manually create copies/backups of *.TREX files before editing the XML. The Files view also supports robust text compare/local history features, via the right-click menu. This makes it possible to track and remove/reverse selected edits to any of your project files (whether changes are made in the Tree Diagram editor or a text/XML editor). Finally, the powerful Search/Find/Replace functionality used in combination with the Files view allows regular expression search/replace within the XML (and any other text-based project documents).
To open a tree in an XML editor:
-
Right-click on a model in the Files View.
-
Choose Open With > XML Editor.
Warning: The "default" method of opening the selected model will change when opened in this way. This means that next time you simply double-click on the file, it will again use the "Text Editor" to open. Therefore, it is necessary to right-click and choose Open With > Tree Diagram Editor in order to restore the original, default opening method.
The tree will appear in an XML editor within the workspace. You can also open the tree in a Text Editor, which shows the XML in plain text format.
The Special Features tutorial example tree Cost Formula.trex is shown below in the XML editor.
XML consists of a hierarchical structure of textual data. In the XML editor, each level of the structure can be expanded or collapsed.
A portion of the basic XML structure of a TreeAge Pro tree is presented below.
Some notes on the XML format:
-
The highest-level elements within the tree document structure are tree and notation.
-
The tree element includes the building blocks of a model - variables, nodes, preferences. etc.
-
The notation element contains details related to presenting the model in the Tree Diagram Editor.
-
Variable elements are nested within the tree element because variables exist at the tree level.
-
Definition elements are nested within a specific Node element because variable definitions are defined at the node-level.
-
Some XML elements are not presented above (Markov, payoffs, etc.), but they do exist within the XML structure.
A more complete, but not exhaustive, list of XML elements is presented in the following table.
Element | Description | Parent Element |
---|---|---|
tree |
Highest level of the tree structure. |
<top level> |
notation |
Controls presentation of the model in an editor. |
<top level> |
Variables |
Variable name and properties. |
tree |
Sensitivity Range |
Sensitivity analysis range for a variable. |
Variable |
Node | Node and its properties. Nested according to its location within the tree. | tree or Node |
Definition | Variable definition associated with a node. | Node |
CategoriesRoot |
Variable categories for the tree. |
tree |
PreferenceSet |
Tree preferences. |
tree |
Termination |
Termination condition for a payoff set/calc methos |
Node (type Markov) |
Prob |
Branch probability. |
Node (with parent chance node) |
MarkovData (state) |
Collection for Markov information associated with Markov State (state rewards). |
Node (with parent Markov node) |
MarkovData (transition) |
Collection for Markov information associated with Markov Transition (transition rewards, jump state). |
Node (in transition subtree) |
Payoff |
Payoff expression for a specific payoff set at that terminal node |
Node (type Terminal) |
You can edit the structure of the model or properties of a model element within the XML view of the document (although this is not recommended). Consider the following image of a tree both in the Tree Diagram Editor and the XML Editor.
Consider the Value attribute within the Payoff element for the Node Foot Saved. If we change the Value from 4500 to 5500, then save the file in the XML editor, the Tree Diagram Editor will reflect the same change.
Be sure to save all changes in the Tree Diagram Editor before opening the XML Editor for changes. Otherwise, you run the risk of overlaying your editor changes with a freshly updated version from the XML Editor.
Additional notes on XML editing:
-
You can delete XML elements or move elements around within the XML structure.
-
You can add new elements to the XML structure, but the xml:id must have a unique value for the new item.
-
The File Search (Control + F) results are listed in XML format, so some knowledge of the XML format can be useful.