Altova XMLSpy 2024 Professional Edition

Filters in XML documents

A filter in XML Grid View can be applied to an element node and enables you to filter the descendants of that node. Wherever a filter can be applied, a grayed out filter icon is displayed. Once a filter has been defined, this icon is shown in color (see screenshot below). A filter is defined with an XQuery 3.1 expression. For example, in the screenshot below, a filter has been set on the Temperatures node to display only those Month child elements that have a Min child element with a value that is greater than 10. (Note that in the screenshot the index number of the respective Month element instance is listed.)

 

XSXMLGridViewFilters

 

To set up a filter, right-click the element you want to filter, select Filter from the context menu that appears, enter the XQuery expression, and click Enter. The Filter cell is indicated by the icon ic_jsongridfilteroff (see screenshot above). You can activate/deactivate the filter by clicking the Filter icon.

 

 

Note the following points about filters:

 

Filters can be applied only to element nodes.

The context node of the filter's XQuery expression is the current node. In the screenshot above, for example, the context node is the Temperatures node.

Filters can be nested. A nested filter will be applied to the filtered content of the parent filter.

Each filter is executed independently and is not affected by formulas or other filters (unless it is a nested filter).

To add a new line in an expression, press Ctrl+Enter. This is useful if you want to display an expression over several lines for better readability.

The filtered content is a visual display only. The actual content remains unchanged.

After a filter has been created, it can be deactivated/reactivated via the node's context menu Filter command.

Filters are not stored in the XML document, but are kept in a special application metadata file located in your (My) Documents folder: Altova\XMLSpyCommon\json-metadata.json. Filters will be automatically applied from this file when the document is re-opened in Grid View. You can pass the metadata file to other XMLSpy users so that they can use the same filters.

 

Filters in JSON documents

Filters enable you to filter the display of objects and arrays. For example, in the screenshot below, a filter (which is an XQuery 3.1 expression) has been applied to an array so that only those tracks written by Brian May are displayed. In JSON terms, only those object children of Tracks are displayed that have a Writer property containing the string value Brian May. The filter's XQuery expression looks up all child objects of Tracks and selects those for which a lookup of the Writer property matches the string 'Brian May'.

 

JSONGridViewFilters01

 

Each filter is executed independently and is not affected by other filters or formulas in the document.

 

For information about constructing XQuery expressions for JSON documents, see the section XQuery Expressions for JSON.

 

Note:When entering expressions for filters and formulas in Grid View, you might want to display an expression over several lines for better readability. To add a new line in the expression, press Ctrl+Enter.

 

Set up a filter

To set up a filter, right-click the element you want to filter, select Filter from the context menu that appears, enter the XQuery expression, and click Enter. The Filter cell is indicated by the icon ic_jsongridfilteroff (see screenshot above). You can activate/deactivate the filter by clicking the Filter icon.

 

Note the following points about filters:

 

Filters can be applied only to objects and arrays.

The context node of the filter's XQuery expression is the current node. In the screenshot above, for example, the context node of the filter's XQuery expression is the Tracks node.

Filters can be nested. A nested filter will be applied to the filtered content of the parent filter.

Each filter is executed independently and is not affected by formulas or other filters (unless it is a nested filter).

To add a new line in an expression, press Ctrl+Enter. This is useful if you want to display an expression over several lines for better readability.

The filtered content is a visual display only. The actual content remains unchanged.

After a filter has been created, it can be deactivated/reactivated via the node's context menu Filter command.

Filters are not stored in the XML document, but are kept in a special application metadata file located in your (My) Documents folder: Altova\XMLSpyCommon\json-metadata.json. Filters will be automatically applied from this file when the document is re-opened in Grid View. You can pass the metadata file to other XMLSpy users so that they can use the same filters.

 

© 2018-2024 Altova GmbH