text-utilities.xsl revision 1008
0N/A ! The contents of this file are subject to the terms of the 0N/A ! Common Development and Distribution License, Version 1.0 only 0N/A ! (the "License"). You may not use this file except in compliance 0N/A ! You can obtain a copy of the license at 0N/A ! See the License for the specific language governing permissions 0N/A ! and limitations under the License. 0N/A ! When distributing Covered Code, include this CDDL HEADER in each 0N/A ! file and include the License file at 0N/A ! add the following below this CDDL HEADER, with the fields enclosed 1472N/A ! by brackets "[]" replaced with your own identifying information: 1472N/A ! Portions Copyright [yyyy] [name of copyright owner] 1879N/A ! Portions Copyright 2007 Sun Microsystems, Inc. 1879N/A<
xsl:
stylesheet version="1.0" 1879N/A This XSLT file contains generic templates which can be used for any 1879N/A <
xsl:
output method="text" encoding="us-ascii" />
0N/A Format a block of text. This template handles two levels of 0N/A indentation: the indentation string for the first line, and a 0N/A second indentation string used for subsequent lines. The template 0N/A will output the content wrapping at the nearest word boundary to 0N/A the specified column. 0N/A The indentation text used for the first line. 0N/A The indentation text used for all lines except 0N/A the first - defaults to the value of indent-text. 0N/A The text to be formatted. 0N/A The text column before which text should be word 0N/A <
xsl:
template name="format-text">
0N/A <
xsl:
param name="indent-text" />
3863N/A <
xsl:
param name="indent-text2" select="$indent-text" />
0N/A <
xsl:
param name="wrap-column" />
0N/A <
xsl:
param name="content" />
0N/A <
xsl:
value-
of select="$indent-text" />
0N/A <
xsl:
call-
template name="format-text-help">
0N/A <
xsl:
with-
param name="indent-text" select="$indent-text2" />
0N/A <
xsl:
with-
param name="wrap-column" select="$wrap-column" />
0N/A <
xsl:
with-
param name="content" select="normalize-space($content)" />
0N/A <
xsl:
with-
param name="column" 0N/A select="string-length($indent-text) + 1" />
0N/A </
xsl:
call-
template>
0N/A <
xsl:
text>
</
xsl:
text>
0N/A PRIVATE implementation template for format-text. 0N/A <
xsl:
template name="format-text-help">
0N/A <
xsl:
param name="indent-text" />
0N/A <
xsl:
param name="wrap-column" />
0N/A <
xsl:
param name="content" />
0N/A <
xsl:
param name="column" />
0N/A <
xsl:
variable name="head" select="substring-before($content, ' ')" />
0N/A <
xsl:
variable name="tail" select="substring-after($content, ' ')" />
0N/A <
xsl:
if test="string-length($content)">
0N/A <
xsl:
when test="string-length($head) = 0">
0N/A test="(string-length($content) + $column) > $wrap-column">
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
value-
of select="$indent-text" />
0N/A <
xsl:
value-
of select="' '" />
0N/A <
xsl:
value-
of select="$content" />
0N/A test="(string-length($head) + $column) > $wrap-column">
0N/A <
xsl:
text>
</
xsl:
text>
0N/A <
xsl:
value-
of select="$indent-text" />
0N/A <
xsl:
value-
of select="' '" />
0N/A <
xsl:
value-
of select="$head" />
0N/A <
xsl:
call-
template name="format-text-help">
0N/A <
xsl:
with-
param name="indent-text" select="$indent-text" />
0N/A <
xsl:
with-
param name="wrap-column" select="$wrap-column" />
0N/A <
xsl:
with-
param name="content" select="$tail" />
0N/A <
xsl:
with-
param name="column" 0N/A select="string-length($indent-text) + string-length($head) + 1" />
0N/A </
xsl:
call-
template>
0N/A <
xsl:
value-
of select="concat(' ', $head)" />
0N/A <
xsl:
call-
template name="format-text-help">
0N/A <
xsl:
with-
param name="indent-text" select="$indent-text" />
0N/A <
xsl:
with-
param name="wrap-column" select="$wrap-column" />
0N/A <
xsl:
with-
param name="content" select="$tail" />
0N/A <
xsl:
with-
param name="column" 0N/A select="$column + string-length($head) + 1" />
0N/A </
xsl:
call-
template>
0N/A Convert a string to title-case or, if the string is a known 0N/A abbreviation, convert it to upper-case. For example, the string 2630N/A "hello" will be converted to the string "Hello", but the string 342N/A "ldap" will be converted to "LDAP". 0N/A The string to be converted to title-case. 0N/A <
xsl:
template name="to-title-case">
0N/A <
xsl:
param name="value" />
0N/A <
xsl:
variable name="is-abbreviation">
0N/A <
xsl:
call-
template name="is-abbreviation">
0N/A <
xsl:
with-
param name="value" select="$value" />
0N/A </
xsl:
call-
template>
0N/A <!-- Convert common abbreviations to uppercase --> 0N/A <
xsl:
when test="$is-abbreviation = 'true'">
0N/A select="translate($value, 0N/A 'abcdefghijklmnopqrstuvwxyz', 0N/A 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')" />
0N/A <
xsl:
variable name="first" select="substring($value, 1, 1)" />
0N/A <
xsl:
variable name="remainder" select="substring($value, 2)" />
0N/A <
xsl:
variable name="first-upper" 0N/A 'abcdefghijklmnopqrstuvwxyz', 1166N/A 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')" />
1166N/A <
xsl:
value-
of select="concat($first-upper, $remainder)" />
0N/A Convert an entity or property ID to a user friendly mixed-cased 0N/A name. For example, the string "my-string-value" will be converted to 0N/A the string "My String Value". 342N/A The ID string to be converted to a Java name. 0N/A <
xsl:
template name="name-to-ufn">
0N/A <
xsl:
param name="value" select="/.." />
0N/A <
xsl:
if test="string-length($value)">
0N/A <
xsl:
when test="contains($value, '-')">
0N/A <
xsl:
variable name="head" 0N/A select="substring-before($value, '-')" />
0N/A <
xsl:
variable name="tail" 0N/A select="substring-after($value, '-')" />
0N/A <
xsl:
call-
template name="to-title-case">
0N/A <
xsl:
with-
param name="value" select="$head" />
0N/A </
xsl:
call-
template>
0N/A <
xsl:
value-
of select="' '" />
0N/A <
xsl:
call-
template name="name-to-ufn">
0N/A <
xsl:
with-
param name="value" select="$tail" />
0N/A </
xsl:
call-
template>
0N/A <
xsl:
call-
template name="to-title-case">
0N/A <
xsl:
with-
param name="value" select="$value" />
0N/A </
xsl:
call-
template>