EXSLT - str:align - Version 1

Version: 1
Status: new
User Page: index.html
XML Definition: str.align.xml
Function Package: str.align.zip

Function Syntax

string str:align(string, string, string?)

Template Syntax

<xsl:call-template name="str:align">
   <xsl:with-param name="string" select="string" />
   <xsl:with-param name="padding" select="string" />
   <xsl:with-param name="alignment" select="string" />?
</xsl:call-template>

The str:align function aligns a string within another string.

The first argument gives the target string to be aligned. The second argument gives the padding string within which it is to be aligned.

If the target string is shorter than the padding string then a range of characters in the padding string are repaced with those in the target string. Which characters are replaced depends on the value of the third argument, which gives the type of alignment. It can be one of 'left', 'right' or 'center'. If no third argument is given or if it is not one of these values, then it defaults to left alignment.

With left alignment, the range of characters replaced by the target string begins with the first character in the padding string. With right alignment, the range of characters replaced by the target string ends with the last character in the padding string. With center alignment, the range of characters replaced by the target string is in the middle of the padding string, such that either the number of unreplaced characters on either side of the range is the same or there is one less on the left than there is on the right.

If the target string is longer than the padding string, then it is truncated to be the same length as the padding string and returned.

An implementation of this extension function in the EXSLT str namespace must conform to the behaviour described in this document.

Implementations

Built-in support for str:align is available in the following XSLT processors:

ProcessorProcessor VersionImplemented Version
4XSLT, from 4Suite.0.12.0a31
libxslt from Daniel Veillard et al.1.0.191

The following implementations of str:align are available:

LanguageImplemented VersionCreatorDateDownload
EXSLT Function1Jeni Tennison2001-06-08str.align.function.xsl
XSLT Template1Jeni Tennison2001-06-08str.align.template.xsl
Javascript1Chris Bayes2001-06-21str.align.js
Msxsl1Chris Bayes2001-06-21str.align.msxsl.xsl

Use Cases

Use Case Package: str.align.use-cases.zip

The following use cases illustrate the functionality of str:align.

DetailsCalling StylesheetXML DataExpected ResultCategoryTemplate
1str.align.1.xslstr.align.data.1.xml-exampleN

Change History

Submitted: 2001-06-08
Creator: Jeni Tennison(http://www.jenitennison.com/)

The str:align function aligns a string within another string.
VersionModifiedByDetails
1.12001-06-21Jeni Tennison Added Javascript and MSXML implementations.
1.22002-08-21Craig Stewart

Added 4XSLT and libxslt implementation to the list.

1.32002-11-12Craig Stewart

Updated 4XSLT version to 0.12.0a3.

http://www.exslt.org/str/functions/align/str.align.1.html last modified 2002-11-12