XslGenerator (iWeb)
Overview
The XslGenerator enables you to create an Xml document from a web service or from a SQL command, and then transform the Xml through a XSL stylesheet to output HTML on a page.
The XslGenerator works in iWeb as either a ASP.NET User Control referenced in a Profile Detail or as a Form Extension on a designed form. The iWeb version of XslGenerator is very similar to the eWeb XslGenerator, although there are some differences.
Samples
Here is an XslGenerator used as a Form Extension:
Here are two XslGenerators used as Profile Details on an Overview page. The one on the left is reading from a RSS feed, and the one on the right is reading from the database:
Setup
The nearly images shows how a Profile Detail on a profile page is configured with the XslGenerator control. Note the Xml Source and the Xsl Source. The remainder of this page details how to do this.
Control
To use XslGenerator as a ASP.NET User Control on a Profile Detail on a Profile Page, first add a Profile Detail as shown in the nearby image.
- In the content type enter Web Control (.ascx)
- In the content path enter /controls/
- In the content file name enter XslGenerator.ascx
Next, in the content area, you will enter special tags that the XslGenerator will interpret to compose an Xml document and Xsl stylesheet.
XML Source
SQL Command
Enter an XML statement using FOR XML PATH within the {BeginXml}{EndXml} tags. Unlike in the eWeb version, you do not need to enclose this in additional <xml> tags.
If you have parameters, enter them like this in this Xml fragment where each parameter is in a <Paramter> node with a <Name> and <Value> element. Enclose this Xml fragment between {BeginParameters}{EndParameters} tags.
{BeginXml}
execute dbo.av_GetCustomerInfo @org_cst_key = {org_cst_key} @ind_cst_key = {cst_key}
{EndXml}
{BeginParameters}
<Parameter>
<Name>cst_key</Name>
<Value>{ind_cst_key}</Value>
</Parameter>
<Parameter>
<Name>org_cst_key</Name>
<Value>{org_cst_key}</Value>
</Parameter>
{EndParameters}
In the example above, whatever is the parsed value of {ind_cst_key} will be passed into the {cst_key} within the {BeginXml}{EndXml} section, which in the example above is passed into a SP parameter called @ind_cst_key.
Web Service
You can get the XML from a webservice using {BeginPostUrl}{EndPostUrl} and optional {BeginPostData}{EndPostData} tags:
{BeginPostUrl}http://weather.yahooapis.com/forecastrss?p=94089{EndPostUrl}
or you can split this to:
{BeginPostUrl}http://weather.yahooapis.com/forecastrss{EndPostUrl}
{BeginPostData}p=94089{EndPostData}
XSL Source
Enter the XSL between {BeginXsl}{EndXsl} tags, or enter the XSL File Name between {BeginXslFileName}{EndXslFileName} tags.
For example, for a file:
{BeginXslFileName}style/xsl/indorgs.xsl{EndXslFileName}
For a stylesheet in the content data:
{BeginXsl}
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="Orgs">
<DIV>
<xsl:apply-templates select="Org" />
</DIV>
</xsl:template>
<xsl:template match="Org">
<DIV>
<span class="tinyTXT">
<strong>
<a href="DynamicPage.aspx?Site=XEvent&WebCode=EventDetail&Key={org_key}">
<xsl:value-of select="org_name" />
</a>
</strong>
</span>
</DIV>
</xsl:template>
</xsl:stylesheet>
{EndXsl}
XSL Parameters
If needed, you can pass XSL parameters as described in the link.
Form Extension
To use XslGenerator as a form extension, you must first develop a profile detail as shown above; the form extension will reference this profile detail. Next, go to the Form you want the XslGenerator to appear and add a form extension.
Enter the following:
- control class - Div
- Assembly - extension
- Typename - Avectra.netForum.Extension.XslGenerator
- Initialize Method - AddXslGenerator
- Initialize Parameters - Enter:
Page:Page;Control:Control;String:xxxxxxxx
where xxxxxxxx is the Key of the profile detail you have previously added.
Then design the form, add the extension on the form as a form control, position and size the form control, and it should work. You can use parsed values from the form's Object in the {BeginParameters}{EndParameters} tags.
Designed Form Menu
You could use this feature for a Designed Form Menu that appears when the user hovers/clicks a link on profile page. Create a form with an XslGenerator form extension, and make this form be the form used in the designed form menu.
See Also
- XslGenerator (iWeb) Case Study - detailed case study using this feature.