You are viewing a plain text version of this content. The canonical link for it is here.
Posted to site-cvs@jakarta.apache.org by hl...@apache.org on 2005/10/31 16:32:38 UTC
svn commit: r329839 [4/4] - in /jakarta/site: ./ docs/site/ docs/site/news/
xdocs/stylesheets/ xdocs/stylesheets/xsltslt-1.2.1/
Added: jakarta/site/xdocs/stylesheets/xsltslt-1.2.1/string.xsl
URL: http://svn.apache.org/viewcvs/jakarta/site/xdocs/stylesheets/xsltslt-1.2.1/string.xsl?rev=329839&view=auto
==============================================================================
--- jakarta/site/xdocs/stylesheets/xsltslt-1.2.1/string.xsl (added)
+++ jakarta/site/xdocs/stylesheets/xsltslt-1.2.1/string.xsl Mon Oct 31 07:32:25 2005
@@ -0,0 +1,1233 @@
+<?xml version="1.0"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:doc="http://xsltsl.org/xsl/documentation/1.0"
+ xmlns:str="http://xsltsl.org/string"
+ extension-element-prefixes="doc str">
+
+ <doc:reference xmlns="">
+ <referenceinfo>
+ <releaseinfo role="meta">
+ $Id: string.xsl,v 1.13 2004/10/08 06:37:25 balls Exp $
+ </releaseinfo>
+ <author>
+ <surname>Ball</surname>
+ <firstname>Steve</firstname>
+ </author>
+ <copyright>
+ <year>2002</year>
+ <year>2001</year>
+ <holder>Steve Ball</holder>
+ </copyright>
+ </referenceinfo>
+
+ <title>String Processing</title>
+
+ <partintro>
+ <section>
+ <title>Introduction</title>
+
+ <para>This module provides templates for manipulating strings.</para>
+
+ </section>
+ </partintro>
+
+ </doc:reference>
+
+ <!-- Common string constants and datasets as XSL variables -->
+
+ <!-- str:lower and str:upper contain pairs of lower and upper case
+ characters. Below insanely long strings should contain the
+ official lower/uppercase pairs, making this stylesheet working
+ for every language on earth. Hopefully. -->
+ <!-- These values are not enough, however. There are some
+ exceptions, dealt with below. -->
+ <xsl:variable name="xsltsl-str-lower" select="'abcdefghijklmnopqrstuvwxyzµàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿāăąćĉċčďđēĕėęěĝğġģĥħĩīĭįıijĵķĺļľŀłńņňŋōŏőœŕŗřśŝşšţťŧũūŭůűųŵŷźżžſƃƅƈƌƒƕƙơƣƥƨƭưƴƶƹƽƿDždžLjljNjnjǎǐǒǔǖǘǚǜǝǟǡǣǥǧǩǫǭǯDzdzǵǹǻǽǿȁȃȅȇȉȋȍȏȑȓȕȗșțȝȟȣȥȧȩȫȭȯȱȳɓɔɖɗəɛɠɣɨɩɯɲɵʀʃʈʊʋʒͅάέήίαβγδεζηθικλμνξοπρςστυφχψωϊϋόύώϐϑϕϖϛϝϟϡϣϥϧϩϫϭϯϰϱϲϵабвгдежзийклмнопрстуфхцчшщъыьэюяѐёђѓєѕіїјљњћќѝўџѡѣѥѧѩѫѭѯѱѳѵѷѹѻѽѿҁҍҏґғҕҗҙқҝҟҡңҥҧҩҫҭүұҳҵҷҹһҽҿӂӄӈӌӑӓӕӗәӛӝӟӡӣӥӧөӫӭӯӱӳӵӹաբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆḁḃḅḇḉḋḍḏḑḓḕḗḙḛḝḟḡḣḥḧḩḫḭḯḱḳḵḷḹḻḽḿṁṃṅṇṉṋṍṏṑṓṕṗṙṛṝṟṡṣṥṧṩṫṭṯṱṳṵṷṹṻṽṿẁẃẅẇẉẋẍẏẑẓẕẛạảấầẩẫậắằẳẵặẹẻẽếềểễệỉịọỏốồổỗộớờởỡợụủứừửữựỳỵỷỹἀἁἂἃἄἅἆἇἐἑἒἓἔἕἠἡἢἣἤἥἦἧἰἱἲἳἴἵἶἷὀὁὂὃὄὅὑὓὕὗὠὡὢὣὤὥὦὧὰάὲέὴήὶίὸόὺύὼώᾀᾁᾂᾃᾄᾅᾆᾇᾐᾑᾒᾓᾔᾕᾖᾗᾠᾡᾢᾣᾤᾥᾦᾧᾰᾱᾳιῃῐῑῠῡῥῳⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹⅺⅻⅼⅽⅾⅿⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩabcdefghijklmnopqrstuvwxyz𐐨𐐩𐐪𐐫𐐬𐐭𐐮𐐯𐐰𐐱𐐲𐐳𐐴𐐵𐐶𐐷𐐸𐐹𐐺𐐻𐐼𐐽𐐾𐐿𐑀𐑁𐑂𐑃𐑄𐑅𐑆𐑇𐑈𐑉𐑊𐑋𐑌𐑍'"/>
+ <xsl:variable name="xsltsl-str-upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZΜÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞŸĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽSƂƄƇƋƑǶƘƠƢƤƧƬƯƳƵƸƼǷDŽDŽLJLJNJNJǍǏǑǓǕǗǙǛƎǞǠǢǤǦǨǪǬǮDZDZǴǸǺǼǾȀȂȄȆȈȊȌȎȐȒȔȖȘȚȜȞȢȤȦȨȪȬȮȰȲƁƆƉƊƏƐƓƔƗƖƜƝƟƦƩƮƱƲƷΙΆΈΉΊΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΣΤΥΦΧΨΩΪΫΌΎΏΒΘΦΠϚϜϞϠϢϤϦϨϪϬϮΚΡΣΕАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏѠѢѤѦѨѪѬѮѰѲѴѶѸѺѼѾҀҌҎҐҒҔҖҘҚҜҞҠҢҤҦҨҪҬҮҰҲҴҶҸҺҼҾӁӃӇӋӐӒӔӖӘӚӜӞӠӢӤӦӨӪӬӮӰӲӴӸԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖḀḂḄḆḈḊḌḎḐḒḔḖḘḚḜḞḠḢḤḦḨḪḬḮḰḲḴḶḸḺḼḾṀṂṄṆṈṊṌṎṐṒṔṖṘṚṜṞṠṢṤṦṨṪṬṮṰṲṴṶṸṺṼṾẀẂẄẆẈẊẌẎẐẒẔṠẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼẾỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴỶỸἈἉἊἋἌἍἎἏἘἙἚἛἜἝἨἩἪἫἬἭἮἯἸἹἺἻἼἽἾἿὈὉὊὋὌὍὙὛὝὟὨὩὪὫὬὭὮὯᾺΆῈΈῊΉῚΊῸΌῪΎῺΏᾈᾉᾊᾋᾌᾍᾎᾏᾘᾙᾚᾛᾜᾝᾞᾟᾨᾩᾪᾫᾬᾭᾮᾯᾸᾹᾼΙῌῘῙῨῩῬῼⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫⅬⅭⅮⅯⒶⒷⒸⒹⒺⒻⒼⒽⒾⒿⓀⓁⓂⓃⓄⓅⓆⓇⓈⓉⓊⓋⓌⓍⓎⓏABCDEFGHIJKLMNOPQRSTUVWXYZ𐐀𐐁𐐂𐐃𐐄𐐅𐐆𐐇𐐈𐐉𐐊𐐋𐐌𐐍𐐎𐐏𐐐𐐑𐐒𐐓𐐔𐐕𐐖𐐗𐐘𐐙𐐚𐐛𐐜𐐝𐐞𐐟𐐠𐐡𐐢𐐣𐐤𐐥'"/>
+ <xsl:variable name="xsltsl-str-digits" select="'0123456789'"/>
+ <!-- space (#x20) characters, carriage returns, line feeds, or tabs. -->
+ <xsl:variable name="xsltsl-str-ws" select="' 	
'"/>
+
+ <doc:template name="str:to-upper" xmlns="">
+ <refpurpose>Make string uppercase</refpurpose>
+
+ <refdescription>
+ <para>Converts all lowercase letters to uppercase.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The string to be converted</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns string with all uppercase letters.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="str:to-upper">
+ <xsl:param name="text"/>
+
+ <!-- Below exception is extracted from unicode's SpecialCasing.txt
+ file. It's the german lowercase "eszett" (the thing looking
+ like a greek beta) that's to become "SS" in uppercase (note:
+ that are *two* characters, that's why it doesn't fit in the
+ list of upper/lowercase characters). There are more
+ characters in that file (103, excluding the locale-specific
+ ones), but they seemed to be much less used to me and they
+ add up to a hellish long stylesheet.... - Reinout -->
+ <xsl:param name="modified-text">
+ <xsl:call-template name="str:subst">
+ <xsl:with-param name="text">
+ <xsl:value-of select="$text"/>
+ </xsl:with-param>
+ <xsl:with-param name="replace">
+ <xsl:text>ß</xsl:text>
+ </xsl:with-param>
+ <xsl:with-param name="with">
+ <xsl:text>S</xsl:text>
+ <xsl:text>S</xsl:text>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:param>
+
+ <xsl:value-of select="translate($modified-text, $xsltsl-str-lower, $xsltsl-str-upper)"/>
+ </xsl:template>
+
+ <doc:template name="str:to-lower" xmlns="">
+ <refpurpose>Make string lowercase</refpurpose>
+
+ <refdescription>
+ <para>Converts all uppercase letters to lowercase.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The string to be converted</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns string with all lowercase letters.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="str:to-lower">
+ <xsl:param name="text"/>
+
+ <xsl:value-of select="translate($text, $xsltsl-str-upper, $xsltsl-str-lower)"/>
+ </xsl:template>
+
+ <doc:template name="str:capitalise" xmlns="">
+ <refpurpose>Capitalise string</refpurpose>
+
+ <refdescription>
+ <para>Converts first character of string to an uppercase letter. All remaining characters are converted to lowercase.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The string to be capitalised</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>all</term>
+ <listitem>
+ <para>Boolean controlling whether all words in the string are capitalised.</para>
+ <para>Default is true.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns string with first character uppcase and all remaining characters lowercase.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="str:capitalise">
+ <xsl:param name="text"/>
+ <xsl:param name="all" select="true()"/>
+
+ <xsl:choose>
+ <xsl:when test="$all and (contains($text, ' ') or contains($text, ' ') or contains($text, ' '))">
+ <xsl:variable name="firstword">
+ <xsl:call-template name="str:substring-before-first">
+ <xsl:with-param name="text" select="$text"/>
+ <xsl:with-param name="chars" select="$xsltsl-str-ws"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:call-template name="str:capitalise">
+ <xsl:with-param name="text">
+ <xsl:value-of select="$firstword"/>
+ </xsl:with-param>
+ <xsl:with-param name="all" select="false()"/>
+ </xsl:call-template>
+ <xsl:value-of select="substring($text, string-length($firstword) + 1, 1)"/>
+ <xsl:call-template name="str:capitalise">
+ <xsl:with-param name="text">
+ <xsl:value-of select="substring($text, string-length($firstword) + 2)"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:call-template name="str:to-upper">
+ <xsl:with-param name="text" select="substring($text, 1, 1)"/>
+ </xsl:call-template>
+ <xsl:call-template name="str:to-lower">
+ <xsl:with-param name="text" select="substring($text, 2)"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="str:to-camelcase" xmlns="">
+ <refpurpose>Convert a string to one camelcase word</refpurpose>
+
+ <refdescription>
+ <para>Converts a string to one lowerCamelCase or UpperCamelCase
+ word, depending on the setting of the "upper"
+ parameter. UpperCamelCase is also called MixedCase while
+ lowerCamelCase is also called just camelCase. The template
+ removes any spaces, tabs and slashes, but doesn't deal with
+ other punctuation. It's purpose is to convert strings like
+ "hollow timber flush door" to a term suitable as identifier or
+ XML tag like "HollowTimberFlushDoor".
+ </para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The string to be capitalised</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>upper</term>
+ <listitem>
+ <para>Boolean controlling whether the string becomes an
+ UpperCamelCase word or a lowerCamelCase word.</para>
+ <para>Default is true.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns string with first character uppcase and all remaining characters lowercase.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="str:to-camelcase">
+ <xsl:param name="text"/>
+ <xsl:param name="upper" select="true()"/>
+ <!-- First change all 'strange' characters to spaces -->
+ <xsl:param name="string-with-only-spaces">
+ <xsl:value-of select="translate($text,concat($xsltsl-str-ws,'/'),' ')"/>
+ </xsl:param>
+ <!-- Then process them -->
+ <xsl:param name="before-space-removal">
+ <xsl:variable name="firstword">
+ <xsl:call-template name="str:substring-before-first">
+ <xsl:with-param name="text" select="$string-with-only-spaces"/>
+ <xsl:with-param name="chars" select="$xsltsl-str-ws"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$upper">
+ <xsl:call-template name="str:to-upper">
+ <xsl:with-param name="text" select="substring($firstword, 1, 1)"/>
+ </xsl:call-template>
+ <xsl:call-template name="str:to-lower">
+ <xsl:with-param name="text" select="substring($firstword, 2)"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="str:to-lower">
+ <xsl:with-param name="text" select="$firstword"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:call-template name="str:capitalise">
+ <xsl:with-param name="text">
+ <xsl:value-of select="substring($string-with-only-spaces, string-length($firstword) + 2)"/>
+ </xsl:with-param>
+ <xsl:with-param name="all" select="true()"/>
+ </xsl:call-template>
+ </xsl:param>
+ <xsl:value-of select="translate($before-space-removal,' ','')"/>
+ </xsl:template>
+
+ <doc:template name="str:substring-before-first" xmlns="">
+ <refpurpose>String extraction</refpurpose>
+
+ <refdescription>
+ <para>Extracts the portion of string 'text' which occurs before any of the characters in string 'chars'.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The string from which to extract a substring.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>chars</term>
+ <listitem>
+ <para>The string containing characters to find.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns string.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="str:substring-before-first">
+ <xsl:param name="text"/>
+ <xsl:param name="chars"/>
+
+ <xsl:choose>
+
+ <xsl:when test="string-length($text) = 0"/>
+
+ <xsl:when test="string-length($chars) = 0">
+ <xsl:value-of select="$text"/>
+ </xsl:when>
+
+ <xsl:when test="contains($text, substring($chars, 1, 1))">
+ <xsl:variable name="this" select="substring-before($text, substring($chars, 1, 1))"/>
+ <xsl:variable name="rest">
+ <xsl:call-template name="str:substring-before-first">
+ <xsl:with-param name="text" select="$text"/>
+ <xsl:with-param name="chars" select="substring($chars, 2)"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="string-length($this) < string-length($rest)">
+ <xsl:value-of select="$this"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$rest"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:call-template name="str:substring-before-first">
+ <xsl:with-param name="text" select="$text"/>
+ <xsl:with-param name="chars" select="substring($chars, 2)"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="str:substring-after-last" xmlns="">
+ <refpurpose>String extraction</refpurpose>
+
+ <refdescription>
+ <para>Extracts the portion of string 'text' which occurs after the last of the character in string 'chars'.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The string from which to extract a substring.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>chars</term>
+ <listitem>
+ <para>The string containing characters to find.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns string.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="str:substring-after-last">
+ <xsl:param name="text"/>
+ <xsl:param name="chars"/>
+
+ <xsl:choose>
+
+ <xsl:when test="contains($text, $chars)">
+ <xsl:variable name="last" select="substring-after($text, $chars)"/>
+
+ <xsl:choose>
+ <xsl:when test="contains($last, $chars)">
+ <xsl:call-template name="str:substring-after-last">
+ <xsl:with-param name="text" select="$last"/>
+ <xsl:with-param name="chars" select="$chars"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$last"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:value-of select="$text"/>
+ </xsl:otherwise>
+
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="str:substring-before-last" xmlns="">
+ <refpurpose>String extraction</refpurpose>
+
+ <refdescription>
+ <para>Extracts the portion of string 'text' which occurs before the first character of the last occurance of string 'chars'.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The string from which to extract a substring.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>chars</term>
+ <listitem>
+ <para>The string containing characters to find.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns string.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="str:substring-before-last">
+ <xsl:param name="text"/>
+ <xsl:param name="chars"/>
+
+ <xsl:choose>
+
+ <xsl:when test="string-length($text) = 0"/>
+
+ <xsl:when test="string-length($chars) = 0">
+ <xsl:value-of select="$text"/>
+ </xsl:when>
+
+ <xsl:when test="contains($text, $chars)">
+ <xsl:call-template name="str:substring-before-last-aux">
+ <xsl:with-param name="text" select="$text"/>
+ <xsl:with-param name="chars" select="$chars"/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:value-of select="$text"/>
+ </xsl:otherwise>
+
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="str:substring-before-last-aux">
+ <xsl:param name="text"/>
+ <xsl:param name="chars"/>
+
+ <xsl:choose>
+ <xsl:when test="string-length($text) = 0"/>
+
+ <xsl:when test="contains($text, $chars)">
+ <xsl:variable name="after">
+ <xsl:call-template name="str:substring-before-last-aux">
+ <xsl:with-param name="text" select="substring-after($text, $chars)"/>
+ <xsl:with-param name="chars" select="$chars"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:value-of select="substring-before($text, $chars)"/>
+ <xsl:if test="string-length($after) > 0">
+ <xsl:value-of select="$chars"/>
+ <xsl:copy-of select="$after"/>
+ </xsl:if>
+ </xsl:when>
+
+ <xsl:otherwise/>
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="str:subst" xmlns="">
+ <refpurpose>String substitution</refpurpose>
+
+ <refdescription>
+ <para>Substitute 'replace' for 'with' in string 'text'.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The string upon which to perform substitution.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>replace</term>
+ <listitem>
+ <para>The string to substitute.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>with</term>
+ <listitem>
+ <para>The string to be substituted.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>disable-output-escaping</term>
+ <listitem>
+ <para>A value of <literal>yes</literal> indicates that the result should have output escaping disabled. Any other value allows normal escaping of text values. The default is to enable output escaping.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns string.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="str:subst">
+ <xsl:param name="text"/>
+ <xsl:param name="replace"/>
+ <xsl:param name="with"/>
+ <xsl:param name='disable-output-escaping'>no</xsl:param>
+
+ <xsl:choose>
+ <xsl:when test="string-length($replace) = 0 and $disable-output-escaping = 'yes'">
+ <xsl:value-of select="$text" disable-output-escaping='yes'/>
+ </xsl:when>
+ <xsl:when test="string-length($replace) = 0">
+ <xsl:value-of select="$text"/>
+ </xsl:when>
+ <xsl:when test="contains($text, $replace)">
+
+ <xsl:variable name="before" select="substring-before($text, $replace)"/>
+ <xsl:variable name="after" select="substring-after($text, $replace)"/>
+
+ <xsl:choose>
+ <xsl:when test='$disable-output-escaping = "yes"'>
+ <xsl:value-of select="$before" disable-output-escaping="yes"/>
+ <xsl:value-of select="$with" disable-output-escaping="yes"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$before"/>
+ <xsl:value-of select="$with"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:call-template name="str:subst">
+ <xsl:with-param name="text" select="$after"/>
+ <xsl:with-param name="replace" select="$replace"/>
+ <xsl:with-param name="with" select="$with"/>
+ <xsl:with-param name="disable-output-escaping" select="$disable-output-escaping"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test='$disable-output-escaping = "yes"'>
+ <xsl:value-of select="$text" disable-output-escaping="yes"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$text"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="str:count-substring" xmlns="">
+ <refpurpose>Count Substrings</refpurpose>
+
+ <refdescription>
+ <para>Counts the number of times a substring occurs in a string. This can also counts the number of times a character occurs in a string, since a character is simply a string of length 1.</para>
+ </refdescription>
+
+ <example>
+ <title>Counting Lines</title>
+ <programlisting><![CDATA[
+<xsl:call-template name="str:count-substring">
+ <xsl:with-param name="text" select="$mytext"/>
+ <xsl:with-param name="chars" select="'
'"/>
+</xsl:call-template>
+]]></programlisting>
+ </example>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The source string.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>chars</term>
+ <listitem>
+ <para>The substring to count.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns a non-negative integer value.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="str:count-substring">
+ <xsl:param name="text"/>
+ <xsl:param name="chars"/>
+
+ <xsl:choose>
+ <xsl:when test="string-length($text) = 0 or string-length($chars) = 0">
+ <xsl:text>0</xsl:text>
+ </xsl:when>
+ <xsl:when test="contains($text, $chars)">
+ <xsl:variable name="remaining">
+ <xsl:call-template name="str:count-substring">
+ <xsl:with-param name="text" select="substring-after($text, $chars)"/>
+ <xsl:with-param name="chars" select="$chars"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:value-of select="$remaining + 1"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>0</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="str:substring-after-at" xmlns="">
+ <refpurpose>String extraction</refpurpose>
+ <refdescription>
+ <para>Extracts the portion of a 'char' delimited 'text' string "array" at a given 'position'.</para>
+ </refdescription>
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The string from which to extract a substring.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>chars</term>
+ <listitem>
+ <para>delimiters</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>position</term>
+ <listitem>
+ <para>position of the elements</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>all</term>
+ <listitem>
+ <para>If true all of the remaining string is returned, otherwise only the element at the given position is returned. Default: false().</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+ <refreturn>
+ <para>Returns string.</para>
+ </refreturn>
+ </doc:template>
+
+
+ <xsl:template name="str:substring-after-at">
+ <xsl:param name="text"/>
+ <xsl:param name="chars"/>
+ <xsl:param name="position"/>
+ <xsl:param name="all" select='false()'/>
+
+ <xsl:choose>
+ <xsl:when test='number($position) = 0 and $all'>
+ <xsl:value-of select='$text'/>
+ </xsl:when>
+ <xsl:when test='number($position) = 0 and not($chars)'>
+ <xsl:value-of select='$text'/>
+ </xsl:when>
+ <xsl:when test='number($position) = 0 and not(contains($text, $chars))'>
+ <xsl:value-of select='$text'/>
+ </xsl:when>
+ <xsl:when test='not(contains($text, $chars))'>
+ </xsl:when>
+ <xsl:when test="number($position) = 0">
+ <xsl:value-of select="substring-before($text, $chars)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="str:substring-after-at">
+ <xsl:with-param name="text" select="substring-after($text, $chars)"/>
+ <xsl:with-param name="chars" select="$chars"/>
+ <xsl:with-param name="all" select="$all"/>
+ <xsl:with-param name="position" select="$position - 1"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="str:substring-before-at" xmlns="">
+ <refpurpose>String extraction</refpurpose>
+ <refdescription>
+ <para>Extracts the portion of a 'char' delimited 'text' string "array" at a given 'position' </para>
+ </refdescription>
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The string from which to extract a substring.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>chars</term>
+ <listitem>
+ <para>delimiters</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>position</term>
+ <listitem>
+ <para>position of the elements</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+ <refreturn>
+ <para>Returns string.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="str:substring-before-at">
+ <xsl:param name="text"/>
+ <xsl:param name="chars"/>
+ <xsl:param name="position"/>
+
+ <xsl:choose>
+ <xsl:when test="$position <= 0"/>
+ <xsl:when test="not(contains($text, $chars))"/>
+ <xsl:otherwise>
+ <xsl:value-of select='substring-before($text, $chars)'/>
+ <xsl:value-of select='$chars'/>
+
+ <xsl:call-template name="str:substring-before-at">
+ <xsl:with-param name="text" select="substring-after($text, $chars)"/>
+ <xsl:with-param name="position" select="$position - 1"/>
+ <xsl:with-param name="chars" select="$chars"/>
+ </xsl:call-template>
+
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="str:insert-at" xmlns="">
+ <refpurpose>String insertion</refpurpose>
+ <refdescription>
+ <para>Insert 'chars' into "text' at any given "position'</para>
+ </refdescription>
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The string upon which to perform insertion</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>position</term>
+ <listitem>
+ <para>the position where insertion will be performed</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>with</term>
+ <listitem>
+ <para>The string to be inserted</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+ <refreturn>
+ <para>Returns string.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="str:insert-at">
+ <xsl:param name="text"/>
+ <xsl:param name="position"/>
+ <xsl:param name="chars"/>
+
+ <xsl:variable name="firstpart" select="substring($text, 0, $position)"/>
+ <xsl:variable name="secondpart" select="substring($text, $position, string-length($text))"/>
+
+ <xsl:value-of select="concat($firstpart, $chars, $secondpart)"/>
+ </xsl:template>
+
+
+ <doc:template name="str:backward" xmlns="">
+ <refpurpose>String reversal</refpurpose>
+
+ <refdescription>
+ <para>Reverse the content of a given string</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The string to be reversed</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns string.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="str:backward">
+ <xsl:param name="text"/>
+ <xsl:variable name="mirror">
+ <xsl:call-template name="str:build-mirror">
+ <xsl:with-param name="text" select="$text"/>
+ <xsl:with-param name="position" select="string-length($text)"/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:value-of select="substring($mirror, string-length($text) + 1, string-length($text))"/>
+ </xsl:template>
+
+ <xsl:template name="str:build-mirror">
+ <xsl:param name="text"/>
+ <xsl:param name="position"/>
+
+ <xsl:choose>
+ <xsl:when test="$position > 0">
+ <xsl:call-template name="str:build-mirror">
+ <xsl:with-param name="text" select="concat($text, substring($text, $position, 1))"/>
+ <xsl:with-param name="position" select="$position - 1"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$text"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="str:justify" xmlns="">
+ <refpurpose>Format a string</refpurpose>
+
+ <refdescription>
+ <para>Inserts newlines and spaces into a string to format it as a block of text.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>String to be formatted.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>max</term>
+ <listitem>
+ <para>Maximum line length.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>indent</term>
+ <listitem>
+ <para>Number of spaces to insert at the beginning of each line.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>justify</term>
+ <listitem>
+ <para>Justify left, right or both. Not currently implemented (fixed at "left").</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Formatted block of text.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name='str:justify'>
+ <xsl:param name='text'/>
+ <xsl:param name='max' select='"80"'/>
+ <xsl:param name='indent' select='"0"'/>
+ <xsl:param name='justify' select='"left"'/>
+
+ <xsl:choose>
+ <xsl:when test='string-length($text) = 0 or $max <= 0'/>
+
+ <xsl:when test='string-length($text) > $max and contains($text, " ") and string-length(substring-before($text, " ")) > $max'>
+ <xsl:call-template name='str:generate-string'>
+ <xsl:with-param name='text' select='" "'/>
+ <xsl:with-param name='count' select='$indent'/>
+ </xsl:call-template>
+ <xsl:value-of select='substring-before($text, " ")'/>
+ <xsl:text>
+</xsl:text>
+ <xsl:call-template name='str:justify'>
+ <xsl:with-param name='text' select='substring-after($text, " ")'/>
+ <xsl:with-param name='max' select='$max'/>
+ <xsl:with-param name='indent' select='$indent'/>
+ <xsl:with-param name='justify' select='$justify'/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <xsl:when test='string-length($text) > $max and contains($text, " ")'>
+ <xsl:variable name='first'>
+ <xsl:call-template name='str:substring-before-last'>
+ <xsl:with-param name='text' select='substring($text, 1, $max)'/>
+ <xsl:with-param name='chars' select='" "'/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:call-template name='str:generate-string'>
+ <xsl:with-param name='text' select='" "'/>
+ <xsl:with-param name='count' select='$indent'/>
+ </xsl:call-template>
+ <xsl:value-of select='$first'/>
+ <xsl:text>
+</xsl:text>
+ <xsl:call-template name='str:justify'>
+ <xsl:with-param name='text' select='substring($text, string-length($first) + 2)'/>
+ <xsl:with-param name='max' select='$max'/>
+ <xsl:with-param name='indent' select='$indent'/>
+ <xsl:with-param name='justify' select='$justify'/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:call-template name='str:generate-string'>
+ <xsl:with-param name='text' select='" "'/>
+ <xsl:with-param name='count' select='$indent'/>
+ </xsl:call-template>
+ <xsl:value-of select='$text'/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="str:character-first" xmlns="">
+ <refpurpose>Find first occurring character in a string</refpurpose>
+
+ <refdescription>
+ <para>Finds which of the given characters occurs first in a string.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The source string.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>chars</term>
+ <listitem>
+ <para>The characters to search for.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+ </doc:template>
+
+ <xsl:template name="str:character-first">
+ <xsl:param name="text"/>
+ <xsl:param name="chars"/>
+
+ <xsl:choose>
+ <xsl:when test="string-length($text) = 0 or string-length($chars) = 0"/>
+
+ <xsl:when test="contains($text, substring($chars, 1, 1))">
+ <xsl:variable name="next-character">
+ <xsl:call-template name="str:character-first">
+ <xsl:with-param name="text" select="$text"/>
+ <xsl:with-param name="chars" select="substring($chars, 2)"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="string-length($next-character)">
+ <xsl:variable name="first-character-position" select="string-length(substring-before($text, substring($chars, 1, 1)))"/>
+ <xsl:variable name="next-character-position" select="string-length(substring-before($text, $next-character))"/>
+
+ <xsl:choose>
+ <xsl:when test="$first-character-position < $next-character-position">
+ <xsl:value-of select="substring($chars, 1, 1)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$next-character"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="substring($chars, 1, 1)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="str:character-first">
+ <xsl:with-param name="text" select="$text"/>
+ <xsl:with-param name="chars" select="substring($chars, 2)"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <doc:template name="str:string-match" xmlns="">
+ <refpurpose>Match A String To A Pattern</refpurpose>
+
+ <refdescription>
+ <para>Performs globbing-style pattern matching on a string.</para>
+ </refdescription>
+
+ <example>
+ <title>Match Pattern</title>
+ <programlisting><![CDATA[
+<xsl:call-template name="str:string-match">
+ <xsl:with-param name="text" select="$mytext"/>
+ <xsl:with-param name="pattern" select="'abc*def?g'"/>
+</xsl:call-template>
+]]></programlisting>
+ </example>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The source string.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>pattern</term>
+ <listitem>
+ <para>The pattern to match against. Certain characters have special meaning:</para>
+ <variablelist>
+ <varlistentry>
+ <term>*</term>
+ <listitem>
+ <para>Matches zero or more characters.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>?</term>
+ <listitem>
+ <para>Matches a single character.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>\</term>
+ <listitem>
+ <para>Character escape. The next character is taken as a literal character.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns "1" if the string matches the pattern, "0" otherwise.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="str:string-match">
+ <xsl:param name="text"/>
+ <xsl:param name="pattern"/>
+
+ <xsl:choose>
+ <xsl:when test="$pattern = '*'">
+ <!-- Special case: always matches -->
+ <xsl:text>1</xsl:text>
+ </xsl:when>
+ <xsl:when test="string-length($text) = 0 and string-length($pattern) = 0">
+ <xsl:text>1</xsl:text>
+ </xsl:when>
+ <xsl:when test="string-length($text) = 0 or string-length($pattern) = 0">
+ <xsl:text>0</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:variable name='before-special'>
+ <xsl:call-template name='str:substring-before-first'>
+ <xsl:with-param name='text' select='$pattern'/>
+ <xsl:with-param name='chars' select='"*?\"'/>
+ </xsl:call-template>
+ </xsl:variable>
+ <xsl:variable name='special'>
+ <xsl:call-template name='str:character-first'>
+ <xsl:with-param name='text' select='$pattern'/>
+ <xsl:with-param name='chars' select='"*?\"'/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name='new-text' select='substring($text, string-length($before-special) + 1)'/>
+ <xsl:variable name='new-pattern' select='substring($pattern, string-length($before-special) + 1)'/>
+
+ <xsl:choose>
+ <xsl:when test="not(starts-with($text, $before-special))">
+ <!-- Verbatim characters don't match -->
+ <xsl:text>0</xsl:text>
+ </xsl:when>
+
+ <xsl:when test="$special = '*' and string-length($new-pattern) = 1">
+ <xsl:text>1</xsl:text>
+ </xsl:when>
+ <xsl:when test="$special = '*'">
+ <xsl:call-template name='str:match-postfix'>
+ <xsl:with-param name='text' select='$new-text'/>
+ <xsl:with-param name='pattern' select='substring($new-pattern, 2)'/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <xsl:when test="$special = '?'">
+ <xsl:call-template name="str:string-match">
+ <xsl:with-param name='text' select='substring($new-text, 2)'/>
+ <xsl:with-param name='pattern' select='substring($new-pattern, 2)'/>
+ </xsl:call-template>
+ </xsl:when>
+
+ <xsl:when test="$special = '\' and substring($new-text, 1, 1) = substring($new-pattern, 2, 1)">
+ <xsl:call-template name="str:string-match">
+ <xsl:with-param name='text' select='substring($new-text, 2)'/>
+ <xsl:with-param name='pattern' select='substring($new-pattern, 3)'/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="$special = '\' and substring($new-text, 1, 1) != substring($new-pattern, 2, 1)">
+ <xsl:text>0</xsl:text>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <!-- There were no special characters in the pattern -->
+ <xsl:choose>
+ <xsl:when test='$text = $pattern'>
+ <xsl:text>1</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>0</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="str:match-postfix">
+ <xsl:param name="text"/>
+ <xsl:param name="pattern"/>
+
+ <xsl:variable name='result'>
+ <xsl:call-template name='str:string-match'>
+ <xsl:with-param name='text' select='$text'/>
+ <xsl:with-param name='pattern' select='$pattern'/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test='$result = "1"'>
+ <xsl:value-of select='$result'/>
+ </xsl:when>
+ <xsl:when test='string-length($text) = 0'>
+ <xsl:text>0</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name='str:match-postfix'>
+ <xsl:with-param name='text' select='substring($text, 2)'/>
+ <xsl:with-param name='pattern' select='$pattern'/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ </xsl:template>
+
+ <doc:template name="str:generate-string" xmlns="">
+ <refpurpose>Create A Repeating Sequence of Characters</refpurpose>
+
+ <refdescription>
+ <para>Repeats a string a given number of times.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>text</term>
+ <listitem>
+ <para>The string to repeat.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>count</term>
+ <listitem>
+ <para>The number of times to repeat the string.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+ </doc:template>
+
+ <xsl:template name="str:generate-string">
+ <xsl:param name="text"/>
+ <xsl:param name="count"/>
+
+ <xsl:choose>
+ <xsl:when test="string-length($text) = 0 or $count <= 0"/>
+ <xsl:otherwise>
+ <xsl:value-of select="$text"/>
+ <xsl:call-template name="str:generate-string">
+ <xsl:with-param name="text" select="$text"/>
+ <xsl:with-param name="count" select="$count - 1"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+</xsl:stylesheet>
+
Added: jakarta/site/xdocs/stylesheets/xsltslt-1.2.1/svg.xsl
URL: http://svn.apache.org/viewcvs/jakarta/site/xdocs/stylesheets/xsltslt-1.2.1/svg.xsl?rev=329839&view=auto
==============================================================================
--- jakarta/site/xdocs/stylesheets/xsltslt-1.2.1/svg.xsl (added)
+++ jakarta/site/xdocs/stylesheets/xsltslt-1.2.1/svg.xsl Mon Oct 31 07:32:25 2005
@@ -0,0 +1 @@
+<xsl:stylesheet version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:svg='http://xsltsl.org/svg'
xmlns:doc="http://xsltsl.org/xsl/documentation/1.0"
exclude-result-prefixes="doc">
<xsl:variable name='svg-public-id' select='"-//W3C//DTD SVG 20010904//EN"'/>
<xsl:variable name='svg-system-id' select='"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"'/>
<doc:reference xmlns="">
<referenceinfo>
<releaseinfo role="meta">
$Id: svg.xsl,v 1.1 2003/03/31 21:07:35 balls Exp $
</releaseinfo>
<author>
<surname>Ball</surname>
<firstname>Steve</firstname>
</author>
<copyright>
<year>2002</year>
<holder>Steve Ball</holder>
</copyright>
</referenceinfo>
<title>SVG Stylesheet</title>
<partintro>
<section>
<title>Introduction</title>
<para>This module provides templates for creating SVG images.</para>
</section>
</partintro>
</doc:reference>
<doc:template name="svg:aqua-button-defs" xmlns="">
<refpurpose>Aqua-style Button</refpurpose>
<refdescription>
<para>Part of the mechanism to create an Aqua-style button. Include a call to this template in your SVG document's <sgmltag>defs</sgmltag> element. This template only needs to be included once. Use this in conjunction with <sgmltag>svg:aqua-button</sgmltag>.</para>
<para>The default values for color1, color2 and color3 result in a grey button.</para>
</refdescription>
<refparameter>
<variablelist>
<varlistentry>
<term>prefix</term>
<listitem>
<para>A prefix to append to the identifiers used, so that they don't clash with other identifiers. Default: "aqua-".</para>
</listitem>
</varlistentry>
<varlistentry>
<term>color1</term>
<listitem>
<para>The base colour of the button. Default: "#d9d9d9".</para>
</listitem>
</varlistentry>
<varlistentry>
<term>color2</term>
<listitem>
<para>A "background" colour for the button. Should be a darker colour than color1. Default: "#a9a9a9".</para>
</listitem>
</varlistentry>
<varlistentry>
<term>color3</term>
<listitem>
<para>A highlight colour for the button. Should be a lighter colour than color1. Default: "#f9f9f9".</para>
</listitem>
</varlistentry>
</variablelist>
</refparameter>
<refreturn>
<para>Returns SVG result-tree-fragment.</para>
</refreturn>
</doc:template>
<xsl:template name="svg:aqua-button-defs">
<xsl:param name="prefix" select='"aqua-"'/>
<xsl:param name="color1" select='"#d9d9d9"'/>
<xsl:param name="color2" select='"#a9a9a9"'/>
<xsl:param name="color3" select='"#f9f9f9"'/>
<linearGradient id='{$prefix}gradient' x1='0%' y1='0%' x2='0%' y2='100%'>
<stop offset='0%' stop-color='{$color2}'/>
<stop offset='100%' stop-color='{$color1}'/>
</linearGradient>
<linearGradient id='{$prefix}highlight-gradient' x1='0%' y1='0%' x2='0%' y2='100%'>
<stop offset='0%' stop-color='#ffffff'/>
<stop offset='75%' stop-color='{$color3}' stop-opacity='0'/>
<stop offset='100%' stop-color='{$color3}' stop-opacity='0'/>
</linearGradient>
<linearGradient id='{$prefix}revhighlight-gradient' x1='0%' y1='100%' x2='0%' y2='0%'>
<stop offset='0%' stop-color='#ffffff'/>
<stop offset='50%' stop-color='{$color3}' stop-opacity='0'/>
<stop offset='100%' stop-color='{$color3}' stop-opacity='0'/>
</linearGradient>
<linearGradient id='{$prefix}corner-left-gradient' x1='0%' y1='0%' x2='100%' y2='100%'>
<stop offset='0%' stop-color='#000000'/>
<stop offset='100%' stop-color='{$color3}' stop-opacity='0'/>
</linearGradient>
<linearGradient id='{$prefix}corner-right-gradient' x1='100%' y1='0%' x2='0%' y2='100%'>
<stop offset='0%' stop-color='#000000'/>
<stop offset='100%' stop-color='{$color3}' stop-opacity='0'/>
</linearGradient>
<filter id='{$prefix}filter-blur' filterUnits='userSpaceOnUse' x='0' y='0' width='200' height='100'>
<feGaussianBlur in='SourceGraphic' stdDeviation='2'/>
</filter>
<filter id='{$prefix}drop-shadow' y='-5' height='100'>
<feColorMatrix type='matrix' in='SourceAlpha' result='inglow'
values='.5 .5 .5 1 0
.5 .5 .5 1 0
.5 .5 .5 1 0
0 0 0 1 0'/>
<feBlend mode='multiply' in2='SourceGraphic' in='inglow' result='innerglow'/>
<feGaussianBlur stdDeviation='4' in='SourceAlpha' result='shadow'/>
<feColorMatrix type='matrix' in='shadow' result='lightshadow'
values='.33 .33 .33 1 0
.33 .33 .33 1 0
.33 .33 .33 1 0
0 0 0 1 0'/>
<feOffset in='lightshadow' dx='0' dy='3' result='dropshadow'/>
<feMerge>
<feMergeNode in='dropshadow'/>
<feMergeNode in='innerglow'/>
</feMerge>
</filter>
</xsl:template>
<doc:template name="svg:aqua-button" xmlns="">
<refpurpose>Aqua-style Button</refpurpose>
<refdescription>
<para>Part of the mechanism to create an Aqua-style button. Include a call to this template in your SVG document where you want a button to appear. This template can be used many times in a single SVG document. Use this in conjunction with <sgmltag>svg:aqua-button-defs</sgmltag>.</para>
</refdescription>
<refparameter>
<variablelist>
<varlistentry>
<term>prefix</term>
<listitem>
<para>A prefix to append to the identifiers used, so that they don't clash with other identifiers. Default: "aqua-".</para>
</listitem>
</varlistentry>
</variablelist>
</refparameter>
<refreturn>
<para>Returns SVG result-tree-fragment.</para>
</refreturn>
</doc:template>
<xsl:template name='svg:aqua-button'>
<xsl:param name="prefix" select='"aqua-"'/>
<g filter='url(#{$prefix}drop-shadow)'>
<clipPath id='{$prefix}main-shape'>
<path clip-rule='evenodd'
d="M50,90 C0,90 0,30 50,30 L150,30 C200,30 200,90 150,90 z" />
</clipPath>
<path fill="url(#{$prefix}gradient)" stroke="none"
d="M50,90 C0,90 0,30 50,30 L150,30 C200,30 200,90 150,90 z" />
<path clip-path='url(#{$prefix}main-shape)' fill='url(#{$prefix}corner-left-gradient)' stroke='none' filter='url(#{$prefix}filter-blur)'
d="M50,57 L13,57 A35,35 -90 0,1 50,30 z" />
<path clip-path='url(#{$prefix}main-shape)' fill='url(#{$prefix}corner-right-gradient)' stroke='none' filter='url(#{$prefix}filter-blur)'
d="M150,30 A35,35 90 0,1 190,57 L150,57 z" />
<path fill="url(#{$prefix}highlight-gradient)" stroke="none" stroke-width='1'
d="M50,65 C20,65 20,35 50,35 L150,35 C180,35 180,65 150,65 z" />
<path filter='url(#{$prefix}filter-blur)' fill="url(#{$prefix}revhighlight-gradient)" stroke="none"
d="M50,85 C10,85 10,35 50,35 L150,35 C190,35 190,85 150,85 z" />
</g>
</xsl:template>
</xsl:stylesheet>
\ No newline at end of file
Added: jakarta/site/xdocs/stylesheets/xsltslt-1.2.1/uri.xsl
URL: http://svn.apache.org/viewcvs/jakarta/site/xdocs/stylesheets/xsltslt-1.2.1/uri.xsl?rev=329839&view=auto
==============================================================================
--- jakarta/site/xdocs/stylesheets/xsltslt-1.2.1/uri.xsl (added)
+++ jakarta/site/xdocs/stylesheets/xsltslt-1.2.1/uri.xsl Mon Oct 31 07:32:25 2005
@@ -0,0 +1,580 @@
+<?xml version="1.0"?>
+
+<xsl:stylesheet
+ version="1.0"
+ extension-element-prefixes="doc"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:doc="http://xsltsl.org/xsl/documentation/1.0"
+ xmlns:uri="http://xsltsl.org/uri"
+>
+
+ <doc:reference xmlns="">
+ <referenceinfo>
+ <releaseinfo role="meta">
+ $Id: uri.xsl,v 1.6 2002/01/11 22:07:08 injektilo Exp $
+ </releaseinfo>
+ <author>
+ <surname>Diamond</surname>
+ <firstname>Jason</firstname>
+ </author>
+ <copyright>
+ <year>2001</year>
+ <holder>Jason Diamond</holder>
+ </copyright>
+ </referenceinfo>
+
+ <title>URI (Uniform Resource Identifier) Processing</title>
+
+ <partintro>
+ <section>
+ <title>Introduction</title>
+ <para>This module provides templates for processing URIs (Uniform Resource Identifers).</para>
+ </section>
+ </partintro>
+
+ </doc:reference>
+
+ <doc:template name="uri:is-absolute-uri" xmlns="">
+ <refpurpose>Determines if a URI is absolute or relative.</refpurpose>
+
+ <refdescription>
+ <para>Absolute URIs start with a scheme (like "http:" or "mailto:").</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>uri</term>
+ <listitem>
+ <para>An absolute or relative URI.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns 'true' if the URI is absolute or '' if it's not.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="uri:is-absolute-uri">
+ <xsl:param name="uri"/>
+
+ <xsl:if test="contains($uri, ':')">
+ <xsl:value-of select="true()"/>
+ </xsl:if>
+
+ </xsl:template>
+
+ <doc:template name="uri:get-uri-scheme" xmlns="">
+ <refpurpose>Gets the scheme part of a URI.</refpurpose>
+
+ <refdescription>
+ <para>The ':' is not part of the scheme.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>uri</term>
+ <listitem>
+ <para>An absolute or relative URI.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns the scheme (without the ':') or '' if the URI is relative.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="uri:get-uri-scheme">
+ <xsl:param name="uri"/>
+ <xsl:if test="contains($uri, ':')">
+ <xsl:value-of select="substring-before($uri, ':')"/>
+ </xsl:if>
+ </xsl:template>
+
+ <doc:template name="uri:get-uri-authority" xmlns="">
+ <refpurpose>Gets the authority part of a URI.</refpurpose>
+
+ <refdescription>
+ <para>The authority usually specifies the host machine for a resource. It always follows '//' in a typical URI.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>uri</term>
+ <listitem>
+ <para>An absolute or relative URI.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns the authority (without the '//') or '' if the URI has no authority.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="uri:get-uri-authority">
+ <xsl:param name="uri"/>
+
+ <xsl:variable name="a">
+ <xsl:choose>
+ <xsl:when test="contains($uri, ':')">
+ <xsl:if test="substring(substring-after($uri, ':'), 1, 2) = '//'">
+ <xsl:value-of select="substring(substring-after($uri, ':'), 3)"/>
+ </xsl:if>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:if test="substring($uri, 1, 2) = '//'">
+ <xsl:value-of select="substring($uri, 3)"/>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="contains($a, '/')">
+ <xsl:value-of select="substring-before($a, '/')" />
+ </xsl:when>
+ <xsl:when test="contains($a, '?')">
+ <xsl:value-of select="substring-before($a, '?')" />
+ </xsl:when>
+ <xsl:when test="contains($a, '#')">
+ <xsl:value-of select="substring-before($a, '#')" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$a" />
+ </xsl:otherwise>
+ </xsl:choose>
+
+ </xsl:template>
+
+ <doc:template name="uri:get-uri-path" xmlns="">
+ <refpurpose>Gets the path part of a URI.</refpurpose>
+
+ <refdescription>
+ <para>The path usually comes after the '/' in a URI.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>uri</term>
+ <listitem>
+ <para>An absolute or relative URI.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns the path (with any leading '/') or '' if the URI has no path.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="uri:get-uri-path">
+ <xsl:param name="uri"/>
+
+ <xsl:variable name="p">
+ <xsl:choose>
+ <xsl:when test="contains($uri, '//')">
+ <xsl:if test="contains(substring-after($uri, '//'), '/')">
+ <xsl:value-of select="concat('/', substring-after(substring-after($uri, '//'), '/'))"/>
+ </xsl:if>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="contains($uri, ':')">
+ <xsl:value-of select="substring-after($uri, ':')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$uri"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="contains($p, '?')">
+ <xsl:value-of select="substring-before($p, '?')" />
+ </xsl:when>
+ <xsl:when test="contains($p, '#')">
+ <xsl:value-of select="substring-before($p, '#')" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$p" />
+ </xsl:otherwise>
+ </xsl:choose>
+
+ </xsl:template>
+
+ <doc:template name="uri:get-uri-query" xmlns="">
+ <refpurpose>Gets the query part of a URI.</refpurpose>
+
+ <refdescription>
+ <para>The query comes after the '?' in a URI.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>uri</term>
+ <listitem>
+ <para>An absolute or relative URI.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns the query (without the '?') or '' if the URI has no query.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="uri:get-uri-query">
+ <xsl:param name="uri"/>
+
+ <xsl:variable name="q" select="substring-after($uri, '?')"/>
+
+ <xsl:choose>
+ <xsl:when test="contains($q, '#')">
+ <xsl:value-of select="substring-before($q, '#')"/>
+ </xsl:when>
+ <xsl:otherwise><xsl:value-of select="$q"/></xsl:otherwise>
+ </xsl:choose>
+
+ </xsl:template>
+
+ <doc:template name="uri:get-uri-fragment" xmlns="">
+ <refpurpose>Gets the fragment part of a URI.</refpurpose>
+
+ <refdescription>
+ <para>The fragment comes after the '#' in a URI.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>uri</term>
+ <listitem>
+ <para>An absolute or relative URI.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>Returns the fragment (without the '#') or '' if the URI has no fragment.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="uri:get-uri-fragment">
+ <xsl:param name="uri"/>
+
+ <xsl:value-of select="substring-after($uri, '#')"/>
+
+ </xsl:template>
+
+ <doc:template name="uri:resolve-uri" xmlns="">
+ <refpurpose>Resolves a URI reference against a base URI.</refpurpose>
+
+ <refdescription>
+ <para>This template follows the guidelines specified by <ulink url="ftp://ftp.isi.edu/in-notes/rfc2396.txt">RFC 2396</ulink>.</para>
+ </refdescription>
+
+ <refparameter>
+ <variablelist>
+ <varlistentry>
+ <term>reference</term>
+ <listitem>
+ <para>A (potentially relative) URI reference.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>base</term>
+ <listitem>
+ <para>The base URI.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>document</term>
+ <listitem>
+ <para>The URI of the current document. This defaults to the value of the base URI if not specified.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refparameter>
+
+ <refreturn>
+ <para>The "combined" URI.</para>
+ </refreturn>
+ </doc:template>
+
+ <xsl:template name="uri:resolve-uri">
+ <xsl:param name="reference"/>
+ <xsl:param name="base"/>
+ <xsl:param name="document" select="$base"/>
+
+ <xsl:variable name="reference-scheme">
+ <xsl:call-template name="uri:get-uri-scheme">
+ <xsl:with-param name="uri" select="$reference"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="reference-authority">
+ <xsl:call-template name="uri:get-uri-authority">
+ <xsl:with-param name="uri" select="$reference"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="reference-path">
+ <xsl:call-template name="uri:get-uri-path">
+ <xsl:with-param name="uri" select="$reference"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="reference-query">
+ <xsl:call-template name="uri:get-uri-query">
+ <xsl:with-param name="uri" select="$reference"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="reference-fragment">
+ <xsl:call-template name="uri:get-uri-fragment">
+ <xsl:with-param name="uri" select="$reference"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:choose>
+
+ <xsl:when test="
+ not(string-length($reference-scheme)) and
+ not(string-length($reference-authority)) and
+ not(string-length($reference-path)) and
+ not(string-length($reference-query))"
+ >
+
+ <xsl:choose>
+ <xsl:when test="contains($document, '?')">
+ <xsl:value-of select="substring-before($document, '?')"/>
+ </xsl:when>
+ <xsl:when test="contains($document, '#')">
+ <xsl:value-of select="substring-before($document, '#')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$document"/>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <xsl:if test="string-length($reference-fragment)">
+ <xsl:value-of select="concat('#', $reference-fragment)"/>
+ </xsl:if>
+
+ </xsl:when>
+
+ <xsl:when test="string-length($reference-scheme)">
+
+ <xsl:value-of select="$reference"/>
+
+ </xsl:when>
+
+ <xsl:otherwise>
+
+ <xsl:variable name="base-scheme">
+ <xsl:call-template name="uri:get-uri-scheme">
+ <xsl:with-param name="uri" select="$base"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="base-authority">
+ <xsl:call-template name="uri:get-uri-authority">
+ <xsl:with-param name="uri" select="$base"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="base-path">
+ <xsl:call-template name="uri:get-uri-path">
+ <xsl:with-param name="uri" select="$base"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="base-query">
+ <xsl:call-template name="uri:get-uri-query">
+ <xsl:with-param name="uri" select="$base"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="base-fragment">
+ <xsl:call-template name="uri:get-uri-fragment">
+ <xsl:with-param name="uri" select="$base"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="result-authority">
+ <xsl:choose>
+ <xsl:when test="string-length($reference-authority)">
+ <xsl:value-of select="$reference-authority"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$base-authority"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:variable name="result-path">
+ <xsl:choose>
+ <!-- don't normalize absolute paths -->
+ <xsl:when test="starts-with($reference-path, '/')">
+ <xsl:value-of select="$reference-path" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="uri:normalize-path">
+ <xsl:with-param name="path">
+ <xsl:if test="string-length($reference-authority) = 0 and substring($reference-path, 1, 1) != '/'">
+ <xsl:call-template name="uri:get-path-without-file">
+ <xsl:with-param name="path-with-file" select="$base-path"/>
+ </xsl:call-template>
+ <xsl:value-of select="'/'"/>
+ </xsl:if>
+ <xsl:value-of select="$reference-path"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:value-of select="concat($base-scheme, '://', $result-authority, $result-path)"/>
+
+ <xsl:if test="string-length($reference-query)">
+ <xsl:value-of select="concat('?', $reference-query)"/>
+ </xsl:if>
+
+ <xsl:if test="string-length($reference-fragment)">
+ <xsl:value-of select="concat('#', $reference-fragment)"/>
+ </xsl:if>
+
+ </xsl:otherwise>
+ </xsl:choose>
+
+ </xsl:template>
+
+ <xsl:template name="uri:get-path-without-file">
+ <xsl:param name="path-with-file" />
+ <xsl:param name="path-without-file" />
+
+ <xsl:choose>
+ <xsl:when test="contains($path-with-file, '/')">
+ <xsl:call-template name="uri:get-path-without-file">
+ <xsl:with-param name="path-with-file" select="substring-after($path-with-file, '/')" />
+ <xsl:with-param name="path-without-file">
+ <xsl:choose>
+ <xsl:when test="$path-without-file">
+ <xsl:value-of select="concat($path-without-file, '/', substring-before($path-with-file, '/'))" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="substring-before($path-with-file, '/')" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$path-without-file" />
+ </xsl:otherwise>
+ </xsl:choose>
+
+ </xsl:template>
+
+ <xsl:template name="uri:normalize-path">
+ <xsl:param name="path"/>
+ <xsl:param name="result" select="''"/>
+
+ <xsl:choose>
+ <xsl:when test="string-length($path)">
+ <xsl:choose>
+ <xsl:when test="$path = '/'">
+ <xsl:value-of select="concat($result, '/')"/>
+ </xsl:when>
+ <xsl:when test="$path = '.'">
+ <xsl:value-of select="concat($result, '/')"/>
+ </xsl:when>
+ <xsl:when test="$path = '..'">
+ <xsl:call-template name="uri:get-path-without-file">
+ <xsl:with-param name="path-with-file" select="$result"/>
+ </xsl:call-template>
+ <xsl:value-of select="'/'"/>
+ </xsl:when>
+ <xsl:when test="contains($path, '/')">
+ <!-- the current segment -->
+ <xsl:variable name="s" select="substring-before($path, '/')"/>
+ <!-- the remaining path -->
+ <xsl:variable name="p">
+ <xsl:choose>
+ <xsl:when test="substring-after($path, '/') = ''">
+ <xsl:value-of select="'/'"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="substring-after($path, '/')"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="$s = ''">
+ <xsl:call-template name="uri:normalize-path">
+ <xsl:with-param name="path" select="$p"/>
+ <xsl:with-param name="result" select="$result"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="$s = '.'">
+ <xsl:call-template name="uri:normalize-path">
+ <xsl:with-param name="path" select="$p"/>
+ <xsl:with-param name="result" select="$result"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="$s = '..'">
+ <xsl:choose>
+ <xsl:when test="string-length($result) and (substring($result, string-length($result) - 2) != '/..')">
+ <xsl:call-template name="uri:normalize-path">
+ <xsl:with-param name="path" select="$p"/>
+ <xsl:with-param name="result">
+ <xsl:call-template name="uri:get-path-without-file">
+ <xsl:with-param name="path-with-file" select="$result"/>
+ </xsl:call-template>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="uri:normalize-path">
+ <xsl:with-param name="path" select="$p"/>
+ <xsl:with-param name="result" select="concat($result, '/..')"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="uri:normalize-path">
+ <xsl:with-param name="path" select="$p"/>
+ <xsl:with-param name="result" select="concat($result, '/', $s)"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="concat($result, '/', $path)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$result"/>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ </xsl:template>
+
+</xsl:stylesheet>
---------------------------------------------------------------------
To unsubscribe, e-mail: site-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: site-cvs-help@jakarta.apache.org