RSS

Knowledge Base / Functions / How to use Xslt Extension...

How to use Xslt Extension Composite.Xslt.Extensions.Globalization

Submitted Jun 03 by Larisa Kharchuk

Composite.Xslt.Extensions.Globalization provides following globalization functions for XSLT use:

 ·       LongMonthName(Int32 monthNumber)

The function return long month name by month number (example: February)

 

·       ShortMonthName(Int32 monthNumber)

The function return short month name by month number (example: "Feb")

 

·       GetGlobalResourceString(String resourceClassKey, String resourceKey)

The function return string from resource file*** in App_GlobalResources by resource class key and resource key

 

*** A resource file is an XML file that can contain strings and other resources, such as image file paths. Resource files are typically used to store user interface strings that must be translated into other languages. This is because you can create a separate resource file for each language into which you want to translate a Web page.

Global resource files are available to any page or component in your Web site. Local resource files are associated with a single Web page, user control, or master page, and contain the resources for only that page

 note: How to create Resource file read http://composite.zendesk.com/forums/5977/entries/6078

 

To call these methods make the following steps:

1.     Go to Administration part | Functions 

2.     Add new XSLT function with following parameters:

Settings tab:

Name - the function should be called intuitive understanding like "NavigationPath"

Namespace -the namespace should display function’s purpose like "Composite.Pages"

Description -function description

Output type - should be "XHTML"

 

Input Parameters

No parameters

 

Function calls

Add new function | Composite | Xslt | Extensios | Globalization

 

Template

Add new namespace “#globalizationExtensions”, where "gl" - can be any name

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

exclude-result-prefixes="xsl in"
 xmlns:in="
http://www.composite.net/ns/transformation/input/1.0"
 xmlns="
http://www.w3.org/1999/xhtml"
 xmlns:gl='#globalizationExtensions'>

 

Call methods

<xsl:value-of select="gl:LongMonthName(2)" />

<br/>

<xsl:value-of select="gl:ShortMonthName(2)" />

<br/>

<!--for resource file: App_GlobalResources\Resources.test.resources.resx-->

 <xsl:value-of select="gl:GetGlobalResourceString('test.resources','title')"/>

    

Preview

In preview mode result will be displayed in HTML format 

 

3.     Press “Save” button

4.     Edit Page or Template

5.     At content area click/right click on Insert button/link  | Functions | select created functions

6.     Press “OK” button

7.     Save changes

 

 
or cancel