1module namespace def = "http://www.28msec.com/compile-time/functx-x-1";
2
3import module namespace functx1 = "http://www.28msec.com/compile-time/lib/functx1" at "functx1.xqlib";
4
5declare namespace ann = "http://www.zorba-xquery.com/annotations";
6
7
8declare function def:t ()
9{
10  "t1"
11};
12
13declare function def:index ()
14{
15  functx1:substring-before-if-contains('abcd','c'),
16  functx1:substring-before-last('abc-def-ghi', '-'),
17  functx1:substring-before-last-match('abc-def-ghi', '[ce]'),
18  functx1:substring-before-match('abc-def-ghi', '[dg]'),
19  functx1:substring-after-if-contains('abcd','b'),
20  functx1:substring-after-last('abc-def-ghi', '-'),
21  functx1:substring-after-last-match('abc-def-ghi', '[ad]'),
22  functx1:substring-after-match('abc-def-ghi', '[ce]'),
23
24  functx1:substring-before-match('abc-def-ghi', '[dg]'),
25  functx1:substring-before-last-match('abc-def-ghi', '[ce]'),
26  functx1:substring-after-last-match('abc-def-ghi', '[ad]'),
27  functx1:substring-after-match('abc-def-ghi', '[ce]'),
28  functx1:index-of-match-first('abcdabcdabcd','abc'),
29  functx1:get-matches('abc123def', '\d+'),
30  functx1:get-matches-and-non-matches('abc123def', '\d+'),
31  functx1:number-of-matches('abcabc','ab'),
32
33  functx1:index-of-string('abcdabcdabcd','abc'),
34  functx1:index-of-string-first('abcdabcdabcd','abc'),
35  functx1:index-of-string-last('abcdabcdabcd','abc'),
36  functx1:index-of-match-first('abcdabcdabcd','abc'),
37
38  functx1:contains-word('abc def ghi', 'def'),
39  functx1:contains-case-insensitive('abcdef', 'def'),
40  functx1:contains-any-of('abc',('bc','xy')),
41
42  functx1:insert-string('xyz','def',2),
43  functx1:chars('abc'),
44  functx1:lines('a value'),
45
46  functx1:replace-first('abcabcabc', 'ab', 'x'),
47  functx1:replace-beginning('abc-def', '-', 'xxx'),
48  functx1:replace-multi('abcdef123',('[a-c]', 'def', '\d+'),('x', 'y', '0')),
49  functx1:escape-for-regex('5.55'),
50  functx1:reverse-string('abc'),
51
52  functx1:max-string( <in-xml><x>a</x><y>c</y><z>b</z></in-xml>/* ),
53  functx1:min-string( <in-xml><x>a</x><y>c</y><z>b</z></in-xml>/* ),
54  functx1:min-non-empty-string(
55      <authors>
56         <author>
57            <fName/>
58            <lName>Smith</lName>
59         </author>
60         <author>
61            <fName>Kate</fName>
62            <lName>Jones</lName>
63         </author>
64         <author>
65            <fName>John</fName>
66            <lName>Doe</lName>
67         </author>
68      </authors>//fName ),
69
70  functx1:trim('   xyz   '),
71  functx1:left-trim('   xyz'),
72  functx1:right-trim('xyz   '),
73  functx1:pad-string-to-length('abc', '*', 6),
74  functx1:repeat-string('*', 6),
75
76  functx1:capitalize-first('hello'),
77  functx1:camel-case-to-words('thisIsACamelCaseTerm',' '),
78  functx1:words-to-camel-case('this Is A Term'),
79  functx1:format-as-title-en(('A Midsummer Night''s Dream',
80      'The Merchant of Venice',
81      'Hamlet')),
82
83  functx1:line-count('a value'),
84  functx1:max-line-length('a value'),
85  functx1:word-count('hello there world'),
86
87
88  functx1:ordinal-number-en(1),
89  functx1:pad-integer-to-length(12, 6),
90
91  functx1:is-a-number('123'),
92
93  let $in-xml :=
94      <prices>
95         <price value="29.99" discount="10.00"/>
96         <price value="39.99" discount="6.00"/>
97         <price value="69.99"/>
98         <price value="49.99" discount=""/>
99      </prices>
100  return
101      functx1:avg-empty-is-zero(
102         $in-xml//price/@discount, $in-xml//price),
103
104
105  functx1:mmddyyyy-to-date('12-15-2004'),
106  functx1:dateTime(2006,6,12,20,6,12),
107  functx1:date(2006,6,12),
108  functx1:time(20,6,12),
109
110  functx1:day-of-week(xs:date('2004-11-04')),
111  functx1:day-of-week-name-en('2004-11-04'),
112  functx1:day-of-week-abbrev-en('2004-11-04'),
113
114  functx1:first-day-of-year(xs:date('2004-01-23')),
115  functx1:last-day-of-year(xs:date('2004-01-23')),
116  functx1:is-leap-year(xs:date('2004-01-23')),
117
118  functx1:month-name-en(xs:date('2004-01-23')),
119  functx1:month-abbrev-en('2004-01-23'),
120  functx1:first-day-of-month('2004-03-23'),
121  functx1:last-day-of-month('2004-03-23'),
122  functx1:days-in-month('2005-02-15'),
123  functx1:add-months('2005-12-31',-3),
124  functx1:next-day(xs:date('2004-01-23')),
125  functx1:previous-day(xs:date('2004-01-23')),
126  functx1:day-in-year('2004-02-05'),
127
128  functx1:total-seconds-from-duration(xs:dayTimeDuration('PT90S')),
129  functx1:total-minutes-from-duration(xs:dayTimeDuration('PT90M')),
130  functx1:total-hours-from-duration(xs:dayTimeDuration('PT26H')),
131  functx1:total-days-from-duration(xs:dayTimeDuration('PT24H')),
132  functx1:total-months-from-duration(xs:yearMonthDuration('P18M')),
133  functx1:total-years-from-duration(xs:yearMonthDuration('P18M')),
134  functx1:yearMonthDuration(1,6),
135  functx1:dayTimeDuration(1,6,0,0),
136
137
138  functx1:between-inclusive(55, 1, 1000),
139  functx1:between-exclusive(55, 1, 1000),
140
141  let $i := <nums><num>12</num><num>23</num><num>115</num><num>12.5</num></nums>
142  return functx1:min-determine-type($i//num),
143  let $i := <nums><num>12</num><num>23</num><num>115</num><num>12.5</num></nums>
144  return functx1:max-determine-type($i//num),
145
146  functx1:all-whitespace('   '),
147  functx1:has-empty-content(<a></a>),
148  let $in-xml :=
149      <prices>
150         <price value="29.99" discount="10.00"/>
151         <price value="39.99" discount="6.00"/>
152         <price value="69.99"/>
153         <price value="49.99" discount=""/>
154      </prices>
155  return
156      fn:data(functx1:if-absent(
157           $in-xml//price[1]/@discount, 0)),
158  let $in-xml :=
159      <prices>
160         <price value="29.99" discount="10.00"/>
161         <price value="39.99" discount="6.00"/>
162         <price value="69.99"/>
163         <price value="49.99" discount=""/>
164      </prices>
165  return
166      functx1:if-empty($in-xml//price[1], 0),
167
168  functx1:exclusive-or(true(),false()),
169  functx1:atomic-type(2)
170
171  (:  Sequences
172      XML Elements and Attributes
173      XML Nodes
174      XML Namespaces and Names
175      XML Documents, URIs and IDs
176      Miscellaneous :)
177
178
179};
180
181
182
183