Altova MobileTogether Designer

When a Read Folder action (see screenshot below) is added to the design, the $MT_FILEINFO page source, which is structured as a set of repeating File elements, is created in the design. In the Read Folder action, you specify the folder that you want to read (see screenshot and example below). At run time, the contents of the specified folder (files and sub-folders) are read, and metadata information of each file and subfolder of the target folder is placed in a corresponding File element of the $MT_FILEINFO page source.

MTActionReadFolder

Note the following points:

 

The folder can be specified either by browsing for it or by entering an XPath expression that evaluates to a string that is the path to the target folder.

If the option to Recurse into subfolders is checked, then files and subfolders in recursive subfolders are read. Otherwise, only items in the specified folder are read.

If the Recurse into subfolders option is checked, then the option to include empty directories becomes available. This enables information about empty folders to be included in the data that is read out.

The File Pattern setting uses wildcards to filter which files of a folder are read. For example: '*.mp3' reads the details of all .mp3 files in the folder; 'My*.*' reads the details of all files that have names that begin with the characters My and take any suffix; '*' or '' reads the entire folder. If recursion into subfolders has been enabled, then the pattern is applied recursively to subfolders.

To enter multiple file patterns, the XPath expression must be a sequence of string items, each of which specifies a single pattern. For example: ("*.xml", "*.txt").

While the Read Folder action provides information about files and subfolders of the target folder, it does not provide information about the target folder itself. For details of the folder itself, submit the name of the folder in the Get File Info action.

Each page contains one $MT_FILEINFO page source. So, if there are multiple Read Folder actions on a page, then, at run time, $MT_FILEINFO at any given time will contain information about the folder that was read by the last Read Action to have been triggered.

The one $MT_FILEINFO page source is also populated with data obtained by the Get File Info action. While the data read by the Read Folder action is passed to the File child elements of $MT_FILEINFO/Root, data read by the the Get File Info action is passed to the attributes of $MT_FILEINFO/Root.

The $MT_FILEINFO page source is created either when a Read Folder action or a Get File Info action is added, whichever is added first.

 

Example

An example file named ReadFolderGetFileInfo.mtd shows how to use the Read Folder action (see screenshot of simulation below). This file is available in the (My) Documents folder Altova\MobileTogetherDesigner9\MobileTogetherDesignerExamples\Tutorials\Actions.

Click to expand/collapse

The example works as follows:

 

The end user enters the name of a folder in the edit field to the left of the Read Folder button.

The folder name is written to the Path node of the $PERSISTENT tree (see screenshot).

The Read Folder button has a Read Folder action set for its OnButtonClick event. The action targets the folder stored in $PERSISTENT/Root/Path.

On clicking Read Folder, data about the folder's items is read and passed to the File elements of $MT_FILEINFO.

Each File element is displayed in the design as the repeating row of a table.

 

MobileTogether extension functions

MobileTogether provides a range of XPath extension functions that have been specifically created for use in MobileTogether designs. Some functions can be particularly useful with specific actions. For example, mt-available-languages() returns the languages in which the solution is available and could, for example, be used with the Message Box action. If a function is especially relevant to this action, it is listed below. For a full list of extension functions and their descriptions, see the topic MobileTogether Extension Functions.

 

© 2018-2024 Altova GmbH