One of the challenges of working with medium and large XML model files is ability to quickly browse the structure of the model and then drill in to view and edit details of a specific model element. Xomega Editor extends the standard XML editor to support this through custom outlining and a standard Visual Studio feature of Collapsing to Definitions, which you can invoke by selecting the corresponding menu item (e.g.
Edit > Outlining > Collapse to Definitions) or by using the associated shortcut (e.g.
Ctrl+M,O).
When you collapse to definitions, the Xomega Editor collapses all the major entities, such as types, enumerations, object fields, operations, etc, which allows you to easily browse them and then expand only the ones that you're interested in. If the collapsed entity in turn contains other major entities, such as a subobject containing its own fields and operations, those will also be initially collapsed, so that you could browse them and expand as needed.
Xomega installation is already configured with which entities should be collapsed to definitions by default. However, you can easily change this behavior if you want a different set of entities to be collapsed, or if you have defined new entities that you want to be included as well. Below are the steps you need to take to achieve this.
- Go to the schema definition of the XML element in your model, for which you want to configure the behavior when collapsing to definitions. One of the easiest ways to do it is to set the cursor on the element in your model and select the Go To Definition context menu or press F12. This should take you to the definition of the element in the corresponding XSD file.
- Make sure that the element has an xs:annotation nested element, where the xs prefix is mapped to the "http://www.w3.org/2001/XMLSchema" namespace.
- Add an xs:appinfo element inside the xs:annotation element.
- Add an xom:outline-definition element inside the xs:appinfo element, where the xom prefix is mapped to the "urn:xomega-net:language" namespace.
- Set the collapse attribute to true to make the current element being collapsed when you collapse the definitions. If you don't want it to be collapsed, then you can set this attribute to false or remove these elements altogether.
- Save the schema file and go back to the model file. Collapse the model elements to definitions and make sure that it behaves as expected.
The following snippet demonstrates how a
type element is configured in the schema to be collapsed when collapsing to definitions.
Code:
<xs:element name="type" type="tns:typeDefinition" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>A named simple type that can be used for fields and parameters.</xs:documentation>
<xs:appinfo>
<xom:outline-definition collapse="true"/>
</xs:appinfo>
</xs:annotation>
</xs:element>