XML Data Source
Last Updated: 05 Jul 2016
A XML Data Source asset allows you to show information from an XML source within your site. Each record in the XML source will be displayed as a shadow asset in the Asset Map. From there you can use the tools within Squiz Matrix, such as an Asset Listing, to display this information in your site.
Bookmarks to the headings on this page:
Once you have created yourXML Data Source, you can configure the asset on its associated screens. Many of these screens are the same or similar to those for a Standard Page and are described in the Asset Screens manual. For more information on the Record Filter screen, refer to the DB Data Source chapter in this manual.
In this chapter we will only describe the Details and Dynamic Inputs screens, which are different for a XML Data Source.
Details Screen
The Details screen allows you to configure the XML Data Source. For more information on the Status, Future Status, Thumbnail and Details sections of the Details screen, refer to the Details Screen chapter of the Asset Screens manual. For more information on the Tag Attributes and Shadow Asset Name sections, refer to the Weather Company Feed chapter in this manual.
XML Feed Details
This section allows you to set up the XML Data Source.
The fields available are as follows:
- Link For The XML Feed: enter the hyperlink for the XML feed.
- Root Tag: enter a tag to start reading the XML feed from. If nothing is specified, the entire XML feed will be parsed for the tags that have been specified in the Tag Names field.
- Tag Names: enter a comma-separated list of tags that you would like to use from the XML feed. Please note that any data to be extracted, as specified in this field, should be in the same tree level on the XML feed. Xpath like syntax is also supported here in order to extract tags specified by a particular path, for example "user/department/id".
- CDATA Tag Names: enter a comma-separated list of tags that you would like to use from the XML feed. These tags will be wrapped in an undefined Character Data (CDATA) section and must already be defined in the Tag Names field.
- Data Delimiter: enter a character to use as the Data Delimiter. This character will be used to separate XML elements that have the same name. By default, this is set to , (comma).
Once you have entered the details into these fields and clicked Commit, shadow assets will appear in the Asset Map under the XML Data Source. Each shadow asset represents one item from the XML feed. For more information on shadow assets, refer to the Shadow Asset chapter in this manual.
Example:
Consider the following XML Feed:
<books> <title>List of books</title> <recid>cat1</recid> <book> <recid>item1</recid> <title>The Dead Zone</title> <author>Stephen King</author> </book> <book> <recid>item2</recid> <title>The Murder of Roger Ackroyd</title> <author>Agatha Christie</author> </book> </books>
If you set the Tag Names value to "book/title" or "books/book/title", the Data Records returned will be:
- Record 1: The Dead Zone
- Record 2: The Murder of Roger Ackroyd
If you set it to "books/title", it will return:
- Record 1: List of books
Tag Attributes
The Tag Attributes section allows you to return attributes of specified tags exposed on the XML Data Source.
The tags exposed on the XML Data Source will be displayed in the Select Tag Attributes field. In the corresponding Attributes field(s), enter the tag attributes names to return .
Shadow Asset Name
The Shadow Asset Name section allows you to specify the name of the Shadow Assets that appear under the XML Data Source in the Asset Map, as well as providing a list of available keyword replacements for these assets.
In the Enter The Name of the Shadow Asset field, enter the name that should be used for shadow assets exposed by the XML Data Source. This name can either be a normal string or a combination of a string and keyword replacements, for example, the keyword replacement %data_source_record_set_result% could be used to display the result data of the returned records as the names of your shadow assets.
A list of keyword replacements is displayed in the Available Keywords for the Data Source Record Set Asset field, exposing the attribute values of the Shadow Assets returned on the XML Data Source. These keyword replacements can be used when defining the Shadow Asset name format, as well as to print XML data on a Site, for example, using an Asset Listing Page.
Please note that the keyword replacements listed in the Available Keywords for the Data Source Record Set Asset field will differ depending on the record attributes returned on the XML Data Source.
Transformations
This section allows you to specify an XSL File to use for extensible style sheet language styling of the XML Data File source content when previewing the asset. Please note that this option requires PHP to have XSL support supplied in your system. If your system is running on Debian, you will be required to install the php5-xsl package on your system.
In the XSL Transformation field, select an XSL File to use and click Commit. The XSL File will now be used to stylise the source content of the XML Data Source. This style will be reflected when previewing the asset onthe Preview screen.
For more information on how to create an XSL File, refer to the XSL File chapter in this manual.
Dynamic Inputs Screen
The Dynamic Inputs screen allows you use dynamic parameters within the XML feed URL.
Dynamic Variables
This section allows you to add variable names for the parameters that you want to add.
Enter the variable name into the Name field, enter the default value into the Default Value field and click Commit. The variable will be added to the list, as show in the figure below.
Once you have added a variable, you can set it up within the Data Mappings section. To delete a variable, click the Delete box and click Commit.To use the variable within the XML feed URL, add double-percentage signs around the variable name. For example, if the name of the variable is Variable, add %%Variable%% within the XML feed URL. Variable names are case sensitive, so for example, Variable is not the same as variable.
Data Mappings
This section allows you to set up the dynamic variables that have been added in the section above.
Select which variable to edit from the Parameter list and select a source from the Source list. The options available in the Data Mappings section are similar to those available in the Dynamic Section of the Details screen of an Asset Listing page. For more information on these options, refer to the Details Screen chapter in the Asset Listing manual.