author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Mon, 02 Jul 2018 08:46:01 +0200 | |
changeset 305 | bad21c4f64bf |
parent 296 | ea3dbc023c80 |
permissions | -rw-r--r-- |
235 | 1 |
"{ Package: 'stx:goodies/xmlsuite/xquery' }" |
2 |
||
3 |
"{ NameSpace: XQuery }" |
|
4 |
||
5 |
Object subclass:#XQueryFuncTable |
|
6 |
instanceVariableNames:'table' |
|
7 |
classVariableNames:'' |
|
8 |
poolDictionaries:'' |
|
9 |
category:'XQuery-Runtime' |
|
10 |
! |
|
11 |
||
12 |
||
13 |
!XQueryFuncTable class methodsFor:'instance creation'! |
|
14 |
||
15 |
new |
|
16 |
^ self basicNew initialize. |
|
17 |
||
18 |
"Created: / 28-12-2006 / 12:28:13 / janfrog" |
|
19 |
! ! |
|
20 |
||
21 |
!XQueryFuncTable class methodsFor:'defaults'! |
|
22 |
||
23 |
defaultTable |
|
24 |
"default value for the 'table' instance variable (automatically generated)" |
|
25 |
||
26 |
^Dictionary new |
|
27 |
at: 'fn:count' put: XQueryFnCount; |
|
28 |
at: 'count' put: XQueryFnCount; |
|
29 |
at: 'fn:empty' put: XQueryFnEmpty; |
|
30 |
at: 'empty' put: XQueryFnEmpty; |
|
31 |
at: 'fn:exists' put: XQueryFnExists; |
|
32 |
at: 'exists' put: XQueryFnExists; |
|
33 |
at: 'fn:true' put: XQueryFnTrue; |
|
34 |
at: 'true' put: XQueryFnTrue; |
|
35 |
at: 'fn:false' put: XQueryFnFalse; |
|
36 |
at: 'false' put: XQueryFnFalse; |
|
37 |
at: 'fn:zero-or-one' put: XQueryFnZeroOrOne; |
|
38 |
at: 'zero-or-one' put: XQueryFnZeroOrOne; |
|
39 |
at: 'fn:one-or-more' put: XQueryFnOneOrMore; |
|
40 |
at: 'one-or-more' put: XQueryFnOneOrMore; |
|
41 |
at: 'fn:exactly-one' put: XQueryFnExactlyOne; |
|
42 |
at: 'exactly-one' put: XQueryFnExactlyOne; |
|
43 |
at: 'fn:boolean' put: XQueryFnBoolean; |
|
44 |
at: 'boolean' put: XQueryFnBoolean; |
|
45 |
at: 'fn:not' put: XQueryFnNot; |
|
46 |
at: 'not' put: XQueryFnNot; |
|
47 |
at: 'fn:position' put: XQueryFnPosition; |
|
48 |
at: 'position' put: XQueryFnPosition; |
|
49 |
at: 'fn:last' put: XQueryFnLast; |
|
50 |
at: 'last' put: XQueryFnLast; |
|
51 |
at: 'fn:doc' put: XQueryFnDoc; |
|
52 |
at: 'doc' put: XQueryFnDoc; |
|
53 |
at: 'fn:sum' put: XQueryFnSum; |
|
54 |
at: 'sum' put: XQueryFnSum; |
|
55 |
at: 'fn:avg' put: XQueryFnAvg; |
|
56 |
at: 'avg' put: XQueryFnAvg; |
|
57 |
at: 'fn:max' put: XQueryFnMax; |
|
58 |
at: 'max' put: XQueryFnMax; |
|
59 |
at: 'fn:min' put: XQueryFnMin; |
|
60 |
at: 'min' put: XQueryFnMin; |
|
61 |
at: 'fn:abs' put: XQueryFnAbs; |
|
62 |
at: 'abs' put: XQueryFnAbs; |
|
63 |
at: 'fn:ceiling' put: XQueryFnCeiling; |
|
64 |
at: 'ceiling' put: XQueryFnCeiling; |
|
65 |
at: 'fn:floor' put: XQueryFnFloor; |
|
66 |
at: 'floor' put: XQueryFnFloor; |
|
67 |
at: 'fn:round' put: XQueryFnRound; |
|
68 |
at: 'round' put: XQueryFnRound; |
|
69 |
at: 'fn:insert-before' put: XQueryFnInsertBefore; |
|
70 |
at: 'insert-before' put: XQueryFnInsertBefore; |
|
71 |
at: 'fn:remove' put: XQueryFnRemove; |
|
72 |
at: 'remove' put: XQueryFnRemove; |
|
73 |
at: 'fn:reverse' put: XQueryFnReverse; |
|
74 |
at: 'reverse' put: XQueryFnReverse; |
|
75 |
at: 'fn:subsequence' put: XQueryFnSubsequence; |
|
76 |
at: 'subsequence' put: XQueryFnSubsequence; |
|
77 |
at: 'fn:distinct-values' put: XQueryFnDistinctValues; |
|
78 |
at: 'distinct-values' put: XQueryFnDistinctValues; |
|
79 |
yourself. |
|
80 |
||
81 |
"Created: / 10-11-2006 / 17:18:50 / ked" |
|
82 |
"Modified: / 02-12-2006 / 13:59:20 / ked" |
|
83 |
! ! |
|
84 |
||
85 |
!XQueryFuncTable methodsFor:'accessing'! |
|
86 |
||
87 |
defineFunction: anXQueryFunction |
|
88 |
||
89 |
(self tableForNamespace: anXQueryFunction namespaceURI) |
|
90 |
at: anXQueryFunction localName put: anXQueryFunction |
|
91 |
||
92 |
"Created: / 28-12-2006 / 12:28:03 / janfrog" |
|
93 |
! |
|
94 |
||
241
e28ef0f20186
Branch datatypes reintegrated
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
235
diff
changeset
|
95 |
functionWithNamespaceURI:nsURI localName:localName |
e28ef0f20186
Branch datatypes reintegrated
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
235
diff
changeset
|
96 |
^ (self tableForNamespace:nsURI) at:localName |
e28ef0f20186
Branch datatypes reintegrated
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
235
diff
changeset
|
97 |
ifAbsent:[ FunctionError raiseErrorString:'function not found' ]. |
235 | 98 |
|
99 |
"Created: / 28-12-2006 / 12:30:55 / janfrog" |
|
241
e28ef0f20186
Branch datatypes reintegrated
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
235
diff
changeset
|
100 |
"Modified: / 30-12-2009 / 13:42:35 / Jan Kurs <kursj1@fel.cvut.cz>" |
235 | 101 |
! |
102 |
||
103 |
table |
|
104 |
table isNil ifTrue:[ |
|
105 |
table := self class defaultTable. |
|
106 |
]. |
|
107 |
^ table |
|
108 |
||
109 |
"Created: / 10-11-2006 / 17:18:50 / ked" |
|
110 |
! |
|
111 |
||
112 |
table:something |
|
113 |
table := something. |
|
114 |
||
115 |
"Created: / 10-11-2006 / 17:18:50 / ked" |
|
116 |
! ! |
|
117 |
||
118 |
!XQueryFuncTable methodsFor:'evaluation'! |
|
119 |
||
120 |
evaluate:qName inContext:givenContext withParameters:parametersCollection forInterpreter:interpreter |
|
121 |
|function functionName| |
|
122 |
||
123 |
functionName := XMLv2::NodeName |
|
124 |
fromString:qName |
|
125 |
andPrefixToNamespaceURIMapping:interpreter prefixToNamespaceURIMapping |
|
126 |
defaultNS:interpreter defaultFunctionNamespaceURI. |
|
127 |
function := self functionWithNamespaceURI:functionName ns |
|
128 |
localName:functionName localName. |
|
129 |
function ifNil:[ self error:qName + ' - function not found'. ]. |
|
130 |
^ function |
|
131 |
evaluateInContext: givenContext |
|
132 |
withParameters:parametersCollection |
|
133 |
forInterpreter:interpreter |
|
134 |
||
135 |
"Modified: / 02-12-2006 / 12:20:04 / ked" |
|
136 |
"Created: / 28-08-2007 / 22:48:21 / janfrog" |
|
137 |
! ! |
|
138 |
||
139 |
!XQueryFuncTable methodsFor:'initialization'! |
|
140 |
||
141 |
initialize |
|
142 |
"Invoked when a new instance is created." |
|
143 |
||
144 |
"/ please change as required (and remove this comment) |
|
145 |
"/ table := nil. |
|
146 |
||
147 |
"/ super initialize. -- commented since inherited method does nothing |
|
148 |
table := Dictionary new. |
|
149 |
||
150 |
"Created: / 28-12-2006 / 12:28:13 / janfrog" |
|
151 |
! ! |
|
152 |
||
153 |
!XQueryFuncTable methodsFor:'private'! |
|
154 |
||
155 |
tableForNamespace: namespaceURI |
|
156 |
||
157 |
||
158 |
^table |
|
159 |
at: namespaceURI |
|
160 |
ifAbsentPut:[Dictionary new] |
|
161 |
||
162 |
"Created: / 28-12-2006 / 12:29:36 / janfrog" |
|
163 |
! ! |
|
164 |
||
165 |
!XQueryFuncTable class methodsFor:'documentation'! |
|
166 |
||
241
e28ef0f20186
Branch datatypes reintegrated
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
235
diff
changeset
|
167 |
version_SVN |
e28ef0f20186
Branch datatypes reintegrated
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
235
diff
changeset
|
168 |
^ '$Id$' |
235 | 169 |
! ! |