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.
ATTENDEE @lastname
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
<location id="1234">Richmond</location>
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.
Tree customization won't show name attribute
w. jordan 04-Dec-2008
A "Proc @name" customization should take the "name" attribute as the tree node text, but it did not.
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.
Tree Customization, save options
John Black 28-Aug-2007
Tree Customization has got to be the best feature of this product (aside from the speed of loading large XML.) The XML we routinely deal with is mostly "normalized", with thousands of identical tag names whose identity is defined by their attributes or child node values.
For the Wish List: Allow us to save/load options. In a large team, this allows one of us to (for example) get the Tree Customizations just right, and send around the option file to everyone else. (True, we could find it in our App Data, but users shouldn't play with those folders too much.)
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.
Tree customization lower level child element
Jim Chakour 08-May-2009
Is it possible to have a lower level child element (not direct child) displayed in the Tree? As an example, I have the following reoccurring nodes and would like the BusinessNameLine1 displayed on the SubsidiaryReturn tree.
<SubsidiaryReturn>
<ReturnHeader>
<SubsidiaryCorp>
<EIN>999999999</EIN>
<Name>
<BusinessNameLine1>Company Name</BusinessNameLine1>
</Name>
We've got over two hundred subsidiary returns in our consolidated Federal Tax Return XML eFile data which makes it very hard to traverse the list.
You can add the following line to your Tools Preferences Tree Customization:
SubsidiaryReturn ReturnHeader/SubsidiaryCorp/Name/BusinessNameLine1
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
tree customization attribute and field value?
Andrew Johnson 16-Mar-2011
Is it possible to customize to display the @NAME attribute and the field value? I have some xml structures that look like:
<Property NAME="e_mail">test@test.com</Property>
<Property NAME="first_name">Joe</Property>
<Property NAME="last_name">Smith</Property>
<Property NAME="phone">732-555-1212</Property>
and would like to customize so that the tree view shows both the attribute @NAME and the value like:
Property e_mail test@test.com Property first_name Joe Property last_name Smith Property Phone 732-555-1212
I tried customizations:
Property @NAME .
or
Property @NAME ../Property
I was thinking that "." or "../Property" makes sense since your syntax is:
@[string] == attribute [string] on current element path == path to element value that is to be displayed
So a path of "." or "../Property" would be the path to the value of <Property> from <Property> right? I can use:
Property @NAME
to get the attribute @NAME ...
Property e_mail Property first_name Property last_name Property Phone
or I can remove customizations to get value:
Property test@test.com Property Joe Property Smith Property 732-555-1212
but I can't see both the attribute and field value. Is there some way to do this?
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.
Tree customization wildcard?
w. jordan 19-Feb-2008
Is it possible to use "*" in the tree customization? For example, "* @id" will have the tree display the id attribute value for any element which has an id attribute. I guess that this can help a lot since there're so many documents having @id, @name, @title attributes.