Namespaces, Modes/Views with fm:set-out and fm:menu-out

This worksheet will give you an insight into setting out data using conditional XPath and using namespaces to separate data.

SYNTAX

You will need to be familiar with the fm:set-out command:

<fm:set-out match=”XPath to match” [namespace:mode=”Conditional XPath”, namespace2:mode=”Conditional XPath, …]>

The fm:menu-out command:

<fm:menu-out [namespace:mode=”Conditional XPath”, namespace2:mode=”Conditional XPath, …]>

CONCEPTS

Conditions can be specified at three different levels in a FOX module. They are:

When you are setting out data to the screen, you should try to group data that become visible/editable at the same time. You should think of it in a similar way to the concept of a Venn diagram where data is grouped and may be part of two different groups. In this way, you should think of a group as being a namespace, so it is possible for data items to appear under many different namespaces.

Different namespaces can then be enabled simultaneously on an fm:set-out and fm:menu-out by specifying them in order on the appropriate command. For example:

<fm:set-out match=”/*/EMPLOYEE_LIST” emp:mode=”.” emp-list:mode=”.”/>

Will set out items that have emp or emp-list namespace attributes assigned.

Additionally, instead of “.” which is an XPath expression that evaluates to “true”, you can put other XPath expressions in its place to only enable the namespace when a certain condition is met.

For example:

<fm:set-out match=”/*/EMPLOYEE_LIST” emp:mode=”/*/CHECK_FLAG=’correct’” emp-list:mode=”/*/MY_AMOUNT &gt; 4”/>

For each item hit in the set-out command, the XPath expression will be evaluated, and if deemed to be “true” then the namespace will be enabled at set-out level.

When this has happened, FOX will look to XPath conditions on the elements targeted providing they have attributes under the enabled namespace, and evaluate them accordingly.

In the above example, the elements of the EMPLOYEE_LIST with namespace “emp” will only display if the CHECK_FLAG is set to ‘correct’. Similarly, the elements with namespace “emp-list” will only display if MY_AMOUNT has a value greater than 4.

You can also use the namespace:view attribute on the set-out command which will enable a namespace only for an namespace:ro mode.

For example, consider

<fm:set-out match="/*/ORDER" orderOpen:view="."/>

Here the namespace is "on" for viewing only, but not as a fully active mode, i.e.:
orderOpen:ro elements are displayed as normal as they are viewable.
orderOpen:edit elements are interpreted as if orderOpen:ro, knocking edit back to view.
orderOpen:run are ignored as this is not a fully active mode, just viewing.
Conditions at the item level still apply as before.
If you try setting out the same element twice, both in edit format, fox will automatically make one of them read only so that it doesn't get confused with what value it should use.

EXERCISES

Exercise 1

Create a new namespace called “emp2”. Add this namespace as read only to the HIRE_DATE element in the Theme DOM. Add the new namespace to the set out for the EMPLOYEE_LIST.

Exercise 2

Try altering the conditions for each namespace in the set out by setting them to either true (1=1) or false (1=2). See what happens.

Exercise 3

In the set-out, change empdata:mode=”.” To empdata:view=”.” and see what happens. Afterwards, change it back to empdata:mode=”.”.