# EXSLT - str:align - Implementer Page

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:
Processor | Processor Version | Implemented Version
--- | --- | ---
4XSLT, from 4Suite. | 0.12.0a3 | 1
libxslt from Daniel Veillard et al. | 1.0.19 | 1
The following implementations of `str:align` are available:
Language | Implemented Version | Creator | Date | Download
--- | --- | --- | --- | ---
EXSLT Function | 1 | Jeni Tennison | 2001-06-08 | str.align.function.xsl
XSLT Template | 1 | Jeni Tennison | 2001-06-08 | str.align.template.xsl
Javascript | 1 | Chris Bayes | 2001-06-21 | str.align.js
Msxsl | 1 | Chris Bayes | 2001-06-21 | str.align.msxsl.xsl
## Use Cases Use Case Package: str.align.use-cases.zip The following use cases illustrate the functionality of `str:align`.
Details | Calling Stylesheet | XML Data | Expected Result | Category | Template
--- | --- | --- | --- | --- | ---
1 | str.align.1.xsl | str.align.data.1.xml | - | example | N
## Change History Submitted: 2001-06-08 Creator: Jeni Tennison(http://www.jenitennison.com/) The str:align function aligns a string within another string.
Version | Modified | By | Details
--- | --- | --- | ---
1.1 | 2001-06-21 | Jeni Tennison | Added Javascript and MSXML implementations.
1.2 | 2002-08-21 | Craig Stewart | Added 4XSLT and libxslt implementation to the list.
1.3 | 2002-11-12 | Craig Stewart | Updated 4XSLT version to 0.12.0a3.

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