New Features
Release date : Friday, September 4, 2009
C1 version: Composite C1 1.2 SP2 (1.2.3534.23578)...
Description : An ability to specify Xslt extension objects to be used in Xslt functions.
Example of usage:
C# code:
using System.Web;
using Composite.StandardPlugins.Functions.XslExtensions;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
namespace Composite.Examples
{
[ConfigurationElementType(typeof(XslExtensionInfo))]
public class ExtensionObject
{
public string GetFormData(string key)
{
var httpContext = HttpContext.Current;
if(httpContext == null
|| httpContext.Request == null
|| httpContext.Request.Form == null)
{
return string.Empty;
}
return httpContext.Request.Form[key] ?? string.Empty;
}
}
}
Composite.config:
<configuration>
...........
<Composite.Functions.Plugins.XslExtensionsProviderConfiguration>
<XslExtensionProviders>
<add name="ConfigurationBasedXslExtensionsProvider" type="Composite.StandardPlugins.Functions.XslExtensions.ConfigBasedXslExtensionsProvider">
<xslExtensions>
....
<add name="http://c1.composite.net/Example" type="Composite.Examples.ExtensionObject, Composite.Examples" />
</xslExtensions>
</add>
</XslExtensionProviders>
</Composite.Functions.Plugins.XslExtensionsProviderConfiguration>
</configuration>
Xslt function:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:in="http://www.composite.net/ns/transformation/input/1.0"
xmlns:e="http://c1.composite.net/Example"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="xsl in">
<xsl:template match="/">
<!-- Using the extension method in order to check if current form was submitted -->
<xsl:variable name="formPosted" select="e:GetFormData('formId') = 'feedbackForm'" />
<html>
<head>
</head>
<body>
<xsl:choose>
<xsl:when test="$formPosted = false">
<form method="post">
<!-- Some markup here -->
<input type="hidden" name="formId" value="feedbackForm" />
<input type="submit" />
</form>
</xsl:when>
<xsl:otherwise>
Thank you for the participation.
</xsl:otherwise>
</xsl:choose>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Example of usage:
C# code:
using System.Web;
using Composite.StandardPlugins.Functions.XslExtensions;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
namespace Composite.Examples
{
[ConfigurationElementType(typeof(XslExtensionInfo))]
public class ExtensionObject
{
public string GetFormData(string key)
{
var httpContext = HttpContext.Current;
if(httpContext == null
|| httpContext.Request == null
|| httpContext.Request.Form == null)
{
return string.Empty;
}
return httpContext.Request.Form[key] ?? string.Empty;
}
}
}
Composite.config:
<configuration>
...........
<Composite.Functions.Plugins.XslExtensionsProviderConfiguration>
<XslExtensionProviders>
<add name="ConfigurationBasedXslExtensionsProvider" type="Composite.StandardPlugins.Functions.XslExtensions.ConfigBasedXslExtensionsProvider">
<xslExtensions>
....
<add name="http://c1.composite.net/Example" type="Composite.Examples.ExtensionObject, Composite.Examples" />
</xslExtensions>
</add>
</XslExtensionProviders>
</Composite.Functions.Plugins.XslExtensionsProviderConfiguration>
</configuration>
Xslt function:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:in="http://www.composite.net/ns/transformation/input/1.0"
xmlns:e="http://c1.composite.net/Example"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="xsl in">
<xsl:template match="/">
<!-- Using the extension method in order to check if current form was submitted -->
<xsl:variable name="formPosted" select="e:GetFormData('formId') = 'feedbackForm'" />
<html>
<head>
</head>
<body>
<xsl:choose>
<xsl:when test="$formPosted = false">
<form method="post">
<!-- Some markup here -->
<input type="hidden" name="formId" value="feedbackForm" />
<input type="submit" />
</form>
</xsl:when>
<xsl:otherwise>
Thank you for the participation.
</xsl:otherwise>
</xsl:choose>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
New Features