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