Please enable JavaScript to view this site.

Altova MobileTogether Designer

Tutorials > QuickStart (Part 1)

Add a Page Source (or Data Source)

Scroll Home Prev Top Next More

You have so far created a page and given it a title. In this part, you will:

 

Add an empty XML page source for this page

Since this page source has neither structure or content, create structure and content directly in the Page Sources Pane

Set a default XPath context node

 

 

 

A page can have one or more page sources from where data can be obtained. Page sources are defined in the Page Sources Pane and can be specified to be read-only or editable. They can be external sources, or can be created directly in the Page Sources Pane and contain static data. The types of page sources that can be used are described in the section Page Sources (Data Sources). In this tutorial, we will add one type of page source, an editable empty XML source, for which we will then create a structure and content directly in the Page Sources Pane.

 

To add the page source for the page, do the following:

 

1.Click the Add Source button in the toolbar of the Page Sources Pane to display the Add Page Source dialog (screenshot below).

Click to expand/collapse

2.Select New, empty XML, and click Next.

3.In the next screen, keep the default settings (XML, Editable, Data is copied to client, Load data on first use), and click OK. (When a page source is created as editable, data in it can be modified.) A root node called $XML1 is added to the Page Sources tree in the Page Sources Pane (screenshot below).

MTDQS01DataSources01

4.Notice that the XML tree with the root node $XML1 is empty. Right-click $XML1 and select Add Child | Element, then enter the element name, Products.

5.Add a child element to Products (by right-clicking it and selecting Add Child | Element), and name the child element Product. If you wish to rename the elements, double-click the element names and edit them.

6.Right-click the Product element, select Ensure exists on load (fixed value), then enter xmlspy (see screenshot below). This will be the Product element's default content when the page loads.

MTDQS01DataSources02

Notice that there is no default XML file assigned to $XML1. A default file would provide the data that goes into the nodes of the page source's tree. The data provided by a default file can be overridden by data that is manually entered in a tree node. In our case, there is a single data node: $XML1/Products/Product, and it has the string xmlspy as its default content. The XML data structure is:

<Products>

   <Product>xmlspy</Product>

</Products>  

 

Set a Page XPath Context Node

Each page has a Page XPath Context Node, which is used as the context node for relative XPath expressions defined on that page. The Page XPath Context Node is indicated in the Page Sources Pane with the label XPath Context (see screenshot below). Note that each page has its own Page XPath Context Node.

 

We will change the Page XPath Context Node to the Products node. Do this by right-clicking Products and selecting Set As Page XPath Context. The element Products will be set as the Page XPath Context Node—this is indicated by the node being labeled XPath Context (see screenshot below).

MTDQS01DataSources03

Note:If you wish, in your XPath expression, to reference a node in a page source tree other than that of the Page XPath Context Node, use an absolute path to that node, starting with the root node of that tree. For example: $XML2/SomeRootElement/SomeOtherElement.

 

© 2019 Altova GmbH