Adding Dynamic Content from a Database

From Documentation
Jump to: navigation, search

Adding Dynamic Content from a Database

You can use the NetObjects Fusion Data Source with PHP and AJAX technologies to develop dynamic, full-featured applications, but also to let your Web site visitors view and instantly update live data in a Microsoft Access, MySQL, MsSQL database, or in an XML file. Customers can change their own contact information in your database, search a database for a particular item, or list the latest prices of all products. What one visitor changes, another can see instantly, without having to wait while you re-publish.

Database Basics

A database contains at least one table. Each table is identified by a name (e.g., "Customers" or "Orders"). Table rows contain the records (rows) with data. For example, if you owned an online sporting goods business, you could create a database table named "Customers", listing the name and address of customers who have ordered products from your Web site.

SQL Queries

SQL stands for "Structured Query Language". It is the native language spoken by most database products, including Microsoft Access and MySQL. With SQL, we can ask the database a question (query) and have a recordset returned. A query like this:

SELECT LastName FROM Customers
Gives a recordset like this:

Recordset1.gif

A query like this:

SELECT LastName FROM Members
where City = "Miami"
and Address LIKE  %Shade Tree%

Gives a recordset like this:

Recordset2.gif

SQL Data Manipulation Language

SQL is a syntax for executing queries. But the SQL language also includes a syntax to update, insert, and delete records.

These query and update commands together form the Data Manipulation Language part of SQL:

  • SELECT - extracts data from a database table.
  • UPDATE - updates data in a database table.
  • DELETE - deletes data from a database table.
  • INSERT INTO - inserts new data into a database table.

NetObjects Fusion and SQL

SQL is a very powerful language that can be extremely complex and difficult to work with. NetObjects Fusion simplifies the process of using SQL by providing an easy-to-use graphical interface and dialogs. Adding data-driven functionality to your Web site is easy with NetObjects Fusion.

NetObjects Fusion and XML

XML stands for Extensible Markup Language. XML is a markup language much like HTML, and it was created to structure, store and, transport information. By using the XML data source feature, you can display the content from an external XML file or XML data embedded in the HTML file into a HTML page in any way you want. NetObjects Fusion allows you to point to an XML file or XML feed URL, and display its contents and customize the way the data is displayed into your HTML page.

Theoretical Background

Before setting data sources in NetObjects Fusion , please review the following information in order to get familiar with the following concepts:

Connectors

In NetObjects Fusion, there are two types of connectors:

Database Connectors In NetObjects Fusion, a connector contains all the necessary information for connecting to a MySQL, MsSQL, or Access database. In NetObjects Fusion , each connector contains one or more connection configurations. Each connection configuration can be used to acquire the schema, or for a specific publish profile, allowing you to manage different access information for different publish profiles. Each database connector has only a schema, but might have one or more connection configurations. Modifying the local schema in NetObjects Fusion will not modify the schema on the server.

XML Connectors XML connectors contain the connection details in order to connect to an XML file. The XML file has to be manually copied to the server and the configuration of the connection for the published site has to point to its location on the server, which is relative to the root of the site.

Data Bindings

Data Bindings consist of Database recordsets, XML datasets (or recordsets), and variables.

Database Recordsets

NetObjects Fusion allows basic and advanced configuration modes for the database recordsets. A database recordset is actually an SQL command (QUERY) that specifies a set of tables and columns, but also a relation or a condition called WHERE statement. The WHERE statement conditions may include Variables and/or fields from other recordsets, that have been previously defined.

XML Datasets

Using NetObjects Fusion, you may also configure XML datasets. The XML dataset is an xPath that points to a node from the XML schema contained in the XML connector. The children of the pointed node are the fields and the parent is the table. There is no WHERE builder for the XML Datasets. When you configure XML datasets remember that in order to provide primary key functionality to XML data sets, a field called XML_PK is added to the list of fields for each XML dataset.

Variables

NetObjects Fusion knows the following types of variables:

  • Form Variables allows you to store string values into them that are persisted across object events as opposed to variables created locally, which are destroyed at the end of every event.
  • URL variables are variables that are created by passing data on the end of the URL. They allow you to interact with Web visitors in a limited way. The URL variable is considered to be a data holder that can store information from the URL that is navigated.
  • Session variables are specific to each visitor of the site and they are used to maintain state on a Web site storing information on the duration of a user session from the moment the visitor navigates to the site to the moment the visitor leaves the site. The users who don't have cookies turned on in their browsers will not have their session variables stored. One use for session variables might be storing user preferences or password access. Session variables disappear as soon as the users session at your site is over.
  • Cookie Variable is a data holder that can store information in the visitor's browser. This is useful for user identification.
  • Server variables are set for the entire server and are available to every application on that server. Server variables are automatically available to any page in any application on the server.
  • Environment Variablesare a set of dynamic values that can affect the way running processes will behave on a computer.

Data Contexts (Repetitive Regions)

Any repetitive region may be configured as a data context. A repetitive region is an HTML tag that is repeated dynamically in order to display information from a defined Database or XML recordset. In NetObjects Fusion , we have the following repetitive regions:

  • Layout Region: Any Layout Region can be configured as a data context, if you have previously defined a database or XML recordset. All the actions targeting a repetitive region on a layout region of a multi layout region have to target the MultiLayout Region containing the Layout Region (not the Layout Region itself).
  • Table Row: Only one line of a table can be a repetitive region. All the actions targeting a repetitive region on a line of a table have to target the table containing the line (not the line itself).
  • Multi Layout Region: A Multi Layout Region can also be configured as a data source context only in PHP.

Setting DataSource Contexts (or Repetitive Region)

A Data Source Context is in fact an HTML tag that is repeated dynamically in order to display information from a defined recordset (XML or Data Base). The Data Source Context is a repetitive region that imports all the information from a database. If you are querying a database and want to return only one record that matches the condition FirstName = Joe, then you need a WHERE condition in the recordset, but you do not need to add a data source context. The query will return all the records meeting that condition, then terminate. However, if you want to return all records in which FirstName = Joe, you will need to add a repetitive region so that all records in the database are searched and those meeting the condition will be returned.

In NetObjects Fusion, you may define as many repetitive regions as you want, but there are only three object types that can be configured as repetitive regions:

  • Layout Region. If the Layout Region is placed within a Multi Layout Region, then only one Layout Region can be a repetitive region.
  • Row of a Table. In NetObjects Fusion, only a line from a table can be a repetitive region.
  • Multi Layout Region. Any Multi Layout Region can be configured as a data context, if you have previously defined a database or an XML recordset. All the actions targeting a repetitive region on a Multi Layout Region have to target the container containing the Multi Layout Region (not the Multi Layout Region itself). The Multi Layout Region can be configured as a data source context only with PHP.

Understanding Data Source functionality

You create database functionality in NetObjects Fusion by creating recordsets from relational databases or XML schemas, and by defining more advanced features like parameters from the URL, cookies, or session that can be bound to the properties of the page objects. The code generated by the NetObjects Fusion is evaluated on the server to which you publish. It is important that you have a database server and a PHP installed. For information on server requirements, check with your hosting provider and/or platform documentation.

NetObjects Fusion offers you the possibility to set up data sources for repetitive regions as layout regions and tables, or to incorporate common dynamic elements in objects such as forms, lists, and tables, all from within the NetObjects Fusion user interface and build pages that will:

  • List details of a particular record to display the name, price, and description of a particular product.
  • List all records in a database table to display names or all available products.
  • Link each record in a list either to details about that record, so that clicking a product name displays a price and description, or to a related list from another table, to display all stores where the product is available.

You can do all this by simply connecting to a database, construct queries and configuring Data Source contexts in NetObjects Fusion , and then publish data via a Web server, between your Web site and any MsSQL, MySQL, or MS Access database that is PHP or AJAX compliant. With the Data Source feature, you won't need to write the code NetObjects Fusion will generate it for you. Knowledge of SQL or specific database technology is not necessary, but you should have some knowledge of the way your database is structured and what data you intend to store in your database to most effectively work with the Data Source feature.

Before you start creating database recordsets, you need to establish a connection to the database. Once a connection to the database has been established, you can get the database, or XML schema and set recordsets to create the dynamic functionality you need for the page.

For example, suppose you want to create a page containing listings of all the names and addresses of your customers. Also suppose that you have a database containing that information. You can create a page to show this information using the following steps:

  1. In the Data Source panel, display the Connectors section.
  2. Click the New Connector.. button and select the Database connector option.
  3. Configure the connection details. Connectors allow access to your data. They define where the data resides.
  4. In the Data Source panel, display the Recordsets section.
  5. Click the New Dataset/Variable.. button and select the Recordset (Query) option.
  6. Configure a recordset to define the data that will be displayed.
  7. Place a Layout Region on the page.
  8. In the Layout Region Properties panel, enable the Data Source option.
  9. Click the DS Config button.
  10. In the DataSource Region dialog, select the Recordset that you have previously configured.
  11. Disable pagination, and then click OK.
  12. In the Layout Region, insert a text box.
  13. In the text box, type a Label that precedes the member's name.
  14. From the Data Source tools, click the Insert Field button.
  15. In the Data Source dialog, select what name information you want to display.
  16. In the Layout Region, insert a new text box.
  17. In the text box, type a Label that precedes the member's addresses.
  18. From the Data Source tools, click the Insert Field button.
  19. In the Data Source dialog, select what address information you want to display.

Before you publish your site, make sure that your page extension is .php. You cannot preview database functionality in NetObjects Fusion. To see the data source functionality, you must publish the site remotely.

Acknowledging the Data Source limitations

For a best use of the data source functionality, keep in mind the following details:

  • The Data Source features works only with PHP and AJAX.
  • If you have several repetitive regions on a page, you can use a recordset to define only one repetitive region per page.
  • You cannot configure a Data Source Context without setting a data source and creating a recordset
  • The update action only works with a form when it is not inside a repetitive region.
  • All the actions targeting a repetitive region on a layout region of a multi layout region have to target the MultiLayout Region containing the Layout Region (not the Layout Region itself).
  • All the actions targeting a repetitive region on a line of a table have to target the table containing the line (not the line itself).
  • The reload data action only works with a form that uses form elements.
  • A Layout Region defined as a repetitive region within a Multi Layout Region does not work in AJAX.
  • NetObjects Fusion does not handle data source deployment. Consequently, the user has to manually copy the XML files and/or install the databases.
  • There can be only a line per table that is a repetitive region.
  • There can be only a layout region in a Multi Layout Region that is a repetitive region.
  • Navigation Actions does not work inside a repetitive region, if the AJAX option is not enabled.

Setting the Page Extension

You can only use the NetObjects Fusion Data Source with PHP and AJAX technologies to add dynamic content to your Web site.

  1. In Online View, select the page to which you want to add dynamic content from a database.
  2. In the Page Properties panel, click the Custom Names button.
  3. From the File Extension drop-down list, select .php.
  4. Click the OK button.

Connecting to a Database

In order to set up a Data Source context, a connection must be established between your Web page and the database. A connector is used to allow your page to communicate with the database. There are three types of connections: Data Source Name (DSN), Custom Connection and OLEDB Connection string. You can create connection settings that apply to individual publishing profiles. For example, you want to check the functionality of your site locally, and then publish your site remotely to a different server with and a different database. NetObjects Fusion allows you to set up as many Publish Profiles as you wish.

Establishing an OLEDB Connection String

The differences between ODBC and OLEDB data access protocols are technical, but in the most general terms, the OLEDB connection type is newer, more advanced, and compatible with a wider selection of database technologies. Being more general, the OLEDB includes the ODBC functionality.

OLEDB (Object Linking and Embedding Database) Connection String is designed to provide access to more types of data, including the SQL functionality defined in ODBC but also defining interfaces suitable for gaining access to data other than SQL data.

For example, if you have installed an OLE DB driver for MySQL, you may create an OLEDB connection to MySQL in the following way:

  1. In the New Connection > Advanced dialog, select "MySQL" from the Database Type drop-down list.
  2. Enable the OLEDB Connection String option.
  3. Click the Browse button.

The Data Link Properties dialog appears.

  1. Select the data provider you want to connect to.
  2. Click the Next button.
  3. On the Connection section, enter the connection details.
  4. Click Test to check your connection.
  5. Click Ok.

If the Test fails, it may be for one of the following reasons:

  • The database is not running on the host specified. Check to ensure that the database is created and running on the host specified.
  • The host specified is unreachable. Check to ensure that the machine specified in the Host field is on and reachable from your machine.
  • The database specified in the Database field has not been created. Ensure that the database has been created on the running instance of MySQL on the host specified in the Host field.
  • The security information is not correct. Ensure that the User and Password fields are correct for your database.
  • You do not have permission to connect to the specified database. Ensure that you have permissions to connect to the database. Consult your system administrator.

Note: It is necessary to have permissions on the tables in the database (select, insert, update, delete, create, drop). Unless these permissions are granted, it is possible that errors appear when connecting to the database, even if the connectivity test is valid.

Setting Connection Configuration

With NetObjects Fusion, you can create separate connection configurations to allow you to associate different databases with publish profiles. In some situations, it is desirable to connect to different databases at different stages in the site development process. For example, after the site has been on the Internet for some time, you may want to test changes to the site locally before publishing. To ensure correct behavior you might need to create a test database to connect to locally. If you do not need this feature, simply leave the Publish Profile field as "Default". When you publish your site, NetObjects Fusion will select the appropriate Connector Profile and publish that connection information at the time of publish.

To establish separate Connector Profiles for each publish profile that requires a different database connection setting:

  1. In the Connectors section, select the connector to which you want to set a new publish profile.
  2. Click the Modify button.
  3. In the Publish Profile list, the Default profile is displayed.
  4. Click the Manage button.

The Manage Connection Configurations dialog appears.

  1. In the Name field, specify a new name for the Publish Profile.
  2. Click the Add button.

The new publish profile will be displayed in the Publish Profile drop-down list.

  1. Click the OK button.
  2. Complete the connection related fields.

To remove a profile:

  1. Click the Manage button.
  2. In the Manage Connection Configurations dialog, select the profile you want to delete.
  3. Click the Remove button.

The Publish profile will be removed from the Publish Profile drop-down list.

Defining a Database Structure

After establishing the database connection, you need to define the structure of your database. This structure is necessary to ensure that the database components can show meaningful data in your pages.

There are two methods of informing NetObjects Fusion of the structure of your database.

  • Automatic database structure definition
  • Manual database structure definition

Information about the structure of the database is used to create a Recordset. A Recordset is used to define what specific data to display. A Recordset can be thought of as a filter that is applied to the data in the database to ensure that only what is necessary is displayed.

Automatic Database Structure Definition

The most common method of informing NetObjects Fusion about the structure of your database is to let NetObjects Fusion import the structure information from the Data Source server or file. NetObjects Fusion retrieves the names of all of the tables and columns in the database. For more information on database basics, see Database Basics.

If you have correctly configured a connection of the Connector and you have access from the machine you are working on, NetObjects Fusion will automatically import the structure of your database.

Allowing NetObjects Fusion to import your database structure has the following advantages:

  • It saves considerable manual work.
  • It ensures that the content of your pages matches exactly what is in the database.

Manual Database Structure Definition

If you are unable to connect to your database or want to add specific tables and fields, you can modify the database structure manually. This can be useful, for example, if the database is being developed by a different person, and you know what the structure will be, but it (is not in the database yet) has not been created yet. You can manually define the structure of the tables and columns so that you can continue to work in NetObjects Fusion while the database is completed. When the database is completed, the site will work over the structure that has been created in the database. Ensure that the structure entered in NetObjects Fusion is exactly the same structure that is being created in the database.

To manually modify the database structure:

  1. On the Connector tab of the Data Sources panel, select the connector to which you want to create your database structure manually.
  2. Click the New Table button.
  3. Enter the exact name of the table in the editable field.
  4. Click New Column button.
  5. In the editable field that appears, enter the name of the first field in your table.
  6. Repeat steps 4 through 5 to create a column for each of the remaining table fields. Ensure that the field names are entered exactly as shown in the table with no spaces in the field names.

Setting up Recordsets

Databases can contain vast amounts of data. Oftentimes, there will be more data in the database than you will want to present to your users. Perhaps there are too many rows to show efficiently, or there is sensitive data'such as credit card information that you would not want to show to all users who view a page. NetObjects Fusion provides Recordsets to filter the data that is presented to users.

To set a recordset:

  1. In Page view, click on the Record sets button from the DataSources panel.

The DataSources panel displays the Recorsets section.

  1. Click the New Dataset/Variable.. button, and select the Recorset (Query) option.

The Choose a connector dialog appears.

  1. From the Connector drop-down list, select the connector to which you want to create a recordset.
  2. Click the OK button.

The Recordset dialog appears.

On the General tab of the Recordset dialog, there are three main sections:

  • Select. In this section you define which columns to display. Often a table will have many columns, but you will only want to display a portion of the available columns. NetObjects Fusion provides the ability to restrict the columns displayed to the user to a more manageable level. This allows you to create a more concise presentation of only the information necessary.
  • Where. In this section you define the where clause. A "Where" clause defines search criteria and returns only those records matching that particular set of criteria. For example, if you had a database containing 10,000 customer records, you could use a Where clause to search for customers who reside in a specific zip code, which in turn, will return only those records meeting that criteria.

The Where clause is not required; however, using a Where clause is recommended. If you have, for example, 10,000 rows of data, it is likely you won't want to return them all. You can use the Where clause to filter your results to a manageable number.

  • Order by. In this section you can specify which direction to sort the data and which column upon which to base the ordering. The data from the database is displayed in an orderly, but unsorted fashion if no ordering is specified for the Recordset. For example, if you were creating a phone-listing site, you would probably want to default to sorting by last name, ascending. That way, records whose values started with A would appear at the top, and records whose values started with 'Z' would appear at the bottom.
  1. In the Select list field, click the name of the table you are working with and then click a field that you want to display.
  2. Click the plus sign to add it to the right-hand pane.
  3. In the Where section:
    • Select a data field from the list of fields in this table. This is the field used to restrict the output.
    • Choose an operator. An operator is a phrase like "is greater than", or "is equal to".
    • Choose a value from the drop-down list or type in a custom value. This value can be a field from another recordset, or a variable. If another recordset is used, this has to be used in a Data Source context.
    • Click the plus sign to add this filter to the right-hand Where pane.
    • To replace the existing condition, repeat steps 1 through 3, highlight the condition on the right side you want to replace it with, and click the check button.
    • To add additional conditions, select AND to narrow the query results or OR to broaden the query results, and click the plus sign.
    • To remove conditions from a where clause, highlight the condition on the right side and click the minus sign.
    • To order the conditions in a Where clause, use the up and down arrows.
  4. Click OK to close the Recordset editor.

The end result is the creation of a Recordset that describes the data you want to see.

Using the Advanced Recordset Editor

Databases can potentially contain vast amounts of data. Often there will be more data in the database than you will want to present to your users. Perhaps there are too many rows to show efficiently, or there is sensitive data that you would not want to show to all users who view a page like credit card information. NetObjects Fusion provides Recordsets to filter the data that is presented to users.

Sometimes, however, to implement advanced functionality in your site, it is necessary to query the database in SQL. SQL, or Structured Query Language, is the standard native language used to ask questions of databases. NetObjects Fusion hides this complexity from users in all but the most advanced situations.

  1. In the Recorset section of the Data Sources panel, double-click the Recordset that you want to work with.
  2. On the Recordset dialog, display the Advanced tab.

The recordset is established and reflects the custom SQL filter.

  1. Add or modify the code, then click the Test button.
  2. Specify how many recordsets to return and click OK to close the Recordset editor.
  3. The end result is the creation of a Recordset that describes the data you want to see. For example, "select product name from products where sale price is greater than 0.00" is the type of filter that can be created from the Recordset dialog. You could name this Recordset "productsForSale".

Navigating Through Recordsets

You can add Navigation elements to the page so that site visitors can navigate forward and backward through results. Using the Data Source tools, you can add predefined actions to different objects that have already placed on the page, thus you can go to the first, last, next, or last record. To create a navigation element:

  1. In Page view, add several objects that you will use to navigate through the recordsets.
  2. Select the element that you want to display the previous recordset when it is clicked.
  3. On the Data Sources tools, click the Previous button.

Note: You cannot add a Data Source tool to a page that does not have a Connector already added. To the selected element, NetObjects Fusion adds a predefined action.

Defining Variables

You can define custom variables in the Recordsets panel. This is useful if you want to filter the data that appears based on inputs to the page. This advanced technique provides even greater flexibility in creating pages that are truly user driven and can change as the user searches your database.

  1. On the Data Sources panel, click on the Record sets button.
  2. Click New Dataset/Variable button.
  3. From the New Dataset/Variable drop-down menu, select which type of variable you want to use:
    • URL. Variables reflecting parameters appended to a URL.
    • Session. Variables used to associate data with a given client session.
    • Server. Variables used to associate data with a given client session.
    • Environment. Variables used to associate data with a specific application.
    • Cookie. Variables reflecting cookies passed by the requesting browser.
  4. The selected variable type will be displayed in the Recorsets pane.
  5. Click on the URL1 to modify the name of the variable.
  6. Enter a new name for the URL variable. For example: id. For example, if you select an URL type variable, you should previously set a dynamic link:

To set a dynamic link:

  1. Add a recordset to one of your Web site pages. In our example on Home page.
  2. On this page, create a link by selecting the text which you want to link to another page of your site.
  3. Click the Link tool from the Standard toolbar. The Internal Link dialog appears.
  4. Select the destination page. In our example: Page 1.
  5. In the Parameters field, enter the URL variable name followed by the "=" sign.
  6. Click the Add Data Source button to specify an array of named variables that ca be passed to the destination page.
  7. On the destination page, define a set of URL variables with the same names that will hold the data transmitted via the URL.

Note: The Data Sources dialog will appear empty, if you haven't created a recordset to this page.

  1. Click the OK button.
  2. Click the Link button.

Using Data Source Actions

Data Source actions are actions that contain data source functionality. These actions can be added and configured from the Action panel like any other action or can be added via the Data Sources toolbar. Choosing to use the Data Source toolbar then the target of the action is the object selected in the toolbar's combo box, and the configuration window is displayed after selecting the desired action.

NetObjects Fusion provides you:

  • Navigation actions: Last, Previews, Next, Last these actions are used in conjunction with a repetitive region, which have pagination. These actions can be placed on objects outside the repetitive regions and has to target the object representing the repetitive region. The targeted repetitive region cannot be included into another repetitive region.
  • Add record: It is an action that directs the user to a page where a form for adding records was designed. This action can be placed on an object that is inside or outside of the repetitive region.
  • Edit record: It is an action that directs the user to a page where a form for editing records was designed. This action can be placed on an object that is inside of the repetitive region and the link to the edit page has to have the URL variables defined in the page with the edit form in order to identify the record that is edited.
  • Delete record: It is an action that allows the deletion of the records from the data source. The action can be placed on objects that are inside of the repetitive region (but this is not a strict rule). The target has to be the object that represents the repetitive region containing the recordset used for deletion. In the configuration window, the user has to select a field used for record identification for each table that he/she wants to delete from.
  • Update record: It is an action used to define insertion and update functionality. The action can be placed on an object inside the form that is used for data gathering and has the same form as a target. (The object can be outside the form but the target must be the form. If the object is outside the form, the DS toolbar cannot be used to place the action). In the configuration window the user has to choose a destination where to redirect the browser after the action completes and a list of bindings between the form elements and the fields from the recordset where the insertion/update has to be made. If the recordset that is used for specifying the destination of the data inputed in the form contains a WHERE statement, then an update will be made. If the recodset does not contain a WHERE condition, then an insertion will be made. The form cannot be a repetitive region.
  • Reload data: is an action that reloads the data from a repetitive region. The action ca be placed on an object placed whithin (but not necessarily) a repetitive region and has as target another repetitive region. The configuration window allows the user to specify a list of bindings between form elements or fields and variables. Usually the variables set in the binding list are used in the WHERE statement of the recordset used in the targeted repetitive region. The action is intended for list-detail/master-detail functionality or for filtering a list of items.

Using the XML Data Source Feature

By using the XML data source feature, you can display the content from an external XML file or XML data embedded in the HTML file into a HTML page in any way you want. NetObjects Fusion allows you to point to an XML file or XML feed URL, display its contents, and customize the way the data is displayed into your HTML page.

It is more efficient (in terms of conversion costs) and easier to store the data in XML format.

Once you have copied the XML file to the server, you can add a connector so that your page can communicate with the XML file.

  1. Create a new connector by clicking the New Connector button from the Data Sources Properties panel.

If the Data Sources Properties panel is not visible: from the View menu, choose More Panels, then check the Data Sources option.

  1. Select the XML Connector option.
  2. Enter a name for the connector in the editable field, or keep the suggested name.
  3. Double-click the connector to open its properties editor.

The XML Datasource dialog appears.

  1. From the Publish Profile(s) drop-down list, select the Publish Profile that the connection will use.
  2. In the XML source field, enter the path to the XML file. The configuration of the connection for the published site has to point to the XML file location on the server.

For example, if the name of the XML file is menu.xml, the path will be ./menu.xml.

  1. Click the Get Schema button to acquire the schema of the XML file.
  2. Click the OK button to close the XML Datasource dialog.
  3. In the Data Sources panel, the XML schema will appear.
  4. Click on the Record sets button from the DataSources panel to define an XML recordset.
  5. Click the New Dataset/Variable.. button, and select the Recordset (Query) option.

The XML Dataset dialog will appear.

  1. In the DataSet name, enter a name for the XML record.
  2. Select a field from the XML schema.

XPath indicates nodes by position, relative position, type, content, and several other criteria.

  1. Click the Preview button to test how the recordset will be presented.

The DataSet columns field displays the column and the data type of each dataset.

  1. XML_PK represents the primary key of the XML data sets, and it is added to the list of fields for each XML dataset.
  2. Select a type for the dataset using the Data type drop-down list. There are three data types: date, number, and string.
  3. Click OK to close the XML DataSet dialog.
  4. In the Data Sources panel, the name of the dataset will appear (in this case, XML1), indicating that a recordset was created.
  5. Set a Data Source Context in order to display information from the defined recordset.
  6. If you are defining a Layout Region as a Data Source Context, check the Data source option from the General tab of the Layout Properties panel.
  7. Click the DS Config button.

The Data Source Region dialog will appear.

  1. Select the recordset that was created previously from the Recordset drop-down menu.
  2. By default, the Enable pagination option is selected and you can set how many records you want to retrieve from the database. If you disable this option, all the entries will be displayed on this page. If not, you need to create navigation elements. See Navigating Through Recordsets.
  3. In the Records per page, specify the number of records returned to display on a page.
  4. Click OK.

The Layout Region becomes a Data Source Context that retrieves information from the selected recordset.

  1. After you have created a Data Source Context, you may add data fields using the Text Tool and the options from the Data Sources toolbar.
  2. In the Layout Region, add a text box in which you type: "Name:" or whatever label you want.
  3. Point the mouse after the Name label.
  4. From the Data Source toolbar, click the Insert field button.

The Data Sources panel appears.

  1. Select which data to query.
  2. Repeat these steps to add data fields on your page.
  3. Publish your site to see the results.