Reference library

XML data islands (old)

This XML syntax has been improved (10.4) by the new data islands configuration page which is far more flexible and provides faster page delivery.  The syntax below is still supported but Sitekit recommend that any new dataislands are built using the new configuration table. Sitekit can also provide assistance in migrating existing data islands to the new system. 

<xmlconsumer>

<xmlsource url="http://www.url.net/source.xml" [method="POST"] [cacheInMin="31"] [allowedParameters="Letter,sitekit_siteid,sitekit_editorialid"] [namespace="http://www.sitekit.net/Webservices"]></xmlsource>

<xslsource url="http://clients.gael.net/source.xsl" [cacheInMin="3000"] [exslt="true"]></xslsource>

</xmlconsumer>

The XML consumer element has 2 mandatory elements xmlsource and xslsource.

XMLsource has 5 attributes:

Data island parameter

What it's used for

url

This is the absolutely addressed URL of the XML file to be used in the data island and is a mandatory field.

method

This defines whether the method to obtain the XML is via GET, POST or SOAP. The attribute is optional and defaults to GET.

cacheInMin

This is the cache expiry period in minutes. The attribute is optional and defaults to 0 (no caching). The acceptable range is integer values from 0 to 36000. The section below deals with caching. Should be used with allowedParameters (below) to avoid cache invalidation by the unique session id.

Skparamsreqd (deprecated see below)

Skparamsreqd attribute is deprecated and only remains for backward compatibility, 'allowedparameters' should be used instead from now on.
This defines a comma-separated list of standard sitekit parameters that must be passed to the url. Only those standard sitekit parameters that are listed will be passed, all others will be removed. This parameter is optional and, if it is omitted, all standard sitekit parameters will be passed to the url. This attribute should be used in conjunction with the cachelnMin attribute. Otherwise a unique session ID will be passed by default negating any advantages of caching.

AllowedParameters

This attribute totally supersedes the 'skparamsreqd' attribute and 'allowedparameters' should be used instead from now on.
If 'allowedparameters' is specified then only parameters whose names are in the list will be forwarded to the XML feed.
If no 'allowedparameters' attribute is given then 'skparamsreqd' processing will be done if it is specified.
If neither is specified then all parameters are forwarded to the XML feed. This attribute should be used in conjunction with the cachelnMin attribute. Otherwise a unique session ID will be passed by default negating any advantages of caching.

This attribute while optional is recommended especially if the xml url is on a separate site to stop the passing of Sitekit parameters to an external provider.

namespace

This is only required if you are using SOAP. This is the namespace of the web service class (which you can normally find at the top of your .asmx code file).

 

XSLsource has 3 attributes:

Data island parameter

What it's used for

url

This is the absolutely addressed URL of the XSL file to be used in the data island and is a mandatory field. If the XSL comes from xsl.sitekit.net it does not need to be digitally sign otherwise it does.

cacheInMin

This is the cache expiry period in minutes. The attribute is optional and defaults to 0 (no caching). The acceptable range is integer values from 0 to 36000.

exslt

True or false, defaults to false. Defines whether the XSLT uses the extended methods provide by eXSLT.

Parameter passing into XSL

This is achieved with reference to the following article http://msdn.microsoft.com/en-us/library/ts9by56w(v=vs.71).aspx using the XSLT Argument list

The following parameters are loaded as an xslt argument list so are available in the xslt

  1. form, prefixed form_
  2. querystring (both submitted and appended to to the xsl url, prefixed qs_
  3. Sitekit parameters (e.g. sitekit_siteid) , prefixed sitekit_
  4. Cookies, prefixed cookie_

Because the same parameter name can be used both in form and querystring the parameters are prefixed to distinguish between them so for example ID=7 passed in the querystring will be available as qs_ID

You cannot load the same parameter more than once so having the following querystring  page.htm?ID=6&ID=7 would throw an error. All but the first value are ignored.

Using parameters in an XSLT would be as follows:

<xsl:param name="sitekit_pagename"/>
<xsl:param name="qs_ID"/>
<xsl:template match="/rss">
xPage: <xsl:value-of select="$sitekit_pagename"/><br />
ID: <xsl:value-of select="$qs_ID"/>

The XSL parameters can be put to various uses, for example you can pull out content from specific XML nodes based on values from the sources listed above. This could allow for news XML content to be listed in a paging format with e.g. 10 items listed per page – clicking on each would take the user to the full news item detail. Or, if an XML source does not allow filtering based on parameters this can be simulated to allow a summary listing page and a full detail page to be generated from the one XML source. For example:

This XSL example lists titles from an RSS news feed:

<?xml version="1.0"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

      <xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="yes" indent="yes"/>

            <xsl:template match="channel">

                      <ul>

                                <xsl:for-each select="item">

                                          <li><a href="/details.htm?id={guid}"><xsl:value-of select="title" /></a></li>

                                </xsl:for-each>

                      </ul>

           </xsl:template>

</xsl:stylesheet>

 

As the code shows, the value of the guid element is passed to the details page as a querystring parameter called id. This value is then pulled out into the XSL on the details page which searches the XML for an item with a matching guid value. This is shown here:

<?xml version="1.0"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

     <xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="yes" indent="yes"/>

     <xsl:param name="qs_id" />

               

     <xsl:template match="item">

                <xsl:if test="guid=$qs_id">

                          <h2><xsl:value-of select="title" /></h2>

                                    <p><xsl:value-of select="description" /></p>

                          </xsl:if>

     </xsl:template>

               

     <xsl:template match="channel">

               <xsl:apply-templates select="item" />

     </xsl:template>

</xsl:stylesheet>

 

The id value is pulled into the XSL using <xsl:param name="qs_id" />. It is then called by using the $ prefix, the same way as XSL variables are called, e.g. <xsl:if test="guid=$qs_id">.

Clearing data island caches

It's recommended practice to use the CacheInMin parameter to set a cache period on data islands. But sometimes you want to override this value, clearing the cache immediately so that some urgent change can be shown immediately.

The two parameters below can be used to clear the xml and xsl caches respectively. These examples would clear the caches on all data islands on the home page of mysite.net.

http://www.mysite.net/?xmlcache=clear

http://www.mysite.net/?xslcache=clear

It is not possible to select a specific data island  - these parameters will clear the caches of all data islands on the specified page.

Related questions