001: package net.sf.saxon.functions;
002:
003: import net.sf.saxon.expr.StaticProperty;
004: import net.sf.saxon.pattern.NodeKindTest;
005: import net.sf.saxon.type.ItemType;
006: import net.sf.saxon.type.Type;
007: import net.sf.saxon.value.SequenceType;
008:
009: import java.util.HashMap;
010:
011: /**
012: * This class contains static data tables defining the properties of standard functions. "Standard functions"
013: * here means the XPath 2.0 functions, the XSLT 2.0 functions, and a few selected extension functions
014: * which need special recognition.
015: */
016:
017: public abstract class StandardFunction {
018:
019: /**
020: * This class is never instantiated
021: */
022:
023: private StandardFunction() {
024: }
025:
026: /**
027: * Register a system function in the table of function details.
028: * @param name the function name
029: * @param implementationClass the class used to implement the function
030: * @param opcode identifies the function when a single class implements several functions
031: * @param minArguments the minimum number of arguments required
032: * @param maxArguments the maximum number of arguments allowed
033: * @param itemType the item type of the result of the function
034: * @param cardinality the cardinality of the result of the function
035: * @return the entry describing the function. The entry is incomplete, it does not yet contain information
036: * about the function arguments.
037: */
038:
039: private static Entry register(String name,
040: Class implementationClass, int opcode, int minArguments,
041: int maxArguments, ItemType itemType, int cardinality) {
042: Entry e = makeEntry(name, implementationClass, opcode,
043: minArguments, maxArguments, itemType, cardinality);
044: functionTable.put(name, e);
045: return e;
046: }
047:
048: /**
049: * Make a table entry describing the signature of a function, with a reference to the implementation class.
050: * @param name the function name
051: * @param implementationClass the class used to implement the function
052: * @param opcode identifies the function when a single class implements several functions
053: * @param minArguments the minimum number of arguments required
054: * @param maxArguments the maximum number of arguments allowed
055: * @param itemType the item type of the result of the function
056: * @param cardinality the cardinality of the result of the function
057: * @return the entry describing the function. The entry is incomplete, it does not yet contain information
058: * about the function arguments.
059: */
060: public static Entry makeEntry(String name,
061: Class implementationClass, int opcode, int minArguments,
062: int maxArguments, ItemType itemType, int cardinality) {
063: Entry e = new Entry();
064: int hash = name.indexOf('#');
065: if (hash < 0) {
066: e.name = name;
067: } else {
068: e.name = name.substring(0, hash);
069: }
070: e.implementationClass = implementationClass;
071: e.opcode = opcode;
072: e.minArguments = minArguments;
073: e.maxArguments = maxArguments;
074: e.itemType = itemType;
075: e.cardinality = cardinality;
076: if (maxArguments > 100) {
077: // special case for concat()
078: e.argumentTypes = new SequenceType[1];
079: } else {
080: e.argumentTypes = new SequenceType[maxArguments];
081: }
082: return e;
083: }
084:
085: /**
086: * Add information to a function entry about the argument types of the function
087: * @param e the entry for the function
088: * @param a the position of the argument, counting from zero
089: * @param type the item type of the argument
090: * @param cardinality the cardinality of the argument
091: */
092:
093: public static void arg(Entry e, int a, ItemType type,
094: int cardinality) {
095: try {
096: e.argumentTypes[a] = SequenceType.makeSequenceType(type,
097: cardinality);
098: } catch (ArrayIndexOutOfBoundsException err) {
099: System.err
100: .println("Internal Saxon error: Can't set argument "
101: + a + " of " + e.name);
102: }
103: }
104:
105: private static HashMap functionTable = new HashMap(200);
106:
107: protected static ItemType SAME_AS_FIRST_ARGUMENT = NodeKindTest.NAMESPACE;
108: // this could be any item type that is used only for this purpose
109:
110: static {
111: Entry e;
112: e = register("abs", Rounding.class, Rounding.ABS, 1, 1,
113: SAME_AS_FIRST_ARGUMENT,
114: StaticProperty.ALLOWS_ZERO_OR_ONE);
115: arg(e, 0, Type.NUMBER_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
116:
117: e = register("adjust-date-to-timezone", Adjust.class, 0, 1, 2,
118: Type.DATE_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
119: arg(e, 0, Type.DATE_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
120: arg(e, 1, Type.DAY_TIME_DURATION_TYPE,
121: StaticProperty.ALLOWS_ZERO_OR_ONE);
122:
123: e = register("adjust-dateTime-to-timezone", Adjust.class, 0, 1,
124: 2, Type.DATE_TIME_TYPE,
125: StaticProperty.ALLOWS_ZERO_OR_ONE);
126: arg(e, 0, Type.DATE_TIME_TYPE,
127: StaticProperty.ALLOWS_ZERO_OR_ONE);
128: arg(e, 1, Type.DAY_TIME_DURATION_TYPE,
129: StaticProperty.ALLOWS_ZERO_OR_ONE);
130:
131: e = register("adjust-time-to-timezone", Adjust.class, 0, 1, 2,
132: Type.TIME_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
133: arg(e, 0, Type.TIME_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
134: arg(e, 1, Type.DAY_TIME_DURATION_TYPE,
135: StaticProperty.ALLOWS_ZERO_OR_ONE);
136:
137: e = register("avg", Aggregate.class, Aggregate.AVG, 1, 1,
138: Type.ANY_ATOMIC_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
139: // can't say "same as first argument" because the avg of a set of integers is decimal
140: arg(e, 0, Type.ANY_ATOMIC_TYPE,
141: StaticProperty.ALLOWS_ZERO_OR_MORE);
142:
143: e = register("base-uri", BaseURI.class, 0, 0, 1,
144: Type.ANY_URI_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
145: arg(e, 0, Type.NODE_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
146:
147: e = register("boolean", BooleanFn.class, BooleanFn.BOOLEAN, 1,
148: 1, Type.BOOLEAN_TYPE, StaticProperty.EXACTLY_ONE);
149: arg(e, 0, Type.ITEM_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
150:
151: e = register("ceiling", Rounding.class, Rounding.CEILING, 1, 1,
152: SAME_AS_FIRST_ARGUMENT,
153: StaticProperty.ALLOWS_ZERO_OR_ONE);
154: arg(e, 0, Type.NUMBER_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
155:
156: e = register("codepoint-equal", CodepointEqual.class, 0, 2, 2,
157: Type.BOOLEAN_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
158: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
159: arg(e, 1, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
160:
161: e = register("codepoints-to-string", Unicode.class,
162: Unicode.FROM_CODEPOINTS, 1, 1, Type.STRING_TYPE,
163: StaticProperty.EXACTLY_ONE);
164: arg(e, 0, Type.INTEGER_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
165:
166: e = register("collection", Collection.class, 0, 0, 1,
167: Type.NODE_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
168: arg(e, 0, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
169:
170: e = register("compare", Compare.class, 0, 2, 3,
171: Type.INTEGER_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
172: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
173: arg(e, 1, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
174: arg(e, 2, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
175:
176: e = register("concat", Concat.class, 0, 2, Integer.MAX_VALUE,
177: Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
178: arg(e, 0, Type.ANY_ATOMIC_TYPE,
179: StaticProperty.ALLOWS_ZERO_OR_ONE);
180: // Note, this has a variable number of arguments so it is treated specially
181:
182: e = register("contains", Contains.class, Contains.CONTAINS, 2,
183: 3, Type.BOOLEAN_TYPE, StaticProperty.EXACTLY_ONE);
184: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
185: arg(e, 1, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
186: arg(e, 2, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
187:
188: e = register("count", Aggregate.class, Aggregate.COUNT, 1, 1,
189: Type.INTEGER_TYPE, StaticProperty.EXACTLY_ONE);
190: arg(e, 0, Type.ITEM_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
191:
192: register("current", Current.class, 0, 0, 0, Type.ITEM_TYPE,
193: StaticProperty.EXACTLY_ONE);
194: register("current-date", CurrentDateTime.class, 0, 0, 0,
195: Type.DATE_TYPE, StaticProperty.EXACTLY_ONE);
196: register("current-dateTime", CurrentDateTime.class, 0, 0, 0,
197: Type.DATE_TIME_TYPE, StaticProperty.EXACTLY_ONE);
198: register("current-time", CurrentDateTime.class, 0, 0, 0,
199: Type.TIME_TYPE, StaticProperty.EXACTLY_ONE);
200:
201: register("current-group", CurrentGroup.class,
202: CurrentGroup.CURRENT_GROUP, 0, 0, Type.ITEM_TYPE,
203: StaticProperty.ALLOWS_ZERO_OR_MORE);
204: register("current-grouping-key", CurrentGroup.class,
205: CurrentGroup.CURRENT_GROUPING_KEY, 0, 0,
206: Type.ANY_ATOMIC_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
207:
208: e = register("data", Data.class, 0, 1, 1, Type.ANY_ATOMIC_TYPE,
209: StaticProperty.ALLOWS_ZERO_OR_MORE);
210: arg(e, 0, Type.ITEM_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
211:
212: e = register("dateTime", DateTimeConstructor.class, 0, 2, 2,
213: Type.DATE_TIME_TYPE, StaticProperty.EXACTLY_ONE);
214: arg(e, 0, Type.DATE_TYPE, StaticProperty.EXACTLY_ONE);
215: arg(e, 1, Type.TIME_TYPE, StaticProperty.EXACTLY_ONE);
216:
217: e = register("day-from-date", Component.class,
218: (Component.DAY << 16) + Type.DATE, 1, 1,
219: Type.INTEGER_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
220: arg(e, 0, Type.DATE_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
221:
222: e = register("day-from-dateTime", Component.class,
223: (Component.DAY << 16) + Type.DATE_TIME, 1, 1,
224: Type.INTEGER_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
225: arg(e, 0, Type.DATE_TIME_TYPE,
226: StaticProperty.ALLOWS_ZERO_OR_ONE);
227:
228: e = register("days-from-duration", Component.class,
229: (Component.DAY << 16) + Type.DAY_TIME_DURATION, 1, 1,
230: Type.INTEGER_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
231: arg(e, 0, Type.DAY_TIME_DURATION_TYPE,
232: StaticProperty.ALLOWS_ZERO_OR_ONE);
233:
234: e = register("deep-equal", DeepEqual.class, 0, 2, 3,
235: Type.BOOLEAN_TYPE, StaticProperty.EXACTLY_ONE);
236: arg(e, 0, Type.ITEM_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
237: arg(e, 1, Type.ITEM_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
238: arg(e, 2, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
239:
240: register("default-collation", DefaultCollation.class, 0, 0, 0,
241: Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
242:
243: e = register("distinct-values", DistinctValues.class, 0, 1, 2,
244: Type.ANY_ATOMIC_TYPE,
245: StaticProperty.ALLOWS_ZERO_OR_MORE);
246: arg(e, 0, Type.ANY_ATOMIC_TYPE,
247: StaticProperty.ALLOWS_ZERO_OR_MORE);
248: arg(e, 1, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
249:
250: e = register("doc", Doc.class, Doc.DOC, 1, 1,
251: NodeKindTest.DOCUMENT,
252: StaticProperty.ALLOWS_ZERO_OR_ONE);
253: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
254:
255: e = register("doc-available", Doc.class, Doc.DOC_AVAILABLE, 1,
256: 1, Type.BOOLEAN_TYPE, StaticProperty.EXACTLY_ONE);
257: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
258:
259: e = register("document", Document.class, 0, 1, 2,
260: Type.NODE_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
261: arg(e, 0, Type.ITEM_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
262: arg(e, 1, Type.NODE_TYPE, StaticProperty.EXACTLY_ONE);
263:
264: e = register("document-uri", NamePart.class,
265: NamePart.DOCUMENT_URI, 1, 1, Type.ANY_URI_TYPE,
266: StaticProperty.ALLOWS_ZERO_OR_ONE);
267: arg(e, 0, Type.NODE_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
268:
269: e = register("empty", Existence.class, Existence.EMPTY, 1, 1,
270: Type.BOOLEAN_TYPE, StaticProperty.EXACTLY_ONE);
271: arg(e, 0, Type.ITEM_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
272:
273: e = register("ends-with", Contains.class, Contains.ENDSWITH, 2,
274: 3, Type.BOOLEAN_TYPE, StaticProperty.EXACTLY_ONE);
275: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
276: arg(e, 1, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
277: arg(e, 2, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
278:
279: e = register("element-available", Available.class,
280: Available.ELEMENT_AVAILABLE, 1, 1, Type.BOOLEAN_TYPE,
281: StaticProperty.EXACTLY_ONE);
282: arg(e, 0, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
283:
284: e = register("encode-for-uri", EscapeURI.class,
285: EscapeURI.ENCODE_FOR_URI, 1, 1, Type.STRING_TYPE,
286: StaticProperty.EXACTLY_ONE);
287: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
288:
289: e = register("escape-html-uri", EscapeURI.class,
290: EscapeURI.HTML_URI, 1, 1, Type.STRING_TYPE,
291: StaticProperty.EXACTLY_ONE);
292: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
293:
294: e = register("error", Error.class, 0, 0, 3, Type.ITEM_TYPE,
295: StaticProperty.EXACTLY_ONE);
296: // The return type is chosen so that use of the error() function will never give a static type error.
297: arg(e, 0, Type.QNAME_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
298: arg(e, 1, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
299: arg(e, 2, Type.ITEM_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
300:
301: // e = register("escape-uri", EscapeURI.class, EscapeURI.ESCAPE, 2, 2, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
302: // arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
303: // arg(e, 1, Type.BOOLEAN_TYPE, StaticProperty.EXACTLY_ONE);
304:
305: e = register("exactly-one", TreatFn.class,
306: StaticProperty.EXACTLY_ONE, 1, 1,
307: SAME_AS_FIRST_ARGUMENT, StaticProperty.EXACTLY_ONE);
308: arg(e, 0, Type.ITEM_TYPE, StaticProperty.EXACTLY_ONE);
309: // because we don't do draconian static type checking, we can do the work in the argument type checking code
310:
311: e = register("exists", Existence.class, Existence.EXISTS, 1, 1,
312: Type.BOOLEAN_TYPE, StaticProperty.EXACTLY_ONE);
313: arg(e, 0, Type.ITEM_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
314:
315: register("false", BooleanFn.class, BooleanFn.FALSE, 0, 0,
316: Type.BOOLEAN_TYPE, StaticProperty.EXACTLY_ONE);
317:
318: e = register("floor", Rounding.class, Rounding.FLOOR, 1, 1,
319: SAME_AS_FIRST_ARGUMENT,
320: StaticProperty.ALLOWS_ZERO_OR_ONE);
321: arg(e, 0, Type.NUMBER_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
322:
323: e = register("format-date", FormatDate.class, Type.DATE, 2, 5,
324: Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
325: arg(e, 0, Type.DATE_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
326: arg(e, 1, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
327: arg(e, 2, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
328: arg(e, 3, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
329: arg(e, 4, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
330:
331: e = register("format-dateTime", FormatDate.class,
332: Type.DATE_TIME, 2, 5, Type.STRING_TYPE,
333: StaticProperty.EXACTLY_ONE);
334: arg(e, 0, Type.DATE_TIME_TYPE,
335: StaticProperty.ALLOWS_ZERO_OR_ONE);
336: arg(e, 1, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
337: arg(e, 2, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
338: arg(e, 3, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
339: arg(e, 4, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
340:
341: e = register("format-number", FormatNumber2.class, 0, 2, 3,
342: Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
343: arg(e, 0, Type.NUMBER_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
344: arg(e, 1, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
345: arg(e, 2, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
346:
347: e = register("format-time", FormatDate.class, Type.TIME, 2, 5,
348: Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
349: arg(e, 0, Type.TIME_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
350: arg(e, 1, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
351: arg(e, 2, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
352: arg(e, 3, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
353: arg(e, 4, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
354:
355: e = register("function-available", Available.class,
356: Available.FUNCTION_AVAILABLE, 1, 2, Type.BOOLEAN_TYPE,
357: StaticProperty.EXACTLY_ONE);
358: arg(e, 0, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
359: arg(e, 1, Type.INTEGER_TYPE, StaticProperty.EXACTLY_ONE);
360:
361: e = register("generate-id", NamePart.class,
362: NamePart.GENERATE_ID, 0, 1, Type.STRING_TYPE,
363: StaticProperty.EXACTLY_ONE);
364: arg(e, 0, Type.NODE_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
365:
366: e = register("hours-from-dateTime", Component.class,
367: (Component.HOURS << 16) + Type.DATE_TIME, 1, 1,
368: Type.INTEGER_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
369: arg(e, 0, Type.DATE_TIME_TYPE,
370: StaticProperty.ALLOWS_ZERO_OR_ONE);
371:
372: e = register("hours-from-duration", Component.class,
373: (Component.HOURS << 16) + Type.DAY_TIME_DURATION, 1, 1,
374: Type.INTEGER_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
375: arg(e, 0, Type.DAY_TIME_DURATION_TYPE,
376: StaticProperty.ALLOWS_ZERO_OR_ONE);
377:
378: e = register("hours-from-time", Component.class,
379: (Component.HOURS << 16) + Type.TIME, 1, 1,
380: Type.INTEGER_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
381: arg(e, 0, Type.TIME_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
382:
383: e = register("id", Id.class, 0, 1, 2, NodeKindTest.ELEMENT,
384: StaticProperty.ALLOWS_ZERO_OR_MORE);
385: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
386: arg(e, 1, Type.NODE_TYPE, StaticProperty.EXACTLY_ONE);
387:
388: e = register("idref", Idref.class, 0, 1, 2, Type.NODE_TYPE,
389: StaticProperty.ALLOWS_ZERO_OR_MORE);
390: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
391: arg(e, 1, Type.NODE_TYPE, StaticProperty.EXACTLY_ONE);
392:
393: register("implicit-timezone", CurrentDateTime.class, 0, 0, 0,
394: Type.DAY_TIME_DURATION_TYPE, StaticProperty.EXACTLY_ONE);
395:
396: e = register("in-scope-prefixes", InScopePrefixes.class, 0, 1,
397: 1, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
398: arg(e, 0, NodeKindTest.ELEMENT, StaticProperty.EXACTLY_ONE);
399:
400: e = register("index-of", IndexOf.class, 0, 2, 3,
401: Type.INTEGER_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
402: arg(e, 0, Type.ANY_ATOMIC_TYPE,
403: StaticProperty.ALLOWS_ZERO_OR_MORE);
404: arg(e, 1, Type.ANY_ATOMIC_TYPE, StaticProperty.EXACTLY_ONE);
405: arg(e, 2, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
406:
407: e = register("insert-before", Insert.class, 0, 3, 3,
408: Type.ITEM_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
409: arg(e, 0, Type.ITEM_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
410: arg(e, 1, Type.INTEGER_TYPE, StaticProperty.EXACTLY_ONE);
411: arg(e, 2, Type.ITEM_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
412:
413: e = register("iri-to-uri", EscapeURI.class,
414: EscapeURI.IRI_TO_URI, 1, 1, Type.STRING_TYPE,
415: StaticProperty.EXACTLY_ONE);
416: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
417:
418: e = register("key", KeyFn.class, 0, 2, 3, Type.NODE_TYPE,
419: StaticProperty.ALLOWS_ZERO_OR_MORE);
420: arg(e, 0, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
421: arg(e, 1, Type.ANY_ATOMIC_TYPE,
422: StaticProperty.ALLOWS_ZERO_OR_MORE);
423: arg(e, 2, Type.NODE_TYPE, StaticProperty.EXACTLY_ONE);
424:
425: e = register("lang", Lang.class, 0, 1, 2, Type.BOOLEAN_TYPE,
426: StaticProperty.EXACTLY_ONE);
427: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
428: arg(e, 1, Type.NODE_TYPE, StaticProperty.EXACTLY_ONE);
429:
430: register("last", Last.class, 0, 0, 0, Type.INTEGER_TYPE,
431: StaticProperty.EXACTLY_ONE);
432:
433: e = register("local-name", NamePart.class, NamePart.LOCAL_NAME,
434: 0, 1, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
435: arg(e, 0, Type.NODE_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
436:
437: e = register("local-name-from-QName", Component.class,
438: (Component.LOCALNAME << 16) + Type.QNAME, 1, 1,
439: Type.NCNAME_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
440: arg(e, 0, Type.QNAME_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
441:
442: e = register("lower-case", ForceCase.class,
443: ForceCase.LOWERCASE, 1, 1, Type.STRING_TYPE,
444: StaticProperty.EXACTLY_ONE);
445: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
446:
447: e = register("matches", Matches.class, 0, 2, 3,
448: Type.BOOLEAN_TYPE, StaticProperty.EXACTLY_ONE);
449: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
450: arg(e, 1, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
451: arg(e, 2, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
452:
453: e = register("max", Minimax.class, Minimax.MAX, 1, 2,
454: SAME_AS_FIRST_ARGUMENT,
455: StaticProperty.ALLOWS_ZERO_OR_ONE);
456: arg(e, 0, Type.ANY_ATOMIC_TYPE,
457: StaticProperty.ALLOWS_ZERO_OR_MORE);
458: arg(e, 1, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
459:
460: e = register("min", Minimax.class, Minimax.MIN, 1, 2,
461: SAME_AS_FIRST_ARGUMENT,
462: StaticProperty.ALLOWS_ZERO_OR_ONE);
463: arg(e, 0, Type.ANY_ATOMIC_TYPE,
464: StaticProperty.ALLOWS_ZERO_OR_MORE);
465: arg(e, 1, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
466:
467: e = register("minutes-from-dateTime", Component.class,
468: (Component.MINUTES << 16) + Type.DATE_TIME, 1, 1,
469: Type.INTEGER_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
470: arg(e, 0, Type.DATE_TIME_TYPE,
471: StaticProperty.ALLOWS_ZERO_OR_ONE);
472:
473: e = register("minutes-from-duration", Component.class,
474: (Component.MINUTES << 16) + Type.DAY_TIME_DURATION, 1,
475: 1, Type.INTEGER_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
476: arg(e, 0, Type.DAY_TIME_DURATION_TYPE,
477: StaticProperty.ALLOWS_ZERO_OR_ONE);
478:
479: e = register("minutes-from-time", Component.class,
480: (Component.MINUTES << 16) + Type.TIME, 1, 1,
481: Type.INTEGER_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
482: arg(e, 0, Type.TIME_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
483:
484: e = register("month-from-date", Component.class,
485: (Component.MONTH << 16) + Type.DATE, 1, 1,
486: Type.INTEGER_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
487: arg(e, 0, Type.DATE_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
488:
489: e = register("month-from-dateTime", Component.class,
490: (Component.MONTH << 16) + Type.DATE_TIME, 1, 1,
491: Type.INTEGER_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
492: arg(e, 0, Type.DATE_TIME_TYPE,
493: StaticProperty.ALLOWS_ZERO_OR_ONE);
494:
495: e = register("months-from-duration", Component.class,
496: (Component.MONTH << 16) + Type.YEAR_MONTH_DURATION, 1,
497: 1, Type.INTEGER_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
498: arg(e, 0, Type.YEAR_MONTH_DURATION_TYPE,
499: StaticProperty.ALLOWS_ZERO_OR_ONE);
500:
501: e = register("name", NamePart.class, NamePart.NAME, 0, 1,
502: Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
503: arg(e, 0, Type.NODE_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
504:
505: e = register("namespace-uri", NamePart.class,
506: NamePart.NAMESPACE_URI, 0, 1, Type.ANY_URI_TYPE,
507: StaticProperty.EXACTLY_ONE);
508: arg(e, 0, Type.NODE_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
509:
510: e = register("namespace-uri-for-prefix",
511: NamespaceForPrefix.class, 0, 2, 2, Type.ANY_URI_TYPE,
512: StaticProperty.ALLOWS_ZERO_OR_ONE);
513: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
514: arg(e, 1, NodeKindTest.ELEMENT, StaticProperty.EXACTLY_ONE);
515:
516: e = register("namespace-uri-from-QName", Component.class,
517: (Component.NAMESPACE << 16) + Type.QNAME, 1, 1,
518: Type.ANY_URI_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
519: arg(e, 0, Type.QNAME_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
520:
521: e = register("nilled", Nilled.class, 0, 1, 1,
522: Type.BOOLEAN_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
523: arg(e, 0, Type.NODE_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
524:
525: e = register("node-name", NamePart.class, NamePart.NODE_NAME,
526: 0, 1, Type.QNAME_TYPE,
527: StaticProperty.ALLOWS_ZERO_OR_ONE);
528: arg(e, 0, Type.NODE_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
529:
530: e = register("not", BooleanFn.class, BooleanFn.NOT, 1, 1,
531: Type.BOOLEAN_TYPE, StaticProperty.EXACTLY_ONE);
532: arg(e, 0, Type.ITEM_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
533:
534: register("normalize-space", NormalizeSpace.class, 0, 0, 1,
535: Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
536: register("normalize-space#0", NormalizeSpace.class, 0, 0, 0,
537: Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
538:
539: e = register("normalize-space#1", NormalizeSpace.class, 0, 1,
540: 1, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
541: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
542:
543: e = register("normalize-unicode", NormalizeUnicode.class, 0, 1,
544: 2, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
545: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
546: arg(e, 1, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
547:
548: e = register("number", NumberFn.class, 0, 0, 1,
549: Type.DOUBLE_TYPE, StaticProperty.EXACTLY_ONE);
550: arg(e, 0, Type.ITEM_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
551:
552: e = register("one-or-more", TreatFn.class,
553: StaticProperty.ALLOWS_ONE_OR_MORE, 1, 1,
554: SAME_AS_FIRST_ARGUMENT,
555: StaticProperty.ALLOWS_ONE_OR_MORE);
556: arg(e, 0, Type.ITEM_TYPE, StaticProperty.ALLOWS_ONE_OR_MORE);
557: // because we don't do draconian static type checking, we can do the work in the argument type checking code
558:
559: register("position", Position.class, 0, 0, 0,
560: Type.INTEGER_TYPE, StaticProperty.EXACTLY_ONE);
561:
562: e = register("prefix-from-QName", Component.class,
563: (Component.PREFIX << 16) + Type.QNAME, 1, 1,
564: Type.NCNAME_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
565: arg(e, 0, Type.QNAME_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
566:
567: e = register("QName", QNameFn.class, 0, 2, 2, Type.QNAME_TYPE,
568: StaticProperty.EXACTLY_ONE);
569: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
570: arg(e, 1, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
571:
572: e = register("regex-group", RegexGroup.class, 0, 1, 1,
573: Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
574: arg(e, 0, Type.INTEGER_TYPE, StaticProperty.EXACTLY_ONE);
575:
576: e = register("remove", Remove.class, 0, 2, 2,
577: SAME_AS_FIRST_ARGUMENT,
578: StaticProperty.ALLOWS_ZERO_OR_MORE);
579: arg(e, 0, Type.ITEM_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
580: arg(e, 1, Type.INTEGER_TYPE, StaticProperty.EXACTLY_ONE);
581:
582: e = register("replace", Replace.class, 0, 3, 4,
583: Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
584: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
585: arg(e, 1, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
586: arg(e, 2, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
587: arg(e, 3, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
588:
589: e = register("resolve-QName", ResolveQName.class, 0, 2, 2,
590: Type.QNAME_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
591: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
592: arg(e, 1, NodeKindTest.ELEMENT, StaticProperty.EXACTLY_ONE);
593:
594: e = register("resolve-uri", ResolveURI.class, 0, 1, 2,
595: Type.ANY_URI_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
596: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
597: arg(e, 1, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
598:
599: e = register("reverse", Reverse.class, 0, 1, 1, Type.ITEM_TYPE,
600: StaticProperty.ALLOWS_ZERO_OR_MORE);
601: arg(e, 0, Type.ITEM_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
602:
603: e = register("root", Root.class, 0, 0, 1, Type.NODE_TYPE,
604: StaticProperty.ALLOWS_ZERO_OR_ONE);
605: arg(e, 0, Type.NODE_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
606:
607: e = register("round", Rounding.class, Rounding.ROUND, 1, 1,
608: SAME_AS_FIRST_ARGUMENT,
609: StaticProperty.ALLOWS_ZERO_OR_ONE);
610: arg(e, 0, Type.NUMBER_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
611:
612: e = register("round-half-to-even", Rounding.class,
613: Rounding.HALF_EVEN, 1, 2, SAME_AS_FIRST_ARGUMENT,
614: StaticProperty.ALLOWS_ZERO_OR_ONE);
615: arg(e, 0, Type.NUMBER_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
616: arg(e, 1, Type.INTEGER_TYPE, StaticProperty.EXACTLY_ONE);
617:
618: e = register("seconds-from-dateTime", Component.class,
619: (Component.SECONDS << 16) + Type.DATE_TIME, 1, 1,
620: Type.DECIMAL_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
621: arg(e, 0, Type.DATE_TIME_TYPE,
622: StaticProperty.ALLOWS_ZERO_OR_ONE);
623:
624: e = register("seconds-from-duration", Component.class,
625: (Component.SECONDS << 16) + Type.DAY_TIME_DURATION, 1,
626: 1, Type.DECIMAL_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
627: arg(e, 0, Type.DAY_TIME_DURATION_TYPE,
628: StaticProperty.ALLOWS_ZERO_OR_ONE);
629:
630: e = register("seconds-from-time", Component.class,
631: (Component.SECONDS << 16) + Type.TIME, 1, 1,
632: Type.DECIMAL_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
633: arg(e, 0, Type.TIME_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
634:
635: e = register("starts-with", Contains.class,
636: Contains.STARTSWITH, 2, 3, Type.BOOLEAN_TYPE,
637: StaticProperty.EXACTLY_ONE);
638: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
639: arg(e, 1, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
640: arg(e, 2, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
641:
642: register("static-base-uri", StaticBaseURI.class, 0, 0, 0,
643: Type.ANY_URI_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
644:
645: e = register("string", StringFn.class, 0, 0, 1,
646: Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
647: arg(e, 0, Type.ITEM_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
648:
649: register("string-length", StringLength.class, 0, 0, 1,
650: Type.INTEGER_TYPE, StaticProperty.EXACTLY_ONE);
651: register("string-length#0", StringLength.class, 0, 0, 0,
652: Type.INTEGER_TYPE, StaticProperty.EXACTLY_ONE);
653:
654: e = register("string-length#1", StringLength.class, 0, 1, 1,
655: Type.INTEGER_TYPE, StaticProperty.EXACTLY_ONE);
656: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
657:
658: e = register("string-join", StringJoin.class, 0, 2, 2,
659: Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
660: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
661: arg(e, 1, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
662:
663: e = register("string-to-codepoints", Unicode.class,
664: Unicode.TO_CODEPOINTS, 1, 1, Type.INTEGER_TYPE,
665: StaticProperty.ALLOWS_ZERO_OR_MORE);
666: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
667:
668: e = register("subsequence", Subsequence.class, 0, 2, 3,
669: SAME_AS_FIRST_ARGUMENT,
670: StaticProperty.ALLOWS_ZERO_OR_MORE);
671: arg(e, 0, Type.ITEM_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
672: arg(e, 1, Type.NUMBER_TYPE, StaticProperty.EXACTLY_ONE);
673: arg(e, 2, Type.NUMBER_TYPE, StaticProperty.EXACTLY_ONE);
674:
675: e = register("substring", Substring.class, 0, 2, 3,
676: Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
677: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
678: arg(e, 1, Type.NUMBER_TYPE, StaticProperty.EXACTLY_ONE);
679: arg(e, 2, Type.NUMBER_TYPE, StaticProperty.EXACTLY_ONE);
680:
681: e = register("substring-after", Contains.class, Contains.AFTER,
682: 2, 3, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
683: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
684: arg(e, 1, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
685: arg(e, 2, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
686:
687: e = register("substring-before", Contains.class,
688: Contains.BEFORE, 2, 3, Type.STRING_TYPE,
689: StaticProperty.EXACTLY_ONE);
690: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
691: arg(e, 1, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
692: arg(e, 2, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
693:
694: e = register("sum", Aggregate.class, Aggregate.SUM, 1, 2,
695: Type.ANY_ATOMIC_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
696: arg(e, 0, Type.ANY_ATOMIC_TYPE,
697: StaticProperty.ALLOWS_ZERO_OR_MORE);
698: arg(e, 1, Type.ANY_ATOMIC_TYPE,
699: StaticProperty.ALLOWS_ZERO_OR_ONE);
700:
701: e = register("system-property", SystemProperty.class, 0, 1, 1,
702: Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
703: arg(e, 0, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
704:
705: e = register("timezone-from-date", Component.class,
706: (Component.TIMEZONE << 16) + Type.DATE, 1, 1,
707: Type.DAY_TIME_DURATION_TYPE,
708: StaticProperty.ALLOWS_ZERO_OR_ONE);
709: arg(e, 0, Type.DATE_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
710:
711: e = register("timezone-from-dateTime", Component.class,
712: (Component.TIMEZONE << 16) + Type.DATE_TIME, 1, 1,
713: Type.DAY_TIME_DURATION_TYPE,
714: StaticProperty.ALLOWS_ZERO_OR_ONE);
715: arg(e, 0, Type.DATE_TIME_TYPE,
716: StaticProperty.ALLOWS_ZERO_OR_ONE);
717:
718: e = register("timezone-from-time", Component.class,
719: (Component.TIMEZONE << 16) + Type.TIME, 1, 1,
720: Type.DAY_TIME_DURATION_TYPE,
721: StaticProperty.ALLOWS_ZERO_OR_ONE);
722: arg(e, 0, Type.TIME_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
723:
724: e = register("trace", Trace.class, 0, 2, 2,
725: SAME_AS_FIRST_ARGUMENT,
726: StaticProperty.ALLOWS_ZERO_OR_MORE);
727: arg(e, 0, Type.ITEM_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
728: arg(e, 1, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
729:
730: register("true", BooleanFn.class, BooleanFn.TRUE, 0, 0,
731: Type.BOOLEAN_TYPE, StaticProperty.EXACTLY_ONE);
732:
733: e = register("translate", Translate.class, 0, 3, 3,
734: Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
735: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
736: arg(e, 1, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
737: arg(e, 2, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
738:
739: e = register("tokenize", Tokenize.class, 0, 2, 3,
740: Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
741: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
742: arg(e, 1, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
743: arg(e, 2, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
744:
745: e = register("unordered", Unordered.class, 0, 1, 1,
746: SAME_AS_FIRST_ARGUMENT,
747: StaticProperty.ALLOWS_ZERO_OR_MORE);
748: arg(e, 0, Type.ITEM_TYPE, StaticProperty.ALLOWS_ZERO_OR_MORE);
749:
750: e = register("upper-case", ForceCase.class,
751: ForceCase.UPPERCASE, 1, 1, Type.STRING_TYPE,
752: StaticProperty.EXACTLY_ONE);
753: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
754:
755: e = register("unparsed-entity-uri", UnparsedEntity.class,
756: UnparsedEntity.URI, 1, 1, Type.ANY_URI_TYPE,
757: StaticProperty.EXACTLY_ONE);
758: arg(e, 0, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
759:
760: // internal version of unparsed-entity-uri with second argument representing the current document
761: e = register("unparsed-entity-uri_9999_", UnparsedEntity.class,
762: UnparsedEntity.URI, 2, 2, Type.STRING_TYPE,
763: StaticProperty.EXACTLY_ONE);
764: arg(e, 0, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
765: arg(e, 1, NodeKindTest.DOCUMENT, StaticProperty.EXACTLY_ONE);
766:
767: e = register("unparsed-entity-public-id", UnparsedEntity.class,
768: UnparsedEntity.PUBLIC_ID, 1, 1, Type.STRING_TYPE,
769: StaticProperty.EXACTLY_ONE);
770: arg(e, 0, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
771:
772: // internal version of unparsed-entity-public-id with second argument representing the current document
773: e = register("unparsed-entity-public-id_9999_",
774: UnparsedEntity.class, UnparsedEntity.PUBLIC_ID, 2, 2,
775: Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
776: arg(e, 0, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
777: arg(e, 1, NodeKindTest.DOCUMENT, StaticProperty.EXACTLY_ONE);
778:
779: e = register("unparsed-text", UnparsedText.class,
780: UnparsedText.UNPARSED_TEXT, 1, 2, Type.STRING_TYPE,
781: StaticProperty.ALLOWS_ZERO_OR_ONE);
782: arg(e, 0, Type.STRING_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
783: arg(e, 1, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
784:
785: e = register("unparsed-text-available", UnparsedText.class,
786: UnparsedText.UNPARSED_TEXT_AVAILABLE, 1, 2,
787: Type.BOOLEAN_TYPE, StaticProperty.EXACTLY_ONE);
788: arg(e, 0, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
789: arg(e, 1, Type.STRING_TYPE, StaticProperty.EXACTLY_ONE);
790:
791: e = register("year-from-date", Component.class,
792: (Component.YEAR << 16) + Type.DATE, 1, 1,
793: Type.INTEGER_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
794: arg(e, 0, Type.DATE_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
795:
796: e = register("year-from-dateTime", Component.class,
797: (Component.YEAR << 16) + Type.DATE_TIME, 1, 1,
798: Type.INTEGER_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
799: arg(e, 0, Type.DATE_TIME_TYPE,
800: StaticProperty.ALLOWS_ZERO_OR_ONE);
801:
802: e = register("years-from-duration", Component.class,
803: (Component.YEAR << 16) + Type.YEAR_MONTH_DURATION, 1,
804: 1, Type.INTEGER_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
805: arg(e, 0, Type.YEAR_MONTH_DURATION_TYPE,
806: StaticProperty.ALLOWS_ZERO_OR_ONE);
807:
808: e = register("zero-or-one", TreatFn.class,
809: StaticProperty.ALLOWS_ZERO_OR_ONE, 1, 1,
810: SAME_AS_FIRST_ARGUMENT,
811: StaticProperty.ALLOWS_ZERO_OR_ONE);
812: arg(e, 0, Type.ITEM_TYPE, StaticProperty.ALLOWS_ZERO_OR_ONE);
813: // because we don't do draconian static type checking, we can do the work in the argument type checking code
814: }
815:
816: /**
817: * Get the table entry for the function with a given name
818: * @param name the name of the function. This may be an unprefixed local-name for functions in the
819: * system namespace, or may use the conventional prefix "saxon:" in the case of Saxon extension functions
820: * that are specially recognized
821: * @return if the function name is known, an Entry containing information about the function. Otherwise,
822: * null
823: */
824:
825: public static Entry getFunction(String name, int arity) {
826: // try first for an entry of the form name#arity
827: Entry e = (Entry) functionTable.get(name + '#' + arity);
828: if (e != null) {
829: return e;
830: }
831: // try for a generic entry
832: return (Entry) functionTable.get(name);
833: }
834:
835: /**
836: * An entry in the table describing the properties of a function
837: */
838: public static class Entry implements java.io.Serializable {
839: /**
840: * The name of the function: a local name in the case of functions in the standard library, or a
841: * name with the conventional prefix "saxon:" in the case of Saxon extension functions
842: */
843: public String name;
844: /**
845: * The class containing the implementation of this function (always a subclass of SystemFunction)
846: */
847: public Class implementationClass;
848: /**
849: * Some classes support more than one function. In these cases the particular function is defined
850: * by an integer opcode, whose meaning is local to the implementation class.
851: */
852: public int opcode;
853: /**
854: * The minimum number of arguments required
855: */
856: public int minArguments;
857: /**
858: * The maximum number of arguments permitted
859: */
860: public int maxArguments;
861: /**
862: * The item type of the result of the function
863: */
864: public ItemType itemType;
865: /**
866: * The cardinality of the result of the function
867: */
868: public int cardinality;
869: /**
870: * An array holding the types of the arguments to the function
871: */
872: public SequenceType[] argumentTypes;
873: }
874: }
875:
876: //
877: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License];
878: // you may not use this file except in compliance with the License. You may obtain a copy of the
879: // License at http://www.mozilla.org/MPL/
880: //
881: // Software distributed under the License is distributed on an "AS IS" basis,
882: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
883: // See the License for the specific language governing rights and limitations under the License.
884: //
885: // The Original Code is: all this file.
886: //
887: // The Initial Developer of the Original Code is Michael Kay
888: //
889: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
890: //
891: // Contributor(s): none.
892: //
|