Modules | Implementer Page: str.align.html Function Syntaxstring 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 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 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. Implementations
The following XSLT processors support
Implementations of
ExamplesFunctionThe following example shows how to use the Source<a> <c>Is this EXSLT? No. no</c> </a> Stylesheet<xsl:template match="a"> <xsl:apply-templates /> </xsl:template> <xsl:template match="*"> <xsl:value-of select="." /> - <xsl:value-of select="str:align(string(.), '------------------------------', 'left')" /> <xsl:value-of select="str:align(string(.), ' ', 'right')" /> <xsl:apply-templates select="*" /> </xsl:template> |
http://www.exslt.org/str/functions/align/index.html last modified 2002-11-12