pretrim.xsl revision b93889871ef8513dd6bb00a0f05bfb7df326a21b
456de5f26ad346749963525a4f91883e6a51c5f3gryzor<?xml version="1.0"?>
456de5f26ad346749963525a4f91883e6a51c5f3gryzor
456de5f26ad346749963525a4f91883e6a51c5f3gryzor<!--
456de5f26ad346749963525a4f91883e6a51c5f3gryzor Licensed to the Apache Software Foundation (ASF) under one or more
456de5f26ad346749963525a4f91883e6a51c5f3gryzor contributor license agreements. See the NOTICE file distributed with
456de5f26ad346749963525a4f91883e6a51c5f3gryzor this work for additional information regarding copyright ownership.
456de5f26ad346749963525a4f91883e6a51c5f3gryzor The ASF licenses this file to You under the Apache License, Version 2.0
96ad5d81ee4a2cc66a4ae19893efc8aa6d06fae7jailletc (the "License"); you may not use this file except in compliance with
456de5f26ad346749963525a4f91883e6a51c5f3gryzor the License. You may obtain a copy of the License at
456de5f26ad346749963525a4f91883e6a51c5f3gryzor
456de5f26ad346749963525a4f91883e6a51c5f3gryzor http://www.apache.org/licenses/LICENSE-2.0
2e545ce2450a9953665f701bb05350f0d3f26275nd
456de5f26ad346749963525a4f91883e6a51c5f3gryzor Unless required by applicable law or agreed to in writing, software
456de5f26ad346749963525a4f91883e6a51c5f3gryzor distributed under the License is distributed on an "AS IS" BASIS,
456de5f26ad346749963525a4f91883e6a51c5f3gryzor WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
456de5f26ad346749963525a4f91883e6a51c5f3gryzor See the License for the specific language governing permissions and
456de5f26ad346749963525a4f91883e6a51c5f3gryzor limitations under the License.
456de5f26ad346749963525a4f91883e6a51c5f3gryzor-->
456de5f26ad346749963525a4f91883e6a51c5f3gryzor
456de5f26ad346749963525a4f91883e6a51c5f3gryzor<xsl:stylesheet version="1.0"
456de5f26ad346749963525a4f91883e6a51c5f3gryzor xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
456de5f26ad346749963525a4f91883e6a51c5f3gryzor
456de5f26ad346749963525a4f91883e6a51c5f3gryzor<!-- load utility snippets -->
456de5f26ad346749963525a4f91883e6a51c5f3gryzor<xsl:include href="string-reverse.xsl" />
456de5f26ad346749963525a4f91883e6a51c5f3gryzor
456de5f26ad346749963525a4f91883e6a51c5f3gryzor
456de5f26ad346749963525a4f91883e6a51c5f3gryzor<!-- strip empty lines at the beginning -->
456de5f26ad346749963525a4f91883e6a51c5f3gryzor<xsl:template name="pre-ltrim">
456de5f26ad346749963525a4f91883e6a51c5f3gryzor<xsl:param name="string" />
456de5f26ad346749963525a4f91883e6a51c5f3gryzor
456de5f26ad346749963525a4f91883e6a51c5f3gryzor<xsl:variable name="lspace">
456de5f26ad346749963525a4f91883e6a51c5f3gryzor <xsl:call-template name="string-reverse">
456de5f26ad346749963525a4f91883e6a51c5f3gryzor <xsl:with-param name="string" select="substring-before($string, substring(normalize-space($string), 1, 1))" />
456de5f26ad346749963525a4f91883e6a51c5f3gryzor </xsl:call-template>
456de5f26ad346749963525a4f91883e6a51c5f3gryzor</xsl:variable>
456de5f26ad346749963525a4f91883e6a51c5f3gryzor
456de5f26ad346749963525a4f91883e6a51c5f3gryzor<xsl:choose>
456de5f26ad346749963525a4f91883e6a51c5f3gryzor<xsl:when test="contains($lspace, '&#x0a;')">
456de5f26ad346749963525a4f91883e6a51c5f3gryzor <xsl:value-of select="substring(
456de5f26ad346749963525a4f91883e6a51c5f3gryzor $string,
456de5f26ad346749963525a4f91883e6a51c5f3gryzor 1 + string-length($lspace)
456de5f26ad346749963525a4f91883e6a51c5f3gryzor - string-length(substring-before($lspace, '&#x0a;')),
456de5f26ad346749963525a4f91883e6a51c5f3gryzor string-length($string)
456de5f26ad346749963525a4f91883e6a51c5f3gryzor )" />
456de5f26ad346749963525a4f91883e6a51c5f3gryzor</xsl:when>
456de5f26ad346749963525a4f91883e6a51c5f3gryzor<xsl:otherwise>
456de5f26ad346749963525a4f91883e6a51c5f3gryzor <xsl:value-of select="$string" />
456de5f26ad346749963525a4f91883e6a51c5f3gryzor</xsl:otherwise>
456de5f26ad346749963525a4f91883e6a51c5f3gryzor</xsl:choose>
456de5f26ad346749963525a4f91883e6a51c5f3gryzor</xsl:template>
456de5f26ad346749963525a4f91883e6a51c5f3gryzor
456de5f26ad346749963525a4f91883e6a51c5f3gryzor<!-- strip whitespace at the end -->
456de5f26ad346749963525a4f91883e6a51c5f3gryzor<xsl:template name="pre-rtrim">
456de5f26ad346749963525a4f91883e6a51c5f3gryzor<xsl:param name="string" />
456de5f26ad346749963525a4f91883e6a51c5f3gryzor
456de5f26ad346749963525a4f91883e6a51c5f3gryzor<xsl:variable name="rev">
456de5f26ad346749963525a4f91883e6a51c5f3gryzor <xsl:call-template name="string-reverse">
456de5f26ad346749963525a4f91883e6a51c5f3gryzor <xsl:with-param name="string" select="$string" />
456de5f26ad346749963525a4f91883e6a51c5f3gryzor </xsl:call-template>
456de5f26ad346749963525a4f91883e6a51c5f3gryzor</xsl:variable>
456de5f26ad346749963525a4f91883e6a51c5f3gryzor
456de5f26ad346749963525a4f91883e6a51c5f3gryzor<xsl:call-template name="string-reverse">
456de5f26ad346749963525a4f91883e6a51c5f3gryzor <xsl:with-param name="string" select="substring(
456de5f26ad346749963525a4f91883e6a51c5f3gryzor $rev,
456de5f26ad346749963525a4f91883e6a51c5f3gryzor 1 + string-length(substring-before(
456de5f26ad346749963525a4f91883e6a51c5f3gryzor $rev, substring(normalize-space($rev), 1, 1)
456de5f26ad346749963525a4f91883e6a51c5f3gryzor )),
456de5f26ad346749963525a4f91883e6a51c5f3gryzor string-length($rev)
456de5f26ad346749963525a4f91883e6a51c5f3gryzor )" />
456de5f26ad346749963525a4f91883e6a51c5f3gryzor</xsl:call-template>
456de5f26ad346749963525a4f91883e6a51c5f3gryzor</xsl:template>
456de5f26ad346749963525a4f91883e6a51c5f3gryzor
456de5f26ad346749963525a4f91883e6a51c5f3gryzor
456de5f26ad346749963525a4f91883e6a51c5f3gryzor</xsl:stylesheet>
456de5f26ad346749963525a4f91883e6a51c5f3gryzor