Tree customization in the firstobject XML editor
Many XML editors have a tree view to let you navigate the XML document by opening containing nodes and handling entire subtrees as a single unit. But when you have a list of elements like the attendees in the following example you can't tell them apart until you open them up (see the tree view on the left).
It would be handy to display important information next to the ATTENDEE tag name. That's what tree customization is for. For example, by adding a simple line to the to the Tools -> Preferences Tree Customizations, you get the additional information displayed in the tree.
This example illustrates the connection between what you are seeing in the tree on the left with the text edit area on the right, but usually the information in the text edit area on the right is much deeper and "messier."
Attributes are prefixed with an @ sign, while child elements are not. So, you can display the values of immediate child elements next to the parent.
<Log> <Purchase id="786.AC"> <Amount>29.99</Amount> <Name>J. Smith</Name> </Purchase> <Control> <Code>BCD</Code> </Control> <Purchase id="536.AB"> <Amount>87.99</Amount> <Name>Ben Bryant</Name> </Purchase> </Log>
Without customizing, the Purchase and Control nodes in the tree would be blank. To view the amount name and id next to the Purchase tag name in the tree, and the code next to the Control tag name, specify these Tree Customizations:
Purchase Amount Name @id Control Code
Each line in your Tree Customizations specifies the customization for a particular element. Right now there is no way to separate customizations for different document types, so leave your customizations together:
ATTENDEE @lastname Purchase Amount Name @id Control Code * @id @name @title
Update April 23, 2011: with release 2.4.2 you can specify a period to display the element's data value among the other customizations. The following will display the id attribute after the data value of the element:
location . @id
Update December 29, 2008: with release 2.3.2 you can specify a wildcard item in your Tools -> Preferences Tree Customizations just like you described.
* @id @name @title
The id and/or name and/or title attribute value will be displayed for any element in the tree that has any of them.
It works better now in release 2.3.2. Tree customization was originally implemented to only honor customizations for elements with child elements or no text data, so it was showing the text data of the element instead of the information specified in the customization. But now I have changed it to display what the tree customization specifies for the element even if it is not a parent element and has text data.
Great suggestion. The settings.xml also has machine specific information such as screen position coordinates and most recent file list, so you're right it would be clumsy copying that around or extracting the Tree Customzations. An export/import settings function would be ideal. In the meantime you can share the tree customizations by copying and pasting the text in the Preferences Tree Customizations editbox.
You can add the following line to your Tools Preferences Tree Customization:
Update May 11, 2009: In foxe 2.3.4 you can specify multiple lower level child elements and attributes of lower level child elements too:
<Customer> <Name first="John" last="Smith" mi="C">John C. Smith</Name> <Address> <Street1>100 Industrial Ct.</Street1> <City>Businesstown</City> <Zip>23000</Zip> <State>VA</State> </Address> </Customer>
Customer Address/State Name/@last Name/@first
Shows: Customer VA Smith John
This has been implemented in foxe release 2.4.2 with a period to represent the data value of the element. The
../Property idea is creative but
.. is not supported in CMarkup paths.
There is an awkward aspect to this. Since you can click on the display area next to the element's tag name to edit, the other display values will disappear during editing of the element's data value. Putting the period first is more natural for editing since it will stay in the same place, but that is up to you.