VirtualBox

source: vbox/trunk/doc/manual/string.xsl

Last change on this file was 69482, checked in by vboxsync, 7 years ago

manual: scm updates

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 49.0 KB
Line 
1<?xml version="1.0"?>
2
3<!-- This file is taken from the XSLT Standard Library as available
4 from http://xsltsl.sourceforge.net/. Except for this notice, it
5 has not been modified. -->
6
7<xsl:stylesheet version="1.0"
8 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
9 xmlns:doc="http://xsltsl.org/xsl/documentation/1.0"
10 xmlns:str="http://xsltsl.org/string"
11 extension-element-prefixes="doc str">
12
13 <doc:reference xmlns="">
14 <referenceinfo>
15 <releaseinfo role="meta">
16 $Id: string.xsl 69482 2017-10-28 13:30:36Z vboxsync $
17 </releaseinfo>
18 <author>
19 <surname>Ball</surname>
20 <firstname>Steve</firstname>
21 </author>
22 <copyright>
23 <year>2002</year>
24 <year>2001</year>
25 <holder>Steve Ball</holder>
26 </copyright>
27 </referenceinfo>
28
29 <title>String Processing</title>
30
31 <partintro>
32 <section>
33 <title>Introduction</title>
34
35 <para>This module provides templates for manipulating strings.</para>
36
37 </section>
38 </partintro>
39
40 </doc:reference>
41
42 <!-- Common string constants and datasets as XSL variables -->
43
44 <!-- str:lower and str:upper contain pairs of lower and upper case
45 characters. Below insanely long strings should contain the
46 official lower/uppercase pairs, making this stylesheet working
47 for every language on earth. Hopefully. -->
48 <!-- These values are not enough, however. There are some
49 exceptions, dealt with below. -->
50 <xsl:variable name="xsltsl-str-lower" select="'&#x0061;&#x0062;&#x0063;&#x0064;&#x0065;&#x0066;&#x0067;&#x0068;&#x0069;&#x006A;&#x006B;&#x006C;&#x006D;&#x006E;&#x006F;&#x0070;&#x0071;&#x0072;&#x0073;&#x0074;&#x0075;&#x0076;&#x0077;&#x0078;&#x0079;&#x007A;&#x00B5;&#x00E0;&#x00E1;&#x00E2;&#x00E3;&#x00E4;&#x00E5;&#x00E6;&#x00E7;&#x00E8;&#x00E9;&#x00EA;&#x00EB;&#x00EC;&#x00ED;&#x00EE;&#x00EF;&#x00F0;&#x00F1;&#x00F2;&#x00F3;&#x00F4;&#x00F5;&#x00F6;&#x00F8;&#x00F9;&#x00FA;&#x00FB;&#x00FC;&#x00FD;&#x00FE;&#x00FF;&#x0101;&#x0103;&#x0105;&#x0107;&#x0109;&#x010B;&#x010D;&#x010F;&#x0111;&#x0113;&#x0115;&#x0117;&#x0119;&#x011B;&#x011D;&#x011F;&#x0121;&#x0123;&#x0125;&#x0127;&#x0129;&#x012B;&#x012D;&#x012F;&#x0131;&#x0133;&#x0135;&#x0137;&#x013A;&#x013C;&#x013E;&#x0140;&#x0142;&#x0144;&#x0146;&#x0148;&#x014B;&#x014D;&#x014F;&#x0151;&#x0153;&#x0155;&#x0157;&#x0159;&#x015B;&#x015D;&#x015F;&#x0161;&#x0163;&#x0165;&#x0167;&#x0169;&#x016B;&#x016D;&#x016F;&#x0171;&#x0173;&#x0175;&#x0177;&#x017A;&#x017C;&#x017E;&#x017F;&#x0183;&#x0185;&#x0188;&#x018C;&#x0192;&#x0195;&#x0199;&#x01A1;&#x01A3;&#x01A5;&#x01A8;&#x01AD;&#x01B0;&#x01B4;&#x01B6;&#x01B9;&#x01BD;&#x01BF;&#x01C5;&#x01C6;&#x01C8;&#x01C9;&#x01CB;&#x01CC;&#x01CE;&#x01D0;&#x01D2;&#x01D4;&#x01D6;&#x01D8;&#x01DA;&#x01DC;&#x01DD;&#x01DF;&#x01E1;&#x01E3;&#x01E5;&#x01E7;&#x01E9;&#x01EB;&#x01ED;&#x01EF;&#x01F2;&#x01F3;&#x01F5;&#x01F9;&#x01FB;&#x01FD;&#x01FF;&#x0201;&#x0203;&#x0205;&#x0207;&#x0209;&#x020B;&#x020D;&#x020F;&#x0211;&#x0213;&#x0215;&#x0217;&#x0219;&#x021B;&#x021D;&#x021F;&#x0223;&#x0225;&#x0227;&#x0229;&#x022B;&#x022D;&#x022F;&#x0231;&#x0233;&#x0253;&#x0254;&#x0256;&#x0257;&#x0259;&#x025B;&#x0260;&#x0263;&#x0268;&#x0269;&#x026F;&#x0272;&#x0275;&#x0280;&#x0283;&#x0288;&#x028A;&#x028B;&#x0292;&#x0345;&#x03AC;&#x03AD;&#x03AE;&#x03AF;&#x03B1;&#x03B2;&#x03B3;&#x03B4;&#x03B5;&#x03B6;&#x03B7;&#x03B8;&#x03B9;&#x03BA;&#x03BB;&#x03BC;&#x03BD;&#x03BE;&#x03BF;&#x03C0;&#x03C1;&#x03C2;&#x03C3;&#x03C4;&#x03C5;&#x03C6;&#x03C7;&#x03C8;&#x03C9;&#x03CA;&#x03CB;&#x03CC;&#x03CD;&#x03CE;&#x03D0;&#x03D1;&#x03D5;&#x03D6;&#x03DB;&#x03DD;&#x03DF;&#x03E1;&#x03E3;&#x03E5;&#x03E7;&#x03E9;&#x03EB;&#x03ED;&#x03EF;&#x03F0;&#x03F1;&#x03F2;&#x03F5;&#x0430;&#x0431;&#x0432;&#x0433;&#x0434;&#x0435;&#x0436;&#x0437;&#x0438;&#x0439;&#x043A;&#x043B;&#x043C;&#x043D;&#x043E;&#x043F;&#x0440;&#x0441;&#x0442;&#x0443;&#x0444;&#x0445;&#x0446;&#x0447;&#x0448;&#x0449;&#x044A;&#x044B;&#x044C;&#x044D;&#x044E;&#x044F;&#x0450;&#x0451;&#x0452;&#x0453;&#x0454;&#x0455;&#x0456;&#x0457;&#x0458;&#x0459;&#x045A;&#x045B;&#x045C;&#x045D;&#x045E;&#x045F;&#x0461;&#x0463;&#x0465;&#x0467;&#x0469;&#x046B;&#x046D;&#x046F;&#x0471;&#x0473;&#x0475;&#x0477;&#x0479;&#x047B;&#x047D;&#x047F;&#x0481;&#x048D;&#x048F;&#x0491;&#x0493;&#x0495;&#x0497;&#x0499;&#x049B;&#x049D;&#x049F;&#x04A1;&#x04A3;&#x04A5;&#x04A7;&#x04A9;&#x04AB;&#x04AD;&#x04AF;&#x04B1;&#x04B3;&#x04B5;&#x04B7;&#x04B9;&#x04BB;&#x04BD;&#x04BF;&#x04C2;&#x04C4;&#x04C8;&#x04CC;&#x04D1;&#x04D3;&#x04D5;&#x04D7;&#x04D9;&#x04DB;&#x04DD;&#x04DF;&#x04E1;&#x04E3;&#x04E5;&#x04E7;&#x04E9;&#x04EB;&#x04ED;&#x04EF;&#x04F1;&#x04F3;&#x04F5;&#x04F9;&#x0561;&#x0562;&#x0563;&#x0564;&#x0565;&#x0566;&#x0567;&#x0568;&#x0569;&#x056A;&#x056B;&#x056C;&#x056D;&#x056E;&#x056F;&#x0570;&#x0571;&#x0572;&#x0573;&#x0574;&#x0575;&#x0576;&#x0577;&#x0578;&#x0579;&#x057A;&#x057B;&#x057C;&#x057D;&#x057E;&#x057F;&#x0580;&#x0581;&#x0582;&#x0583;&#x0584;&#x0585;&#x0586;&#x1E01;&#x1E03;&#x1E05;&#x1E07;&#x1E09;&#x1E0B;&#x1E0D;&#x1E0F;&#x1E11;&#x1E13;&#x1E15;&#x1E17;&#x1E19;&#x1E1B;&#x1E1D;&#x1E1F;&#x1E21;&#x1E23;&#x1E25;&#x1E27;&#x1E29;&#x1E2B;&#x1E2D;&#x1E2F;&#x1E31;&#x1E33;&#x1E35;&#x1E37;&#x1E39;&#x1E3B;&#x1E3D;&#x1E3F;&#x1E41;&#x1E43;&#x1E45;&#x1E47;&#x1E49;&#x1E4B;&#x1E4D;&#x1E4F;&#x1E51;&#x1E53;&#x1E55;&#x1E57;&#x1E59;&#x1E5B;&#x1E5D;&#x1E5F;&#x1E61;&#x1E63;&#x1E65;&#x1E67;&#x1E69;&#x1E6B;&#x1E6D;&#x1E6F;&#x1E71;&#x1E73;&#x1E75;&#x1E77;&#x1E79;&#x1E7B;&#x1E7D;&#x1E7F;&#x1E81;&#x1E83;&#x1E85;&#x1E87;&#x1E89;&#x1E8B;&#x1E8D;&#x1E8F;&#x1E91;&#x1E93;&#x1E95;&#x1E9B;&#x1EA1;&#x1EA3;&#x1EA5;&#x1EA7;&#x1EA9;&#x1EAB;&#x1EAD;&#x1EAF;&#x1EB1;&#x1EB3;&#x1EB5;&#x1EB7;&#x1EB9;&#x1EBB;&#x1EBD;&#x1EBF;&#x1EC1;&#x1EC3;&#x1EC5;&#x1EC7;&#x1EC9;&#x1ECB;&#x1ECD;&#x1ECF;&#x1ED1;&#x1ED3;&#x1ED5;&#x1ED7;&#x1ED9;&#x1EDB;&#x1EDD;&#x1EDF;&#x1EE1;&#x1EE3;&#x1EE5;&#x1EE7;&#x1EE9;&#x1EEB;&#x1EED;&#x1EEF;&#x1EF1;&#x1EF3;&#x1EF5;&#x1EF7;&#x1EF9;&#x1F00;&#x1F01;&#x1F02;&#x1F03;&#x1F04;&#x1F05;&#x1F06;&#x1F07;&#x1F10;&#x1F11;&#x1F12;&#x1F13;&#x1F14;&#x1F15;&#x1F20;&#x1F21;&#x1F22;&#x1F23;&#x1F24;&#x1F25;&#x1F26;&#x1F27;&#x1F30;&#x1F31;&#x1F32;&#x1F33;&#x1F34;&#x1F35;&#x1F36;&#x1F37;&#x1F40;&#x1F41;&#x1F42;&#x1F43;&#x1F44;&#x1F45;&#x1F51;&#x1F53;&#x1F55;&#x1F57;&#x1F60;&#x1F61;&#x1F62;&#x1F63;&#x1F64;&#x1F65;&#x1F66;&#x1F67;&#x1F70;&#x1F71;&#x1F72;&#x1F73;&#x1F74;&#x1F75;&#x1F76;&#x1F77;&#x1F78;&#x1F79;&#x1F7A;&#x1F7B;&#x1F7C;&#x1F7D;&#x1F80;&#x1F81;&#x1F82;&#x1F83;&#x1F84;&#x1F85;&#x1F86;&#x1F87;&#x1F90;&#x1F91;&#x1F92;&#x1F93;&#x1F94;&#x1F95;&#x1F96;&#x1F97;&#x1FA0;&#x1FA1;&#x1FA2;&#x1FA3;&#x1FA4;&#x1FA5;&#x1FA6;&#x1FA7;&#x1FB0;&#x1FB1;&#x1FB3;&#x1FBE;&#x1FC3;&#x1FD0;&#x1FD1;&#x1FE0;&#x1FE1;&#x1FE5;&#x1FF3;&#x2170;&#x2171;&#x2172;&#x2173;&#x2174;&#x2175;&#x2176;&#x2177;&#x2178;&#x2179;&#x217A;&#x217B;&#x217C;&#x217D;&#x217E;&#x217F;&#x24D0;&#x24D1;&#x24D2;&#x24D3;&#x24D4;&#x24D5;&#x24D6;&#x24D7;&#x24D8;&#x24D9;&#x24DA;&#x24DB;&#x24DC;&#x24DD;&#x24DE;&#x24DF;&#x24E0;&#x24E1;&#x24E2;&#x24E3;&#x24E4;&#x24E5;&#x24E6;&#x24E7;&#x24E8;&#x24E9;&#xFF41;&#xFF42;&#xFF43;&#xFF44;&#xFF45;&#xFF46;&#xFF47;&#xFF48;&#xFF49;&#xFF4A;&#xFF4B;&#xFF4C;&#xFF4D;&#xFF4E;&#xFF4F;&#xFF50;&#xFF51;&#xFF52;&#xFF53;&#xFF54;&#xFF55;&#xFF56;&#xFF57;&#xFF58;&#xFF59;&#xFF5A;&#x10428;&#x10429;&#x1042A;&#x1042B;&#x1042C;&#x1042D;&#x1042E;&#x1042F;&#x10430;&#x10431;&#x10432;&#x10433;&#x10434;&#x10435;&#x10436;&#x10437;&#x10438;&#x10439;&#x1043A;&#x1043B;&#x1043C;&#x1043D;&#x1043E;&#x1043F;&#x10440;&#x10441;&#x10442;&#x10443;&#x10444;&#x10445;&#x10446;&#x10447;&#x10448;&#x10449;&#x1044A;&#x1044B;&#x1044C;&#x1044D;'"/>
51 <xsl:variable name="xsltsl-str-upper" select="'&#x0041;&#x0042;&#x0043;&#x0044;&#x0045;&#x0046;&#x0047;&#x0048;&#x0049;&#x004A;&#x004B;&#x004C;&#x004D;&#x004E;&#x004F;&#x0050;&#x0051;&#x0052;&#x0053;&#x0054;&#x0055;&#x0056;&#x0057;&#x0058;&#x0059;&#x005A;&#x039C;&#x00C0;&#x00C1;&#x00C2;&#x00C3;&#x00C4;&#x00C5;&#x00C6;&#x00C7;&#x00C8;&#x00C9;&#x00CA;&#x00CB;&#x00CC;&#x00CD;&#x00CE;&#x00CF;&#x00D0;&#x00D1;&#x00D2;&#x00D3;&#x00D4;&#x00D5;&#x00D6;&#x00D8;&#x00D9;&#x00DA;&#x00DB;&#x00DC;&#x00DD;&#x00DE;&#x0178;&#x0100;&#x0102;&#x0104;&#x0106;&#x0108;&#x010A;&#x010C;&#x010E;&#x0110;&#x0112;&#x0114;&#x0116;&#x0118;&#x011A;&#x011C;&#x011E;&#x0120;&#x0122;&#x0124;&#x0126;&#x0128;&#x012A;&#x012C;&#x012E;&#x0049;&#x0132;&#x0134;&#x0136;&#x0139;&#x013B;&#x013D;&#x013F;&#x0141;&#x0143;&#x0145;&#x0147;&#x014A;&#x014C;&#x014E;&#x0150;&#x0152;&#x0154;&#x0156;&#x0158;&#x015A;&#x015C;&#x015E;&#x0160;&#x0162;&#x0164;&#x0166;&#x0168;&#x016A;&#x016C;&#x016E;&#x0170;&#x0172;&#x0174;&#x0176;&#x0179;&#x017B;&#x017D;&#x0053;&#x0182;&#x0184;&#x0187;&#x018B;&#x0191;&#x01F6;&#x0198;&#x01A0;&#x01A2;&#x01A4;&#x01A7;&#x01AC;&#x01AF;&#x01B3;&#x01B5;&#x01B8;&#x01BC;&#x01F7;&#x01C4;&#x01C4;&#x01C7;&#x01C7;&#x01CA;&#x01CA;&#x01CD;&#x01CF;&#x01D1;&#x01D3;&#x01D5;&#x01D7;&#x01D9;&#x01DB;&#x018E;&#x01DE;&#x01E0;&#x01E2;&#x01E4;&#x01E6;&#x01E8;&#x01EA;&#x01EC;&#x01EE;&#x01F1;&#x01F1;&#x01F4;&#x01F8;&#x01FA;&#x01FC;&#x01FE;&#x0200;&#x0202;&#x0204;&#x0206;&#x0208;&#x020A;&#x020C;&#x020E;&#x0210;&#x0212;&#x0214;&#x0216;&#x0218;&#x021A;&#x021C;&#x021E;&#x0222;&#x0224;&#x0226;&#x0228;&#x022A;&#x022C;&#x022E;&#x0230;&#x0232;&#x0181;&#x0186;&#x0189;&#x018A;&#x018F;&#x0190;&#x0193;&#x0194;&#x0197;&#x0196;&#x019C;&#x019D;&#x019F;&#x01A6;&#x01A9;&#x01AE;&#x01B1;&#x01B2;&#x01B7;&#x0399;&#x0386;&#x0388;&#x0389;&#x038A;&#x0391;&#x0392;&#x0393;&#x0394;&#x0395;&#x0396;&#x0397;&#x0398;&#x0399;&#x039A;&#x039B;&#x039C;&#x039D;&#x039E;&#x039F;&#x03A0;&#x03A1;&#x03A3;&#x03A3;&#x03A4;&#x03A5;&#x03A6;&#x03A7;&#x03A8;&#x03A9;&#x03AA;&#x03AB;&#x038C;&#x038E;&#x038F;&#x0392;&#x0398;&#x03A6;&#x03A0;&#x03DA;&#x03DC;&#x03DE;&#x03E0;&#x03E2;&#x03E4;&#x03E6;&#x03E8;&#x03EA;&#x03EC;&#x03EE;&#x039A;&#x03A1;&#x03A3;&#x0395;&#x0410;&#x0411;&#x0412;&#x0413;&#x0414;&#x0415;&#x0416;&#x0417;&#x0418;&#x0419;&#x041A;&#x041B;&#x041C;&#x041D;&#x041E;&#x041F;&#x0420;&#x0421;&#x0422;&#x0423;&#x0424;&#x0425;&#x0426;&#x0427;&#x0428;&#x0429;&#x042A;&#x042B;&#x042C;&#x042D;&#x042E;&#x042F;&#x0400;&#x0401;&#x0402;&#x0403;&#x0404;&#x0405;&#x0406;&#x0407;&#x0408;&#x0409;&#x040A;&#x040B;&#x040C;&#x040D;&#x040E;&#x040F;&#x0460;&#x0462;&#x0464;&#x0466;&#x0468;&#x046A;&#x046C;&#x046E;&#x0470;&#x0472;&#x0474;&#x0476;&#x0478;&#x047A;&#x047C;&#x047E;&#x0480;&#x048C;&#x048E;&#x0490;&#x0492;&#x0494;&#x0496;&#x0498;&#x049A;&#x049C;&#x049E;&#x04A0;&#x04A2;&#x04A4;&#x04A6;&#x04A8;&#x04AA;&#x04AC;&#x04AE;&#x04B0;&#x04B2;&#x04B4;&#x04B6;&#x04B8;&#x04BA;&#x04BC;&#x04BE;&#x04C1;&#x04C3;&#x04C7;&#x04CB;&#x04D0;&#x04D2;&#x04D4;&#x04D6;&#x04D8;&#x04DA;&#x04DC;&#x04DE;&#x04E0;&#x04E2;&#x04E4;&#x04E6;&#x04E8;&#x04EA;&#x04EC;&#x04EE;&#x04F0;&#x04F2;&#x04F4;&#x04F8;&#x0531;&#x0532;&#x0533;&#x0534;&#x0535;&#x0536;&#x0537;&#x0538;&#x0539;&#x053A;&#x053B;&#x053C;&#x053D;&#x053E;&#x053F;&#x0540;&#x0541;&#x0542;&#x0543;&#x0544;&#x0545;&#x0546;&#x0547;&#x0548;&#x0549;&#x054A;&#x054B;&#x054C;&#x054D;&#x054E;&#x054F;&#x0550;&#x0551;&#x0552;&#x0553;&#x0554;&#x0555;&#x0556;&#x1E00;&#x1E02;&#x1E04;&#x1E06;&#x1E08;&#x1E0A;&#x1E0C;&#x1E0E;&#x1E10;&#x1E12;&#x1E14;&#x1E16;&#x1E18;&#x1E1A;&#x1E1C;&#x1E1E;&#x1E20;&#x1E22;&#x1E24;&#x1E26;&#x1E28;&#x1E2A;&#x1E2C;&#x1E2E;&#x1E30;&#x1E32;&#x1E34;&#x1E36;&#x1E38;&#x1E3A;&#x1E3C;&#x1E3E;&#x1E40;&#x1E42;&#x1E44;&#x1E46;&#x1E48;&#x1E4A;&#x1E4C;&#x1E4E;&#x1E50;&#x1E52;&#x1E54;&#x1E56;&#x1E58;&#x1E5A;&#x1E5C;&#x1E5E;&#x1E60;&#x1E62;&#x1E64;&#x1E66;&#x1E68;&#x1E6A;&#x1E6C;&#x1E6E;&#x1E70;&#x1E72;&#x1E74;&#x1E76;&#x1E78;&#x1E7A;&#x1E7C;&#x1E7E;&#x1E80;&#x1E82;&#x1E84;&#x1E86;&#x1E88;&#x1E8A;&#x1E8C;&#x1E8E;&#x1E90;&#x1E92;&#x1E94;&#x1E60;&#x1EA0;&#x1EA2;&#x1EA4;&#x1EA6;&#x1EA8;&#x1EAA;&#x1EAC;&#x1EAE;&#x1EB0;&#x1EB2;&#x1EB4;&#x1EB6;&#x1EB8;&#x1EBA;&#x1EBC;&#x1EBE;&#x1EC0;&#x1EC2;&#x1EC4;&#x1EC6;&#x1EC8;&#x1ECA;&#x1ECC;&#x1ECE;&#x1ED0;&#x1ED2;&#x1ED4;&#x1ED6;&#x1ED8;&#x1EDA;&#x1EDC;&#x1EDE;&#x1EE0;&#x1EE2;&#x1EE4;&#x1EE6;&#x1EE8;&#x1EEA;&#x1EEC;&#x1EEE;&#x1EF0;&#x1EF2;&#x1EF4;&#x1EF6;&#x1EF8;&#x1F08;&#x1F09;&#x1F0A;&#x1F0B;&#x1F0C;&#x1F0D;&#x1F0E;&#x1F0F;&#x1F18;&#x1F19;&#x1F1A;&#x1F1B;&#x1F1C;&#x1F1D;&#x1F28;&#x1F29;&#x1F2A;&#x1F2B;&#x1F2C;&#x1F2D;&#x1F2E;&#x1F2F;&#x1F38;&#x1F39;&#x1F3A;&#x1F3B;&#x1F3C;&#x1F3D;&#x1F3E;&#x1F3F;&#x1F48;&#x1F49;&#x1F4A;&#x1F4B;&#x1F4C;&#x1F4D;&#x1F59;&#x1F5B;&#x1F5D;&#x1F5F;&#x1F68;&#x1F69;&#x1F6A;&#x1F6B;&#x1F6C;&#x1F6D;&#x1F6E;&#x1F6F;&#x1FBA;&#x1FBB;&#x1FC8;&#x1FC9;&#x1FCA;&#x1FCB;&#x1FDA;&#x1FDB;&#x1FF8;&#x1FF9;&#x1FEA;&#x1FEB;&#x1FFA;&#x1FFB;&#x1F88;&#x1F89;&#x1F8A;&#x1F8B;&#x1F8C;&#x1F8D;&#x1F8E;&#x1F8F;&#x1F98;&#x1F99;&#x1F9A;&#x1F9B;&#x1F9C;&#x1F9D;&#x1F9E;&#x1F9F;&#x1FA8;&#x1FA9;&#x1FAA;&#x1FAB;&#x1FAC;&#x1FAD;&#x1FAE;&#x1FAF;&#x1FB8;&#x1FB9;&#x1FBC;&#x0399;&#x1FCC;&#x1FD8;&#x1FD9;&#x1FE8;&#x1FE9;&#x1FEC;&#x1FFC;&#x2160;&#x2161;&#x2162;&#x2163;&#x2164;&#x2165;&#x2166;&#x2167;&#x2168;&#x2169;&#x216A;&#x216B;&#x216C;&#x216D;&#x216E;&#x216F;&#x24B6;&#x24B7;&#x24B8;&#x24B9;&#x24BA;&#x24BB;&#x24BC;&#x24BD;&#x24BE;&#x24BF;&#x24C0;&#x24C1;&#x24C2;&#x24C3;&#x24C4;&#x24C5;&#x24C6;&#x24C7;&#x24C8;&#x24C9;&#x24CA;&#x24CB;&#x24CC;&#x24CD;&#x24CE;&#x24CF;&#xFF21;&#xFF22;&#xFF23;&#xFF24;&#xFF25;&#xFF26;&#xFF27;&#xFF28;&#xFF29;&#xFF2A;&#xFF2B;&#xFF2C;&#xFF2D;&#xFF2E;&#xFF2F;&#xFF30;&#xFF31;&#xFF32;&#xFF33;&#xFF34;&#xFF35;&#xFF36;&#xFF37;&#xFF38;&#xFF39;&#xFF3A;&#x10400;&#x10401;&#x10402;&#x10403;&#x10404;&#x10405;&#x10406;&#x10407;&#x10408;&#x10409;&#x1040A;&#x1040B;&#x1040C;&#x1040D;&#x1040E;&#x1040F;&#x10410;&#x10411;&#x10412;&#x10413;&#x10414;&#x10415;&#x10416;&#x10417;&#x10418;&#x10419;&#x1041A;&#x1041B;&#x1041C;&#x1041D;&#x1041E;&#x1041F;&#x10420;&#x10421;&#x10422;&#x10423;&#x10424;&#x10425;'"/>
52 <xsl:variable name="xsltsl-str-digits" select="'0123456789'"/>
53 <!-- space (#x20) characters, carriage returns, line feeds, or tabs. -->
54 <xsl:variable name="xsltsl-str-ws" select="'&#x20;&#x9;&#xD;&#xA;'"/>
55
56 <doc:template name="str:to-upper" xmlns="">
57 <refpurpose>Make string uppercase</refpurpose>
58
59 <refdescription>
60 <para>Converts all lowercase letters to uppercase.</para>
61 </refdescription>
62
63 <refparameter>
64 <variablelist>
65 <varlistentry>
66 <term>text</term>
67 <listitem>
68 <para>The string to be converted</para>
69 </listitem>
70 </varlistentry>
71 </variablelist>
72 </refparameter>
73
74 <refreturn>
75 <para>Returns string with all uppercase letters.</para>
76 </refreturn>
77 </doc:template>
78
79 <xsl:template name="str:to-upper">
80 <xsl:param name="text"/>
81
82 <!-- Below exception is extracted from unicode's SpecialCasing.txt
83 file. It's the german lowercase "eszett" (the thing looking
84 like a greek beta) that's to become "SS" in uppercase (note:
85 that are *two* characters, that's why it doesn't fit in the
86 list of upper/lowercase characters). There are more
87 characters in that file (103, excluding the locale-specific
88 ones), but they seemed to be much less used to me and they
89 add up to a hellish long stylesheet.... - Reinout -->
90 <xsl:param name="modified-text">
91 <xsl:call-template name="str:subst">
92 <xsl:with-param name="text">
93 <xsl:value-of select="$text"/>
94 </xsl:with-param>
95 <xsl:with-param name="replace">
96 <xsl:text>&#x00DF;</xsl:text>
97 </xsl:with-param>
98 <xsl:with-param name="with">
99 <xsl:text>&#x0053;</xsl:text>
100 <xsl:text>&#x0053;</xsl:text>
101 </xsl:with-param>
102 </xsl:call-template>
103 </xsl:param>
104
105 <xsl:value-of select="translate($modified-text, $xsltsl-str-lower, $xsltsl-str-upper)"/>
106 </xsl:template>
107
108 <doc:template name="str:to-lower" xmlns="">
109 <refpurpose>Make string lowercase</refpurpose>
110
111 <refdescription>
112 <para>Converts all uppercase letters to lowercase.</para>
113 </refdescription>
114
115 <refparameter>
116 <variablelist>
117 <varlistentry>
118 <term>text</term>
119 <listitem>
120 <para>The string to be converted</para>
121 </listitem>
122 </varlistentry>
123 </variablelist>
124 </refparameter>
125
126 <refreturn>
127 <para>Returns string with all lowercase letters.</para>
128 </refreturn>
129 </doc:template>
130
131 <xsl:template name="str:to-lower">
132 <xsl:param name="text"/>
133
134 <xsl:value-of select="translate($text, $xsltsl-str-upper, $xsltsl-str-lower)"/>
135 </xsl:template>
136
137 <doc:template name="str:capitalise" xmlns="">
138 <refpurpose>Capitalise string</refpurpose>
139
140 <refdescription>
141 <para>Converts first character of string to an uppercase letter. All remaining characters are converted to lowercase.</para>
142 </refdescription>
143
144 <refparameter>
145 <variablelist>
146 <varlistentry>
147 <term>text</term>
148 <listitem>
149 <para>The string to be capitalised</para>
150 </listitem>
151 </varlistentry>
152 <varlistentry>
153 <term>all</term>
154 <listitem>
155 <para>Boolean controlling whether all words in the string are capitalised.</para>
156 <para>Default is true.</para>
157 </listitem>
158 </varlistentry>
159 </variablelist>
160 </refparameter>
161
162 <refreturn>
163 <para>Returns string with first character uppcase and all remaining characters lowercase.</para>
164 </refreturn>
165 </doc:template>
166
167 <xsl:template name="str:capitalise">
168 <xsl:param name="text"/>
169 <xsl:param name="all" select="true()"/>
170
171 <xsl:choose>
172 <xsl:when test="$all and (contains($text, ' ') or contains($text, ' ') or contains($text, '&#10;'))">
173 <xsl:variable name="firstword">
174 <xsl:call-template name="str:substring-before-first">
175 <xsl:with-param name="text" select="$text"/>
176 <xsl:with-param name="chars" select="$xsltsl-str-ws"/>
177 </xsl:call-template>
178 </xsl:variable>
179 <xsl:call-template name="str:capitalise">
180 <xsl:with-param name="text">
181 <xsl:value-of select="$firstword"/>
182 </xsl:with-param>
183 <xsl:with-param name="all" select="false()"/>
184 </xsl:call-template>
185 <xsl:value-of select="substring($text, string-length($firstword) + 1, 1)"/>
186 <xsl:call-template name="str:capitalise">
187 <xsl:with-param name="text">
188 <xsl:value-of select="substring($text, string-length($firstword) + 2)"/>
189 </xsl:with-param>
190 </xsl:call-template>
191 </xsl:when>
192
193 <xsl:otherwise>
194 <xsl:call-template name="str:to-upper">
195 <xsl:with-param name="text" select="substring($text, 1, 1)"/>
196 </xsl:call-template>
197 <xsl:call-template name="str:to-lower">
198 <xsl:with-param name="text" select="substring($text, 2)"/>
199 </xsl:call-template>
200 </xsl:otherwise>
201 </xsl:choose>
202 </xsl:template>
203
204 <doc:template name="str:to-camelcase" xmlns="">
205 <refpurpose>Convert a string to one camelcase word</refpurpose>
206
207 <refdescription>
208 <para>Converts a string to one lowerCamelCase or UpperCamelCase
209 word, depending on the setting of the "upper"
210 parameter. UpperCamelCase is also called MixedCase while
211 lowerCamelCase is also called just camelCase. The template
212 removes any spaces, tabs and slashes, but doesn't deal with
213 other punctuation. It's purpose is to convert strings like
214 "hollow timber flush door" to a term suitable as identifier or
215 XML tag like "HollowTimberFlushDoor".
216 </para>
217 </refdescription>
218
219 <refparameter>
220 <variablelist>
221 <varlistentry>
222 <term>text</term>
223 <listitem>
224 <para>The string to be capitalised</para>
225 </listitem>
226 </varlistentry>
227 <varlistentry>
228 <term>upper</term>
229 <listitem>
230 <para>Boolean controlling whether the string becomes an
231 UpperCamelCase word or a lowerCamelCase word.</para>
232 <para>Default is true.</para>
233 </listitem>
234 </varlistentry>
235 </variablelist>
236 </refparameter>
237
238 <refreturn>
239 <para>Returns string with first character uppcase and all remaining characters lowercase.</para>
240 </refreturn>
241 </doc:template>
242
243 <xsl:template name="str:to-camelcase">
244 <xsl:param name="text"/>
245 <xsl:param name="upper" select="true()"/>
246 <!-- First change all 'strange' characters to spaces -->
247 <xsl:param name="string-with-only-spaces">
248 <xsl:value-of select="translate($text,concat($xsltsl-str-ws,'/'),' ')"/>
249 </xsl:param>
250 <!-- Then process them -->
251 <xsl:param name="before-space-removal">
252 <xsl:variable name="firstword">
253 <xsl:call-template name="str:substring-before-first">
254 <xsl:with-param name="text" select="$string-with-only-spaces"/>
255 <xsl:with-param name="chars" select="$xsltsl-str-ws"/>
256 </xsl:call-template>
257 </xsl:variable>
258 <xsl:choose>
259 <xsl:when test="$upper">
260 <xsl:call-template name="str:to-upper">
261 <xsl:with-param name="text" select="substring($firstword, 1, 1)"/>
262 </xsl:call-template>
263 <xsl:call-template name="str:to-lower">
264 <xsl:with-param name="text" select="substring($firstword, 2)"/>
265 </xsl:call-template>
266 </xsl:when>
267 <xsl:otherwise>
268 <xsl:call-template name="str:to-lower">
269 <xsl:with-param name="text" select="$firstword"/>
270 </xsl:call-template>
271 </xsl:otherwise>
272 </xsl:choose>
273
274 <xsl:call-template name="str:capitalise">
275 <xsl:with-param name="text">
276 <xsl:value-of select="substring($string-with-only-spaces, string-length($firstword) + 2)"/>
277 </xsl:with-param>
278 <xsl:with-param name="all" select="true()"/>
279 </xsl:call-template>
280 </xsl:param>
281 <xsl:value-of select="translate($before-space-removal,' ','')"/>
282 </xsl:template>
283
284 <doc:template name="str:substring-before-first" xmlns="">
285 <refpurpose>String extraction</refpurpose>
286
287 <refdescription>
288 <para>Extracts the portion of string 'text' which occurs before any of the characters in string 'chars'.</para>
289 </refdescription>
290
291 <refparameter>
292 <variablelist>
293 <varlistentry>
294 <term>text</term>
295 <listitem>
296 <para>The string from which to extract a substring.</para>
297 </listitem>
298 </varlistentry>
299 <varlistentry>
300 <term>chars</term>
301 <listitem>
302 <para>The string containing characters to find.</para>
303 </listitem>
304 </varlistentry>
305 </variablelist>
306 </refparameter>
307
308 <refreturn>
309 <para>Returns string.</para>
310 </refreturn>
311 </doc:template>
312
313 <xsl:template name="str:substring-before-first">
314 <xsl:param name="text"/>
315 <xsl:param name="chars"/>
316
317 <xsl:choose>
318
319 <xsl:when test="string-length($text) = 0"/>
320
321 <xsl:when test="string-length($chars) = 0">
322 <xsl:value-of select="$text"/>
323 </xsl:when>
324
325 <xsl:when test="contains($text, substring($chars, 1, 1))">
326 <xsl:variable name="this" select="substring-before($text, substring($chars, 1, 1))"/>
327 <xsl:variable name="rest">
328 <xsl:call-template name="str:substring-before-first">
329 <xsl:with-param name="text" select="$text"/>
330 <xsl:with-param name="chars" select="substring($chars, 2)"/>
331 </xsl:call-template>
332 </xsl:variable>
333
334 <xsl:choose>
335 <xsl:when test="string-length($this) &lt; string-length($rest)">
336 <xsl:value-of select="$this"/>
337 </xsl:when>
338 <xsl:otherwise>
339 <xsl:value-of select="$rest"/>
340 </xsl:otherwise>
341 </xsl:choose>
342 </xsl:when>
343
344 <xsl:otherwise>
345 <xsl:call-template name="str:substring-before-first">
346 <xsl:with-param name="text" select="$text"/>
347 <xsl:with-param name="chars" select="substring($chars, 2)"/>
348 </xsl:call-template>
349 </xsl:otherwise>
350
351 </xsl:choose>
352 </xsl:template>
353
354 <doc:template name="str:substring-after-last" xmlns="">
355 <refpurpose>String extraction</refpurpose>
356
357 <refdescription>
358 <para>Extracts the portion of string 'text' which occurs after the last of the character in string 'chars'.</para>
359 </refdescription>
360
361 <refparameter>
362 <variablelist>
363 <varlistentry>
364 <term>text</term>
365 <listitem>
366 <para>The string from which to extract a substring.</para>
367 </listitem>
368 </varlistentry>
369 <varlistentry>
370 <term>chars</term>
371 <listitem>
372 <para>The string containing characters to find.</para>
373 </listitem>
374 </varlistentry>
375 </variablelist>
376 </refparameter>
377
378 <refreturn>
379 <para>Returns string.</para>
380 </refreturn>
381 </doc:template>
382
383 <xsl:template name="str:substring-after-last">
384 <xsl:param name="text"/>
385 <xsl:param name="chars"/>
386
387 <xsl:choose>
388
389 <xsl:when test="contains($text, $chars)">
390 <xsl:variable name="last" select="substring-after($text, $chars)"/>
391
392 <xsl:choose>
393 <xsl:when test="contains($last, $chars)">
394 <xsl:call-template name="str:substring-after-last">
395 <xsl:with-param name="text" select="$last"/>
396 <xsl:with-param name="chars" select="$chars"/>
397 </xsl:call-template>
398 </xsl:when>
399 <xsl:otherwise>
400 <xsl:value-of select="$last"/>
401 </xsl:otherwise>
402 </xsl:choose>
403 </xsl:when>
404
405 <xsl:otherwise>
406 <xsl:value-of select="$text"/>
407 </xsl:otherwise>
408
409 </xsl:choose>
410 </xsl:template>
411
412 <doc:template name="str:substring-before-last" xmlns="">
413 <refpurpose>String extraction</refpurpose>
414
415 <refdescription>
416 <para>Extracts the portion of string 'text' which occurs before the first character of the last occurance of string 'chars'.</para>
417 </refdescription>
418
419 <refparameter>
420 <variablelist>
421 <varlistentry>
422 <term>text</term>
423 <listitem>
424 <para>The string from which to extract a substring.</para>
425 </listitem>
426 </varlistentry>
427 <varlistentry>
428 <term>chars</term>
429 <listitem>
430 <para>The string containing characters to find.</para>
431 </listitem>
432 </varlistentry>
433 </variablelist>
434 </refparameter>
435
436 <refreturn>
437 <para>Returns string.</para>
438 </refreturn>
439 </doc:template>
440
441 <xsl:template name="str:substring-before-last">
442 <xsl:param name="text"/>
443 <xsl:param name="chars"/>
444
445 <xsl:choose>
446
447 <xsl:when test="string-length($text) = 0"/>
448
449 <xsl:when test="string-length($chars) = 0">
450 <xsl:value-of select="$text"/>
451 </xsl:when>
452
453 <xsl:when test="contains($text, $chars)">
454 <xsl:call-template name="str:substring-before-last-aux">
455 <xsl:with-param name="text" select="$text"/>
456 <xsl:with-param name="chars" select="$chars"/>
457 </xsl:call-template>
458 </xsl:when>
459
460 <xsl:otherwise>
461 <xsl:value-of select="$text"/>
462 </xsl:otherwise>
463
464 </xsl:choose>
465 </xsl:template>
466
467 <xsl:template name="str:substring-before-last-aux">
468 <xsl:param name="text"/>
469 <xsl:param name="chars"/>
470
471 <xsl:choose>
472 <xsl:when test="string-length($text) = 0"/>
473
474 <xsl:when test="contains($text, $chars)">
475 <xsl:variable name="after">
476 <xsl:call-template name="str:substring-before-last-aux">
477 <xsl:with-param name="text" select="substring-after($text, $chars)"/>
478 <xsl:with-param name="chars" select="$chars"/>
479 </xsl:call-template>
480 </xsl:variable>
481
482 <xsl:value-of select="substring-before($text, $chars)"/>
483 <xsl:if test="string-length($after) &gt; 0">
484 <xsl:value-of select="$chars"/>
485 <xsl:copy-of select="$after"/>
486 </xsl:if>
487 </xsl:when>
488
489 <xsl:otherwise/>
490 </xsl:choose>
491 </xsl:template>
492
493 <doc:template name="str:subst" xmlns="">
494 <refpurpose>String substitution</refpurpose>
495
496 <refdescription>
497 <para>Substitute 'replace' for 'with' in string 'text'.</para>
498 </refdescription>
499
500 <refparameter>
501 <variablelist>
502 <varlistentry>
503 <term>text</term>
504 <listitem>
505 <para>The string upon which to perform substitution.</para>
506 </listitem>
507 </varlistentry>
508 <varlistentry>
509 <term>replace</term>
510 <listitem>
511 <para>The string to substitute.</para>
512 </listitem>
513 </varlistentry>
514 <varlistentry>
515 <term>with</term>
516 <listitem>
517 <para>The string to be substituted.</para>
518 </listitem>
519 </varlistentry>
520 <varlistentry>
521 <term>disable-output-escaping</term>
522 <listitem>
523 <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>
524 </listitem>
525 </varlistentry>
526 </variablelist>
527 </refparameter>
528
529 <refreturn>
530 <para>Returns string.</para>
531 </refreturn>
532 </doc:template>
533
534 <xsl:template name="str:subst">
535 <xsl:param name="text"/>
536 <xsl:param name="replace"/>
537 <xsl:param name="with"/>
538 <xsl:param name='disable-output-escaping'>no</xsl:param>
539
540 <xsl:choose>
541 <xsl:when test="string-length($replace) = 0 and $disable-output-escaping = 'yes'">
542 <xsl:value-of select="$text" disable-output-escaping='yes'/>
543 </xsl:when>
544 <xsl:when test="string-length($replace) = 0">
545 <xsl:value-of select="$text"/>
546 </xsl:when>
547 <xsl:when test="contains($text, $replace)">
548
549 <xsl:variable name="before" select="substring-before($text, $replace)"/>
550 <xsl:variable name="after" select="substring-after($text, $replace)"/>
551
552 <xsl:choose>
553 <xsl:when test='$disable-output-escaping = "yes"'>
554 <xsl:value-of select="$before" disable-output-escaping="yes"/>
555 <xsl:value-of select="$with" disable-output-escaping="yes"/>
556 </xsl:when>
557 <xsl:otherwise>
558 <xsl:value-of select="$before"/>
559 <xsl:value-of select="$with"/>
560 </xsl:otherwise>
561 </xsl:choose>
562 <xsl:call-template name="str:subst">
563 <xsl:with-param name="text" select="$after"/>
564 <xsl:with-param name="replace" select="$replace"/>
565 <xsl:with-param name="with" select="$with"/>
566 <xsl:with-param name="disable-output-escaping" select="$disable-output-escaping"/>
567 </xsl:call-template>
568 </xsl:when>
569 <xsl:when test='$disable-output-escaping = "yes"'>
570 <xsl:value-of select="$text" disable-output-escaping="yes"/>
571 </xsl:when>
572 <xsl:otherwise>
573 <xsl:value-of select="$text"/>
574 </xsl:otherwise>
575 </xsl:choose>
576 </xsl:template>
577
578 <doc:template name="str:count-substring" xmlns="">
579 <refpurpose>Count Substrings</refpurpose>
580
581 <refdescription>
582 <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>
583 </refdescription>
584
585 <example>
586 <title>Counting Lines</title>
587 <programlisting><![CDATA[
588<xsl:call-template name="str:count-substring">
589 <xsl:with-param name="text" select="$mytext"/>
590 <xsl:with-param name="chars" select="'&#x0a;'"/>
591</xsl:call-template>
592]]></programlisting>
593 </example>
594
595 <refparameter>
596 <variablelist>
597 <varlistentry>
598 <term>text</term>
599 <listitem>
600 <para>The source string.</para>
601 </listitem>
602 </varlistentry>
603 <varlistentry>
604 <term>chars</term>
605 <listitem>
606 <para>The substring to count.</para>
607 </listitem>
608 </varlistentry>
609 </variablelist>
610 </refparameter>
611
612 <refreturn>
613 <para>Returns a non-negative integer value.</para>
614 </refreturn>
615 </doc:template>
616
617 <xsl:template name="str:count-substring">
618 <xsl:param name="text"/>
619 <xsl:param name="chars"/>
620
621 <xsl:choose>
622 <xsl:when test="string-length($text) = 0 or string-length($chars) = 0">
623 <xsl:text>0</xsl:text>
624 </xsl:when>
625 <xsl:when test="contains($text, $chars)">
626 <xsl:variable name="remaining">
627 <xsl:call-template name="str:count-substring">
628 <xsl:with-param name="text" select="substring-after($text, $chars)"/>
629 <xsl:with-param name="chars" select="$chars"/>
630 </xsl:call-template>
631 </xsl:variable>
632 <xsl:value-of select="$remaining + 1"/>
633 </xsl:when>
634 <xsl:otherwise>
635 <xsl:text>0</xsl:text>
636 </xsl:otherwise>
637 </xsl:choose>
638 </xsl:template>
639
640 <doc:template name="str:substring-after-at" xmlns="">
641 <refpurpose>String extraction</refpurpose>
642 <refdescription>
643 <para>Extracts the portion of a 'char' delimited 'text' string "array" at a given 'position'.</para>
644 </refdescription>
645 <refparameter>
646 <variablelist>
647 <varlistentry>
648 <term>text</term>
649 <listitem>
650 <para>The string from which to extract a substring.</para>
651 </listitem>
652 </varlistentry>
653 <varlistentry>
654 <term>chars</term>
655 <listitem>
656 <para>delimiters</para>
657 </listitem>
658 </varlistentry>
659 <varlistentry>
660 <term>position</term>
661 <listitem>
662 <para>position of the elements</para>
663 </listitem>
664 </varlistentry>
665 <varlistentry>
666 <term>all</term>
667 <listitem>
668 <para>If true all of the remaining string is returned, otherwise only the element at the given position is returned. Default: false().</para>
669 </listitem>
670 </varlistentry>
671 </variablelist>
672 </refparameter>
673 <refreturn>
674 <para>Returns string.</para>
675 </refreturn>
676 </doc:template>
677
678
679 <xsl:template name="str:substring-after-at">
680 <xsl:param name="text"/>
681 <xsl:param name="chars"/>
682 <xsl:param name="position"/>
683 <xsl:param name="all" select='false()'/>
684
685 <xsl:choose>
686 <xsl:when test='number($position) = 0 and $all'>
687 <xsl:value-of select='$text'/>
688 </xsl:when>
689 <xsl:when test='number($position) = 0 and not($chars)'>
690 <xsl:value-of select='$text'/>
691 </xsl:when>
692 <xsl:when test='number($position) = 0 and not(contains($text, $chars))'>
693 <xsl:value-of select='$text'/>
694 </xsl:when>
695 <xsl:when test='not(contains($text, $chars))'>
696 </xsl:when>
697 <xsl:when test="number($position) = 0">
698 <xsl:value-of select="substring-before($text, $chars)"/>
699 </xsl:when>
700 <xsl:otherwise>
701 <xsl:call-template name="str:substring-after-at">
702 <xsl:with-param name="text" select="substring-after($text, $chars)"/>
703 <xsl:with-param name="chars" select="$chars"/>
704 <xsl:with-param name="all" select="$all"/>
705 <xsl:with-param name="position" select="$position - 1"/>
706 </xsl:call-template>
707 </xsl:otherwise>
708 </xsl:choose>
709 </xsl:template>
710
711 <doc:template name="str:substring-before-at" xmlns="">
712 <refpurpose>String extraction</refpurpose>
713 <refdescription>
714 <para>Extracts the portion of a 'char' delimited 'text' string "array" at a given 'position' </para>
715 </refdescription>
716 <refparameter>
717 <variablelist>
718 <varlistentry>
719 <term>text</term>
720 <listitem>
721 <para>The string from which to extract a substring.</para>
722 </listitem>
723 </varlistentry>
724 <varlistentry>
725 <term>chars</term>
726 <listitem>
727 <para>delimiters</para>
728 </listitem>
729 </varlistentry>
730 <varlistentry>
731 <term>position</term>
732 <listitem>
733 <para>position of the elements</para>
734 </listitem>
735 </varlistentry>
736 </variablelist>
737 </refparameter>
738 <refreturn>
739 <para>Returns string.</para>
740 </refreturn>
741 </doc:template>
742
743 <xsl:template name="str:substring-before-at">
744 <xsl:param name="text"/>
745 <xsl:param name="chars"/>
746 <xsl:param name="position"/>
747
748 <xsl:choose>
749 <xsl:when test="$position &lt;= 0"/>
750 <xsl:when test="not(contains($text, $chars))"/>
751 <xsl:otherwise>
752 <xsl:value-of select='substring-before($text, $chars)'/>
753 <xsl:value-of select='$chars'/>
754
755 <xsl:call-template name="str:substring-before-at">
756 <xsl:with-param name="text" select="substring-after($text, $chars)"/>
757 <xsl:with-param name="position" select="$position - 1"/>
758 <xsl:with-param name="chars" select="$chars"/>
759 </xsl:call-template>
760
761 </xsl:otherwise>
762 </xsl:choose>
763 </xsl:template>
764
765 <doc:template name="str:insert-at" xmlns="">
766 <refpurpose>String insertion</refpurpose>
767 <refdescription>
768 <para>Insert 'chars' into "text' at any given "position'</para>
769 </refdescription>
770 <refparameter>
771 <variablelist>
772 <varlistentry>
773 <term>text</term>
774 <listitem>
775 <para>The string upon which to perform insertion</para>
776 </listitem>
777 </varlistentry>
778 <varlistentry>
779 <term>position</term>
780 <listitem>
781 <para>the position where insertion will be performed</para>
782 </listitem>
783 </varlistentry>
784 <varlistentry>
785 <term>with</term>
786 <listitem>
787 <para>The string to be inserted</para>
788 </listitem>
789 </varlistentry>
790 </variablelist>
791 </refparameter>
792 <refreturn>
793 <para>Returns string.</para>
794 </refreturn>
795 </doc:template>
796
797 <xsl:template name="str:insert-at">
798 <xsl:param name="text"/>
799 <xsl:param name="position"/>
800 <xsl:param name="chars"/>
801
802 <xsl:variable name="firstpart" select="substring($text, 0, $position)"/>
803 <xsl:variable name="secondpart" select="substring($text, $position, string-length($text))"/>
804
805 <xsl:value-of select="concat($firstpart, $chars, $secondpart)"/>
806 </xsl:template>
807
808
809 <doc:template name="str:backward" xmlns="">
810 <refpurpose>String reversal</refpurpose>
811
812 <refdescription>
813 <para>Reverse the content of a given string</para>
814 </refdescription>
815
816 <refparameter>
817 <variablelist>
818 <varlistentry>
819 <term>text</term>
820 <listitem>
821 <para>The string to be reversed</para>
822 </listitem>
823 </varlistentry>
824 </variablelist>
825 </refparameter>
826
827 <refreturn>
828 <para>Returns string.</para>
829 </refreturn>
830 </doc:template>
831
832 <xsl:template name="str:backward">
833 <xsl:param name="text"/>
834 <xsl:variable name="mirror">
835 <xsl:call-template name="str:build-mirror">
836 <xsl:with-param name="text" select="$text"/>
837 <xsl:with-param name="position" select="string-length($text)"/>
838 </xsl:call-template>
839 </xsl:variable>
840 <xsl:value-of select="substring($mirror, string-length($text) + 1, string-length($text))"/>
841 </xsl:template>
842
843 <xsl:template name="str:build-mirror">
844 <xsl:param name="text"/>
845 <xsl:param name="position"/>
846
847 <xsl:choose>
848 <xsl:when test="$position &gt; 0">
849 <xsl:call-template name="str:build-mirror">
850 <xsl:with-param name="text" select="concat($text, substring($text, $position, 1))"/>
851 <xsl:with-param name="position" select="$position - 1"/>
852 </xsl:call-template>
853 </xsl:when>
854 <xsl:otherwise>
855 <xsl:value-of select="$text"/>
856 </xsl:otherwise>
857 </xsl:choose>
858 </xsl:template>
859
860 <doc:template name="str:justify" xmlns="">
861 <refpurpose>Format a string</refpurpose>
862
863 <refdescription>
864 <para>Inserts newlines and spaces into a string to format it as a block of text.</para>
865 </refdescription>
866
867 <refparameter>
868 <variablelist>
869 <varlistentry>
870 <term>text</term>
871 <listitem>
872 <para>String to be formatted.</para>
873 </listitem>
874 </varlistentry>
875 <varlistentry>
876 <term>max</term>
877 <listitem>
878 <para>Maximum line length.</para>
879 </listitem>
880 </varlistentry>
881 <varlistentry>
882 <term>indent</term>
883 <listitem>
884 <para>Number of spaces to insert at the beginning of each line.</para>
885 </listitem>
886 </varlistentry>
887 <varlistentry>
888 <term>justify</term>
889 <listitem>
890 <para>Justify left, right or both. Not currently implemented (fixed at "left").</para>
891 </listitem>
892 </varlistentry>
893 </variablelist>
894 </refparameter>
895
896 <refreturn>
897 <para>Formatted block of text.</para>
898 </refreturn>
899 </doc:template>
900
901 <xsl:template name='str:justify'>
902 <xsl:param name='text'/>
903 <xsl:param name='max' select='"80"'/>
904 <xsl:param name='indent' select='"0"'/>
905 <xsl:param name='justify' select='"left"'/>
906
907 <xsl:choose>
908 <xsl:when test='string-length($text) = 0 or $max &lt;= 0'/>
909
910 <xsl:when test='string-length($text) > $max and contains($text, " ") and string-length(substring-before($text, " ")) > $max'>
911 <xsl:call-template name='str:generate-string'>
912 <xsl:with-param name='text' select='" "'/>
913 <xsl:with-param name='count' select='$indent'/>
914 </xsl:call-template>
915 <xsl:value-of select='substring-before($text, " ")'/>
916 <xsl:text>
917</xsl:text>
918 <xsl:call-template name='str:justify'>
919 <xsl:with-param name='text' select='substring-after($text, " ")'/>
920 <xsl:with-param name='max' select='$max'/>
921 <xsl:with-param name='indent' select='$indent'/>
922 <xsl:with-param name='justify' select='$justify'/>
923 </xsl:call-template>
924 </xsl:when>
925
926 <xsl:when test='string-length($text) > $max and contains($text, " ")'>
927 <xsl:variable name='first'>
928 <xsl:call-template name='str:substring-before-last'>
929 <xsl:with-param name='text' select='substring($text, 1, $max)'/>
930 <xsl:with-param name='chars' select='" "'/>
931 </xsl:call-template>
932 </xsl:variable>
933
934 <xsl:call-template name='str:generate-string'>
935 <xsl:with-param name='text' select='" "'/>
936 <xsl:with-param name='count' select='$indent'/>
937 </xsl:call-template>
938 <xsl:value-of select='$first'/>
939 <xsl:text>
940</xsl:text>
941 <xsl:call-template name='str:justify'>
942 <xsl:with-param name='text' select='substring($text, string-length($first) + 2)'/>
943 <xsl:with-param name='max' select='$max'/>
944 <xsl:with-param name='indent' select='$indent'/>
945 <xsl:with-param name='justify' select='$justify'/>
946 </xsl:call-template>
947 </xsl:when>
948
949 <xsl:otherwise>
950 <xsl:call-template name='str:generate-string'>
951 <xsl:with-param name='text' select='" "'/>
952 <xsl:with-param name='count' select='$indent'/>
953 </xsl:call-template>
954 <xsl:value-of select='$text'/>
955 </xsl:otherwise>
956 </xsl:choose>
957 </xsl:template>
958
959 <doc:template name="str:character-first" xmlns="">
960 <refpurpose>Find first occurring character in a string</refpurpose>
961
962 <refdescription>
963 <para>Finds which of the given characters occurs first in a string.</para>
964 </refdescription>
965
966 <refparameter>
967 <variablelist>
968 <varlistentry>
969 <term>text</term>
970 <listitem>
971 <para>The source string.</para>
972 </listitem>
973 </varlistentry>
974 <varlistentry>
975 <term>chars</term>
976 <listitem>
977 <para>The characters to search for.</para>
978 </listitem>
979 </varlistentry>
980 </variablelist>
981 </refparameter>
982 </doc:template>
983
984 <xsl:template name="str:character-first">
985 <xsl:param name="text"/>
986 <xsl:param name="chars"/>
987
988 <xsl:choose>
989 <xsl:when test="string-length($text) = 0 or string-length($chars) = 0"/>
990
991 <xsl:when test="contains($text, substring($chars, 1, 1))">
992 <xsl:variable name="next-character">
993 <xsl:call-template name="str:character-first">
994 <xsl:with-param name="text" select="$text"/>
995 <xsl:with-param name="chars" select="substring($chars, 2)"/>
996 </xsl:call-template>
997 </xsl:variable>
998
999 <xsl:choose>
1000 <xsl:when test="string-length($next-character)">
1001 <xsl:variable name="first-character-position" select="string-length(substring-before($text, substring($chars, 1, 1)))"/>
1002 <xsl:variable name="next-character-position" select="string-length(substring-before($text, $next-character))"/>
1003
1004 <xsl:choose>
1005 <xsl:when test="$first-character-position &lt; $next-character-position">
1006 <xsl:value-of select="substring($chars, 1, 1)"/>
1007 </xsl:when>
1008 <xsl:otherwise>
1009 <xsl:value-of select="$next-character"/>
1010 </xsl:otherwise>
1011 </xsl:choose>
1012 </xsl:when>
1013 <xsl:otherwise>
1014 <xsl:value-of select="substring($chars, 1, 1)"/>
1015 </xsl:otherwise>
1016 </xsl:choose>
1017 </xsl:when>
1018 <xsl:otherwise>
1019 <xsl:call-template name="str:character-first">
1020 <xsl:with-param name="text" select="$text"/>
1021 <xsl:with-param name="chars" select="substring($chars, 2)"/>
1022 </xsl:call-template>
1023 </xsl:otherwise>
1024 </xsl:choose>
1025 </xsl:template>
1026
1027 <doc:template name="str:string-match" xmlns="">
1028 <refpurpose>Match A String To A Pattern</refpurpose>
1029
1030 <refdescription>
1031 <para>Performs globbing-style pattern matching on a string.</para>
1032 </refdescription>
1033
1034 <example>
1035 <title>Match Pattern</title>
1036 <programlisting><![CDATA[
1037<xsl:call-template name="str:string-match">
1038 <xsl:with-param name="text" select="$mytext"/>
1039 <xsl:with-param name="pattern" select="'abc*def?g'"/>
1040</xsl:call-template>
1041]]></programlisting>
1042 </example>
1043
1044 <refparameter>
1045 <variablelist>
1046 <varlistentry>
1047 <term>text</term>
1048 <listitem>
1049 <para>The source string.</para>
1050 </listitem>
1051 </varlistentry>
1052 <varlistentry>
1053 <term>pattern</term>
1054 <listitem>
1055 <para>The pattern to match against. Certain characters have special meaning:</para>
1056 <variablelist>
1057 <varlistentry>
1058 <term>*</term>
1059 <listitem>
1060 <para>Matches zero or more characters.</para>
1061 </listitem>
1062 </varlistentry>
1063 <varlistentry>
1064 <term>?</term>
1065 <listitem>
1066 <para>Matches a single character.</para>
1067 </listitem>
1068 </varlistentry>
1069 <varlistentry>
1070 <term>\</term>
1071 <listitem>
1072 <para>Character escape. The next character is taken as a literal character.</para>
1073 </listitem>
1074 </varlistentry>
1075 </variablelist>
1076 </listitem>
1077 </varlistentry>
1078 </variablelist>
1079 </refparameter>
1080
1081 <refreturn>
1082 <para>Returns "1" if the string matches the pattern, "0" otherwise.</para>
1083 </refreturn>
1084 </doc:template>
1085
1086 <xsl:template name="str:string-match">
1087 <xsl:param name="text"/>
1088 <xsl:param name="pattern"/>
1089
1090 <xsl:choose>
1091 <xsl:when test="$pattern = '*'">
1092 <!-- Special case: always matches -->
1093 <xsl:text>1</xsl:text>
1094 </xsl:when>
1095 <xsl:when test="string-length($text) = 0 and string-length($pattern) = 0">
1096 <xsl:text>1</xsl:text>
1097 </xsl:when>
1098 <xsl:when test="string-length($text) = 0 or string-length($pattern) = 0">
1099 <xsl:text>0</xsl:text>
1100 </xsl:when>
1101 <xsl:otherwise>
1102 <xsl:variable name='before-special'>
1103 <xsl:call-template name='str:substring-before-first'>
1104 <xsl:with-param name='text' select='$pattern'/>
1105 <xsl:with-param name='chars' select='"*?\"'/>
1106 </xsl:call-template>
1107 </xsl:variable>
1108 <xsl:variable name='special'>
1109 <xsl:call-template name='str:character-first'>
1110 <xsl:with-param name='text' select='$pattern'/>
1111 <xsl:with-param name='chars' select='"*?\"'/>
1112 </xsl:call-template>
1113 </xsl:variable>
1114
1115 <xsl:variable name='new-text' select='substring($text, string-length($before-special) + 1)'/>
1116 <xsl:variable name='new-pattern' select='substring($pattern, string-length($before-special) + 1)'/>
1117
1118 <xsl:choose>
1119 <xsl:when test="not(starts-with($text, $before-special))">
1120 <!-- Verbatim characters don't match -->
1121 <xsl:text>0</xsl:text>
1122 </xsl:when>
1123
1124 <xsl:when test="$special = '*' and string-length($new-pattern) = 1">
1125 <xsl:text>1</xsl:text>
1126 </xsl:when>
1127 <xsl:when test="$special = '*'">
1128 <xsl:call-template name='str:match-postfix'>
1129 <xsl:with-param name='text' select='$new-text'/>
1130 <xsl:with-param name='pattern' select='substring($new-pattern, 2)'/>
1131 </xsl:call-template>
1132 </xsl:when>
1133
1134 <xsl:when test="$special = '?'">
1135 <xsl:call-template name="str:string-match">
1136 <xsl:with-param name='text' select='substring($new-text, 2)'/>
1137 <xsl:with-param name='pattern' select='substring($new-pattern, 2)'/>
1138 </xsl:call-template>
1139 </xsl:when>
1140
1141 <xsl:when test="$special = '\' and substring($new-text, 1, 1) = substring($new-pattern, 2, 1)">
1142 <xsl:call-template name="str:string-match">
1143 <xsl:with-param name='text' select='substring($new-text, 2)'/>
1144 <xsl:with-param name='pattern' select='substring($new-pattern, 3)'/>
1145 </xsl:call-template>
1146 </xsl:when>
1147 <xsl:when test="$special = '\' and substring($new-text, 1, 1) != substring($new-pattern, 2, 1)">
1148 <xsl:text>0</xsl:text>
1149 </xsl:when>
1150
1151 <xsl:otherwise>
1152 <!-- There were no special characters in the pattern -->
1153 <xsl:choose>
1154 <xsl:when test='$text = $pattern'>
1155 <xsl:text>1</xsl:text>
1156 </xsl:when>
1157 <xsl:otherwise>
1158 <xsl:text>0</xsl:text>
1159 </xsl:otherwise>
1160 </xsl:choose>
1161 </xsl:otherwise>
1162 </xsl:choose>
1163 </xsl:otherwise>
1164 </xsl:choose>
1165 </xsl:template>
1166
1167 <xsl:template name="str:match-postfix">
1168 <xsl:param name="text"/>
1169 <xsl:param name="pattern"/>
1170
1171 <xsl:variable name='result'>
1172 <xsl:call-template name='str:string-match'>
1173 <xsl:with-param name='text' select='$text'/>
1174 <xsl:with-param name='pattern' select='$pattern'/>
1175 </xsl:call-template>
1176 </xsl:variable>
1177
1178 <xsl:choose>
1179 <xsl:when test='$result = "1"'>
1180 <xsl:value-of select='$result'/>
1181 </xsl:when>
1182 <xsl:when test='string-length($text) = 0'>
1183 <xsl:text>0</xsl:text>
1184 </xsl:when>
1185 <xsl:otherwise>
1186 <xsl:call-template name='str:match-postfix'>
1187 <xsl:with-param name='text' select='substring($text, 2)'/>
1188 <xsl:with-param name='pattern' select='$pattern'/>
1189 </xsl:call-template>
1190 </xsl:otherwise>
1191 </xsl:choose>
1192
1193 </xsl:template>
1194
1195 <doc:template name="str:generate-string" xmlns="">
1196 <refpurpose>Create A Repeating Sequence of Characters</refpurpose>
1197
1198 <refdescription>
1199 <para>Repeats a string a given number of times.</para>
1200 </refdescription>
1201
1202 <refparameter>
1203 <variablelist>
1204 <varlistentry>
1205 <term>text</term>
1206 <listitem>
1207 <para>The string to repeat.</para>
1208 </listitem>
1209 </varlistentry>
1210 <varlistentry>
1211 <term>count</term>
1212 <listitem>
1213 <para>The number of times to repeat the string.</para>
1214 </listitem>
1215 </varlistentry>
1216 </variablelist>
1217 </refparameter>
1218 </doc:template>
1219
1220 <xsl:template name="str:generate-string">
1221 <xsl:param name="text"/>
1222 <xsl:param name="count"/>
1223
1224 <xsl:choose>
1225 <xsl:when test="string-length($text) = 0 or $count &lt;= 0"/>
1226 <xsl:otherwise>
1227 <xsl:value-of select="$text"/>
1228 <xsl:call-template name="str:generate-string">
1229 <xsl:with-param name="text" select="$text"/>
1230 <xsl:with-param name="count" select="$count - 1"/>
1231 </xsl:call-template>
1232 </xsl:otherwise>
1233 </xsl:choose>
1234 </xsl:template>
1235
1236</xsl:stylesheet>
1237
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use