1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the  "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 // Base class header file
19 #include "XPathFunctionTable.hpp"
20 
21 
22 
23 #include <cstring>
24 
25 
26 
27 #include <xalanc/PlatformSupport/DOMStringHelper.hpp>
28 #include <xalanc/PlatformSupport/XalanMessageLoader.hpp>
29 
30 
31 
32 #include "FunctionConcat.hpp"
33 #include "FunctionContains.hpp"
34 #include "FunctionID.hpp"
35 #include "FunctionLang.hpp"
36 #include "FunctionString.hpp"
37 #include "FunctionNamespaceURI.hpp"
38 #include "FunctionNormalizeSpace.hpp"
39 #include "FunctionStartsWith.hpp"
40 #include "FunctionSubstring.hpp"
41 #include "FunctionSubstringAfter.hpp"
42 #include "FunctionSubstringBefore.hpp"
43 #include "FunctionTranslate.hpp"
44 
45 
46 
47 namespace XALAN_CPP_NAMESPACE {
48 
49 
50 
51 class FunctionNotImplemented : public Function
52 {
53 public:
54 
FunctionNotImplemented(const XalanDOMChar * theName)55     FunctionNotImplemented(const XalanDOMChar*  theName) :
56         m_name(theName)
57     {
58     }
59 
60     /**
61      * Create a copy of the function object.
62      *
63      * @return pointer to the new object
64      */
65     virtual Function*
clone(MemoryManager & theManager) const66     clone(MemoryManager& theManager) const
67     {
68         typedef FunctionNotImplemented  ThisType;
69 
70         XalanAllocationGuard    theGuard(theManager, theManager.allocate(sizeof(ThisType)));
71 
72         ThisType* const     theResult =
73             new (theGuard.get()) ThisType(m_name);
74 
75         theGuard.release();
76 
77         return theResult;
78     }
79 
80 protected:
81 
82     /**
83      * Get the error message to report when
84      * the function is called with the wrong
85      * number of arguments.
86      *
87      * @return function error message
88      */
89     virtual const XalanDOMString&
getError(XalanDOMString & theResult) const90     getError(XalanDOMString& theResult) const
91     {
92         return XalanMessageLoader::getMessage(
93                     theResult,
94                     XalanMessages::FunctionIsNotImplemented_1Param,
95                     m_name);
96     }
97 
98 private:
99 
100     // Not implemented...
101     Function&
102     operator=(const Function&);
103 
104     bool
105     operator==(const Function&) const;
106 
107     const XalanDOMChar* const   m_name;
108 };
109 
110 
111 
XPathFunctionTable(bool fCreateTable)112 XPathFunctionTable::XPathFunctionTable( bool fCreateTable) :
113     m_memoryManager(0),
114     m_functionTable(),
115     m_functionTableEnd(m_functionTable + (sizeof(m_functionTable) / sizeof(m_functionTable[0])) - 1)
116 {
117     assert(int(s_functionNamesSize) == TableSize);
118 
119     std::memset(m_functionTable, 0, sizeof(m_functionTable));
120 
121     if (fCreateTable == true)
122     {
123         CreateTable();
124     }
125 }
126 
127 
128 
~XPathFunctionTable()129 XPathFunctionTable::~XPathFunctionTable()
130 {
131     DestroyTable();
132 }
133 
134 
135 
136 void
InstallFunction(const XalanDOMChar * theFunctionName,const Function & theFunction)137 XPathFunctionTable::InstallFunction(
138             const XalanDOMChar*     theFunctionName,
139             const Function&         theFunction)
140 {
141     const int   theFunctionID =
142             getFunctionIndex(theFunctionName);
143 
144     assert (m_memoryManager != 0);
145 
146     if (theFunctionID == InvalidFunctionNumberID)
147     {
148         XalanDOMString theResult(*m_memoryManager);
149 
150         throw XPathExceptionFunctionNotSupported(
151                 theFunctionName,
152                 theResult,
153                 0);
154     }
155     else
156     {
157         if (m_functionTable[theFunctionID] == 0)
158         {
159             m_functionTable[theFunctionID] = theFunction.clone(*m_memoryManager);
160         }
161         else
162         {
163             const Function* const   theOldFunction = m_functionTable[theFunctionID];
164 
165             m_functionTable[theFunctionID] = theFunction.clone(*m_memoryManager);
166 
167             const_cast<Function*>(theOldFunction)->~Function();
168 
169             m_memoryManager->deallocate((void*)theOldFunction);
170         }
171     }
172 }
173 
174 
175 
176 bool
UninstallFunction(const XalanDOMChar * theFunctionName)177 XPathFunctionTable::UninstallFunction(const XalanDOMChar*   theFunctionName)
178 {
179     const int   theFunctionID =
180             getFunctionIndex(theFunctionName);
181 
182     if (theFunctionID == InvalidFunctionNumberID)
183     {
184         return false;
185     }
186     else
187     {
188         Function* const theFunction =
189             const_cast<Function*>(m_functionTable[theFunctionID]);
190 
191         if (theFunction != 0)
192         {
193             m_functionTable[theFunctionID] = 0;
194 
195             XalanDestroy(
196                 *m_memoryManager,
197                 *theFunction);
198         }
199 
200         return true;
201     }
202 }
203 
204 
205 
206 #if 0
207 #include <fstream>
208 
209 void
210 dumpTable(
211             const XPathFunctionTable::FunctionNameIndexMapType&     theTable,
212             std::ostream&                                           theSourceStream,
213             std::ostream&                                           theHeaderStream)
214 {
215     XPathFunctionTable::FunctionNameIndexMapType::const_iterator    i = theTable.begin();
216 
217     while(i != theTable.end())
218     {
219         theSourceStream << "const XalanDOMChar\tXPathFunctionTable::s_";
220 
221         const XalanDOMString&   theString = (*i).first;
222 
223         theHeaderStream << "\t// The string \"" << theString << "\"\n\tstatic const XalanDOMChar\ts_";
224 
225         bool    nextCap = false;
226 
227         XalanDOMString::const_iterator  j = theString.begin();
228 
229         while(*j)
230         {
231             if (*j == '-')
232             {
233                 nextCap = true;
234             }
235             else
236             {
237                 assert(*j >= 'a' && *j <= 'z');
238 
239                 if (nextCap)
240                 {
241                     theSourceStream << char(*j -'a' + 'A');
242                     theHeaderStream << char(*j -'a' + 'A');
243 
244                     nextCap = false;
245                 }
246                 else
247                 {
248                     theSourceStream << char(*j);
249                     theHeaderStream << char(*j);
250                 }
251             }
252 
253             ++j;
254         }
255 
256         j = theString.begin();
257 
258         theSourceStream << "[] =\n{\n";
259         theHeaderStream << "[];\n\n";
260 
261         while(*j)
262         {
263             if (*j == '-')
264             {
265                 theSourceStream << "\tXalanUnicode::charHyphenMinus,\n";
266             }
267             else
268             {
269                 assert(*j >= 'a' && *j <= 'z');
270 
271                 theSourceStream << "\tXalanUnicode::charLetter_";
272 
273                 theSourceStream << char(*j) << ",\n";
274             }
275 
276             ++j;
277         }
278 
279         theSourceStream << "\t0\n};\n\n";
280 
281         ++i;
282     }
283 }
284 #endif
285 
286 
287 
288 void
CreateTable()289 XPathFunctionTable::CreateTable()
290 {
291     try
292     {
293         InstallFunction(
294                 s_id,
295                 FunctionID());
296 
297         InstallFunction(
298                 s_key,
299                 FunctionNotImplemented(s_key));
300 
301         InstallFunction(
302                 s_not,
303                 FunctionNotImplemented(s_not));
304 
305         InstallFunction(
306                 s_sum,
307                 FunctionNotImplemented(s_sum));
308 
309         InstallFunction(
310                 s_lang,
311                 FunctionLang());
312 
313         InstallFunction(
314                 s_last,
315                 FunctionNotImplemented(s_last));
316 
317         InstallFunction(
318                 s_name,
319                 FunctionNotImplemented(s_name));
320 
321         InstallFunction(
322                 s_true,
323                 FunctionNotImplemented(s_true));
324 
325         InstallFunction(
326                 s_count,
327                 FunctionNotImplemented(s_count));
328 
329         InstallFunction(
330                 s_false,
331                 FunctionNotImplemented(s_false));
332 
333         InstallFunction(
334                 s_floor,
335                 FunctionNotImplemented(s_floor));
336 
337         InstallFunction(
338                 s_round,
339                 FunctionNotImplemented(s_round));
340 
341         InstallFunction(
342                 s_concat,
343                 FunctionConcat());
344 
345         InstallFunction(
346                 s_number,
347                 FunctionNotImplemented(s_number));
348 
349         InstallFunction(
350                 s_string,
351                 FunctionString());
352 
353         InstallFunction(
354                 s_boolean,
355                 FunctionNotImplemented(s_boolean));
356 
357         InstallFunction(
358                 s_ceiling,
359                 FunctionNotImplemented(s_ceiling));
360 
361         InstallFunction(
362                 s_current,
363                 FunctionNotImplemented(s_current));
364 
365         InstallFunction(
366                 s_contains,
367                 FunctionContains());
368 
369         InstallFunction(
370                 s_document,
371                 FunctionNotImplemented(s_document));
372 
373         InstallFunction(
374                 s_position,
375                 FunctionNotImplemented(s_position));
376 
377         InstallFunction(
378                 s_substring,
379                 FunctionSubstring());
380 
381         InstallFunction(
382                 s_translate,
383                 FunctionTranslate());
384 
385         InstallFunction(
386                 s_localName,
387                 FunctionNotImplemented(s_localName));
388 
389         InstallFunction(
390                 s_generateId,
391                 FunctionNotImplemented(s_generateId));
392 
393         InstallFunction(
394                 s_startsWith,
395                 FunctionStartsWith());
396 
397         InstallFunction(
398                 s_formatNumber,
399                 FunctionNotImplemented(s_formatNumber));
400 
401         InstallFunction(
402                 s_namespaceUri,
403                 FunctionNamespaceURI());
404 
405         InstallFunction(
406                 s_stringLength,
407                 FunctionNotImplemented(s_stringLength));
408 
409         InstallFunction(
410                 s_normalizeSpace,
411                 FunctionNormalizeSpace());
412 
413         InstallFunction(
414                 s_substringAfter,
415                 FunctionSubstringAfter());
416 
417         InstallFunction(
418                 s_systemProperty,
419                 FunctionNotImplemented(s_systemProperty));
420 
421         InstallFunction(
422                 s_substringBefore,
423                 FunctionSubstringBefore());
424 
425         InstallFunction(
426                 s_elementAvailable,
427                 FunctionNotImplemented(s_elementAvailable));
428 
429         InstallFunction(
430                 s_functionAvailable,
431                 FunctionNotImplemented(s_functionAvailable));
432 
433         InstallFunction(
434                 s_unparsedEntityUri,
435                 FunctionNotImplemented(s_unparsedEntityUri));
436 
437 #if 0
438         std::ofstream   theSourceStream("\\foo.cpp");
439         std::ofstream   theHeaderStream("\\foo.hpp");
440 
441         dumpTable(m_FunctionNameIndex, theSourceStream, theHeaderStream);
442 #endif
443     }
444     catch(...)
445     {
446         DestroyTable();
447 
448         throw;
449     }
450 }
451 
452 
453 
454 void
DestroyTable()455 XPathFunctionTable::DestroyTable()
456 {
457     try
458     {
459         using std::for_each;
460 
461         for_each(
462             m_functionTable,
463             m_functionTable + TableSize,
464             DeleteFunctorType(*m_memoryManager));
465 
466         std::memset(m_functionTable, 0, sizeof(m_functionTable));
467     }
468     catch(...)
469     {
470     }
471 }
472 
473 
474 
475 int
getFunctionIndex(const XalanDOMChar * theName,StringSizeType theNameLength)476 XPathFunctionTable::getFunctionIndex(
477             const XalanDOMChar*     theName,
478             StringSizeType          theNameLength)
479 {
480     assert(theName != 0);
481 
482     // Do a binary search...
483     const FunctionNameTableEntry*   theFirst = s_functionNames;
484     const FunctionNameTableEntry*   theLast = s_lastFunctionName;
485 
486     while(theFirst <= theLast)
487     {
488         const FunctionNameTableEntry* const     theCurrent =
489             theFirst + (theLast - theFirst) / 2;
490         assert(theCurrent->m_size == length(theCurrent->m_name));
491 
492         const int   theResult = compare(
493                 theName,
494                 theNameLength,
495                 theCurrent->m_name,
496                 theCurrent->m_size);
497 
498         if (theResult < 0)
499         {
500             theLast = theCurrent - 1;
501         }
502         else if (theResult > 0)
503         {
504             theFirst = theCurrent + 1;
505         }
506         else
507         {
508             assert(int(theCurrent - s_functionNames) == theCurrent - s_functionNames);
509 
510             return int(theCurrent - s_functionNames);
511         }
512     }
513 
514     return InvalidFunctionNumberID;
515 }
516 
517 
518 
XPathExceptionFunctionNotAvailable(const XalanDOMString & theFunctionNumber,XalanDOMString & theResult,const Locator * theLocator)519 XPathExceptionFunctionNotAvailable::XPathExceptionFunctionNotAvailable(
520             const XalanDOMString&   theFunctionNumber,
521             XalanDOMString&         theResult,
522             const Locator*          theLocator) :
523     XalanXPathException(
524         XalanMessageLoader::getMessage(
525             theResult,
526             XalanMessages::FunctionNumberIsNotAvailable_1Param,
527             theFunctionNumber),
528         theResult.getMemoryManager(),
529         theLocator)
530 {
531 }
532 
533 
534 
XPathExceptionFunctionNotAvailable(const XPathExceptionFunctionNotAvailable & other)535 XPathExceptionFunctionNotAvailable::XPathExceptionFunctionNotAvailable(const XPathExceptionFunctionNotAvailable& other) :
536     XalanXPathException(other)
537 {
538 }
539 
540 
541 
~XPathExceptionFunctionNotAvailable()542 XPathExceptionFunctionNotAvailable::~XPathExceptionFunctionNotAvailable()
543 {
544 }
545 
546 
547 
548 
XPathExceptionFunctionNotSupported(const XalanDOMChar * theFunctionName,XalanDOMString & theResult,const Locator * theLocator)549 XPathExceptionFunctionNotSupported::XPathExceptionFunctionNotSupported(
550             const XalanDOMChar*     theFunctionName,
551             XalanDOMString&         theResult,
552             const Locator*          theLocator) :
553     XalanXPathException(
554         XalanMessageLoader::getMessage(
555             theResult,
556             XalanMessages::FunctionIsNotSupported_1Param,
557             theFunctionName),
558         theResult.getMemoryManager(),
559         theLocator)
560 {
561 }
562 
563 
564 
XPathExceptionFunctionNotSupported(const XPathExceptionFunctionNotSupported & other)565 XPathExceptionFunctionNotSupported::XPathExceptionFunctionNotSupported(const XPathExceptionFunctionNotSupported& other) :
566     XalanXPathException(other)
567 {
568 }
569 
570 
571 
~XPathExceptionFunctionNotSupported()572 XPathExceptionFunctionNotSupported::~XPathExceptionFunctionNotSupported()
573 {
574 }
575 
576 
577 
578 
579 const XalanDOMChar  XPathFunctionTable::s_id[] =
580 {
581     XalanUnicode::charLetter_i,
582     XalanUnicode::charLetter_d,
583     0
584 };
585 
586 const XalanDOMChar  XPathFunctionTable::s_key[] =
587 {
588     XalanUnicode::charLetter_k,
589     XalanUnicode::charLetter_e,
590     XalanUnicode::charLetter_y,
591     0
592 };
593 
594 const XalanDOMChar  XPathFunctionTable::s_not[] =
595 {
596     XalanUnicode::charLetter_n,
597     XalanUnicode::charLetter_o,
598     XalanUnicode::charLetter_t,
599     0
600 };
601 
602 const XalanDOMChar  XPathFunctionTable::s_sum[] =
603 {
604     XalanUnicode::charLetter_s,
605     XalanUnicode::charLetter_u,
606     XalanUnicode::charLetter_m,
607     0
608 };
609 
610 const XalanDOMChar  XPathFunctionTable::s_lang[] =
611 {
612     XalanUnicode::charLetter_l,
613     XalanUnicode::charLetter_a,
614     XalanUnicode::charLetter_n,
615     XalanUnicode::charLetter_g,
616     0
617 };
618 
619 const XalanDOMChar  XPathFunctionTable::s_last[] =
620 {
621     XalanUnicode::charLetter_l,
622     XalanUnicode::charLetter_a,
623     XalanUnicode::charLetter_s,
624     XalanUnicode::charLetter_t,
625     0
626 };
627 
628 const XalanDOMChar  XPathFunctionTable::s_name[] =
629 {
630     XalanUnicode::charLetter_n,
631     XalanUnicode::charLetter_a,
632     XalanUnicode::charLetter_m,
633     XalanUnicode::charLetter_e,
634     0
635 };
636 
637 const XalanDOMChar  XPathFunctionTable::s_true[] =
638 {
639     XalanUnicode::charLetter_t,
640     XalanUnicode::charLetter_r,
641     XalanUnicode::charLetter_u,
642     XalanUnicode::charLetter_e,
643     0
644 };
645 
646 const XalanDOMChar  XPathFunctionTable::s_count[] =
647 {
648     XalanUnicode::charLetter_c,
649     XalanUnicode::charLetter_o,
650     XalanUnicode::charLetter_u,
651     XalanUnicode::charLetter_n,
652     XalanUnicode::charLetter_t,
653     0
654 };
655 
656 const XalanDOMChar  XPathFunctionTable::s_false[] =
657 {
658     XalanUnicode::charLetter_f,
659     XalanUnicode::charLetter_a,
660     XalanUnicode::charLetter_l,
661     XalanUnicode::charLetter_s,
662     XalanUnicode::charLetter_e,
663     0
664 };
665 
666 const XalanDOMChar  XPathFunctionTable::s_floor[] =
667 {
668     XalanUnicode::charLetter_f,
669     XalanUnicode::charLetter_l,
670     XalanUnicode::charLetter_o,
671     XalanUnicode::charLetter_o,
672     XalanUnicode::charLetter_r,
673     0
674 };
675 
676 const XalanDOMChar  XPathFunctionTable::s_round[] =
677 {
678     XalanUnicode::charLetter_r,
679     XalanUnicode::charLetter_o,
680     XalanUnicode::charLetter_u,
681     XalanUnicode::charLetter_n,
682     XalanUnicode::charLetter_d,
683     0
684 };
685 
686 const XalanDOMChar  XPathFunctionTable::s_concat[] =
687 {
688     XalanUnicode::charLetter_c,
689     XalanUnicode::charLetter_o,
690     XalanUnicode::charLetter_n,
691     XalanUnicode::charLetter_c,
692     XalanUnicode::charLetter_a,
693     XalanUnicode::charLetter_t,
694     0
695 };
696 
697 const XalanDOMChar  XPathFunctionTable::s_number[] =
698 {
699     XalanUnicode::charLetter_n,
700     XalanUnicode::charLetter_u,
701     XalanUnicode::charLetter_m,
702     XalanUnicode::charLetter_b,
703     XalanUnicode::charLetter_e,
704     XalanUnicode::charLetter_r,
705     0
706 };
707 
708 const XalanDOMChar  XPathFunctionTable::s_string[] =
709 {
710     XalanUnicode::charLetter_s,
711     XalanUnicode::charLetter_t,
712     XalanUnicode::charLetter_r,
713     XalanUnicode::charLetter_i,
714     XalanUnicode::charLetter_n,
715     XalanUnicode::charLetter_g,
716     0
717 };
718 
719 const XalanDOMChar  XPathFunctionTable::s_boolean[] =
720 {
721     XalanUnicode::charLetter_b,
722     XalanUnicode::charLetter_o,
723     XalanUnicode::charLetter_o,
724     XalanUnicode::charLetter_l,
725     XalanUnicode::charLetter_e,
726     XalanUnicode::charLetter_a,
727     XalanUnicode::charLetter_n,
728     0
729 };
730 
731 const XalanDOMChar  XPathFunctionTable::s_ceiling[] =
732 {
733     XalanUnicode::charLetter_c,
734     XalanUnicode::charLetter_e,
735     XalanUnicode::charLetter_i,
736     XalanUnicode::charLetter_l,
737     XalanUnicode::charLetter_i,
738     XalanUnicode::charLetter_n,
739     XalanUnicode::charLetter_g,
740     0
741 };
742 
743 const XalanDOMChar  XPathFunctionTable::s_current[] =
744 {
745     XalanUnicode::charLetter_c,
746     XalanUnicode::charLetter_u,
747     XalanUnicode::charLetter_r,
748     XalanUnicode::charLetter_r,
749     XalanUnicode::charLetter_e,
750     XalanUnicode::charLetter_n,
751     XalanUnicode::charLetter_t,
752     0
753 };
754 
755 const XalanDOMChar  XPathFunctionTable::s_contains[] =
756 {
757     XalanUnicode::charLetter_c,
758     XalanUnicode::charLetter_o,
759     XalanUnicode::charLetter_n,
760     XalanUnicode::charLetter_t,
761     XalanUnicode::charLetter_a,
762     XalanUnicode::charLetter_i,
763     XalanUnicode::charLetter_n,
764     XalanUnicode::charLetter_s,
765     0
766 };
767 
768 const XalanDOMChar  XPathFunctionTable::s_document[] =
769 {
770     XalanUnicode::charLetter_d,
771     XalanUnicode::charLetter_o,
772     XalanUnicode::charLetter_c,
773     XalanUnicode::charLetter_u,
774     XalanUnicode::charLetter_m,
775     XalanUnicode::charLetter_e,
776     XalanUnicode::charLetter_n,
777     XalanUnicode::charLetter_t,
778     0
779 };
780 
781 const XalanDOMChar  XPathFunctionTable::s_position[] =
782 {
783     XalanUnicode::charLetter_p,
784     XalanUnicode::charLetter_o,
785     XalanUnicode::charLetter_s,
786     XalanUnicode::charLetter_i,
787     XalanUnicode::charLetter_t,
788     XalanUnicode::charLetter_i,
789     XalanUnicode::charLetter_o,
790     XalanUnicode::charLetter_n,
791     0
792 };
793 
794 const XalanDOMChar  XPathFunctionTable::s_substring[] =
795 {
796     XalanUnicode::charLetter_s,
797     XalanUnicode::charLetter_u,
798     XalanUnicode::charLetter_b,
799     XalanUnicode::charLetter_s,
800     XalanUnicode::charLetter_t,
801     XalanUnicode::charLetter_r,
802     XalanUnicode::charLetter_i,
803     XalanUnicode::charLetter_n,
804     XalanUnicode::charLetter_g,
805     0
806 };
807 
808 const XalanDOMChar  XPathFunctionTable::s_translate[] =
809 {
810     XalanUnicode::charLetter_t,
811     XalanUnicode::charLetter_r,
812     XalanUnicode::charLetter_a,
813     XalanUnicode::charLetter_n,
814     XalanUnicode::charLetter_s,
815     XalanUnicode::charLetter_l,
816     XalanUnicode::charLetter_a,
817     XalanUnicode::charLetter_t,
818     XalanUnicode::charLetter_e,
819     0
820 };
821 
822 const XalanDOMChar  XPathFunctionTable::s_localName[] =
823 {
824     XalanUnicode::charLetter_l,
825     XalanUnicode::charLetter_o,
826     XalanUnicode::charLetter_c,
827     XalanUnicode::charLetter_a,
828     XalanUnicode::charLetter_l,
829     XalanUnicode::charHyphenMinus,
830     XalanUnicode::charLetter_n,
831     XalanUnicode::charLetter_a,
832     XalanUnicode::charLetter_m,
833     XalanUnicode::charLetter_e,
834     0
835 };
836 
837 const XalanDOMChar  XPathFunctionTable::s_generateId[] =
838 {
839     XalanUnicode::charLetter_g,
840     XalanUnicode::charLetter_e,
841     XalanUnicode::charLetter_n,
842     XalanUnicode::charLetter_e,
843     XalanUnicode::charLetter_r,
844     XalanUnicode::charLetter_a,
845     XalanUnicode::charLetter_t,
846     XalanUnicode::charLetter_e,
847     XalanUnicode::charHyphenMinus,
848     XalanUnicode::charLetter_i,
849     XalanUnicode::charLetter_d,
850     0
851 };
852 
853 const XalanDOMChar  XPathFunctionTable::s_startsWith[] =
854 {
855     XalanUnicode::charLetter_s,
856     XalanUnicode::charLetter_t,
857     XalanUnicode::charLetter_a,
858     XalanUnicode::charLetter_r,
859     XalanUnicode::charLetter_t,
860     XalanUnicode::charLetter_s,
861     XalanUnicode::charHyphenMinus,
862     XalanUnicode::charLetter_w,
863     XalanUnicode::charLetter_i,
864     XalanUnicode::charLetter_t,
865     XalanUnicode::charLetter_h,
866     0
867 };
868 
869 const XalanDOMChar  XPathFunctionTable::s_formatNumber[] =
870 {
871     XalanUnicode::charLetter_f,
872     XalanUnicode::charLetter_o,
873     XalanUnicode::charLetter_r,
874     XalanUnicode::charLetter_m,
875     XalanUnicode::charLetter_a,
876     XalanUnicode::charLetter_t,
877     XalanUnicode::charHyphenMinus,
878     XalanUnicode::charLetter_n,
879     XalanUnicode::charLetter_u,
880     XalanUnicode::charLetter_m,
881     XalanUnicode::charLetter_b,
882     XalanUnicode::charLetter_e,
883     XalanUnicode::charLetter_r,
884     0
885 };
886 
887 const XalanDOMChar  XPathFunctionTable::s_namespaceUri[] =
888 {
889     XalanUnicode::charLetter_n,
890     XalanUnicode::charLetter_a,
891     XalanUnicode::charLetter_m,
892     XalanUnicode::charLetter_e,
893     XalanUnicode::charLetter_s,
894     XalanUnicode::charLetter_p,
895     XalanUnicode::charLetter_a,
896     XalanUnicode::charLetter_c,
897     XalanUnicode::charLetter_e,
898     XalanUnicode::charHyphenMinus,
899     XalanUnicode::charLetter_u,
900     XalanUnicode::charLetter_r,
901     XalanUnicode::charLetter_i,
902     0
903 };
904 
905 const XalanDOMChar  XPathFunctionTable::s_stringLength[] =
906 {
907     XalanUnicode::charLetter_s,
908     XalanUnicode::charLetter_t,
909     XalanUnicode::charLetter_r,
910     XalanUnicode::charLetter_i,
911     XalanUnicode::charLetter_n,
912     XalanUnicode::charLetter_g,
913     XalanUnicode::charHyphenMinus,
914     XalanUnicode::charLetter_l,
915     XalanUnicode::charLetter_e,
916     XalanUnicode::charLetter_n,
917     XalanUnicode::charLetter_g,
918     XalanUnicode::charLetter_t,
919     XalanUnicode::charLetter_h,
920     0
921 };
922 
923 const XalanDOMChar  XPathFunctionTable::s_normalizeSpace[] =
924 {
925     XalanUnicode::charLetter_n,
926     XalanUnicode::charLetter_o,
927     XalanUnicode::charLetter_r,
928     XalanUnicode::charLetter_m,
929     XalanUnicode::charLetter_a,
930     XalanUnicode::charLetter_l,
931     XalanUnicode::charLetter_i,
932     XalanUnicode::charLetter_z,
933     XalanUnicode::charLetter_e,
934     XalanUnicode::charHyphenMinus,
935     XalanUnicode::charLetter_s,
936     XalanUnicode::charLetter_p,
937     XalanUnicode::charLetter_a,
938     XalanUnicode::charLetter_c,
939     XalanUnicode::charLetter_e,
940     0
941 };
942 
943 const XalanDOMChar  XPathFunctionTable::s_substringAfter[] =
944 {
945     XalanUnicode::charLetter_s,
946     XalanUnicode::charLetter_u,
947     XalanUnicode::charLetter_b,
948     XalanUnicode::charLetter_s,
949     XalanUnicode::charLetter_t,
950     XalanUnicode::charLetter_r,
951     XalanUnicode::charLetter_i,
952     XalanUnicode::charLetter_n,
953     XalanUnicode::charLetter_g,
954     XalanUnicode::charHyphenMinus,
955     XalanUnicode::charLetter_a,
956     XalanUnicode::charLetter_f,
957     XalanUnicode::charLetter_t,
958     XalanUnicode::charLetter_e,
959     XalanUnicode::charLetter_r,
960     0
961 };
962 
963 const XalanDOMChar  XPathFunctionTable::s_systemProperty[] =
964 {
965     XalanUnicode::charLetter_s,
966     XalanUnicode::charLetter_y,
967     XalanUnicode::charLetter_s,
968     XalanUnicode::charLetter_t,
969     XalanUnicode::charLetter_e,
970     XalanUnicode::charLetter_m,
971     XalanUnicode::charHyphenMinus,
972     XalanUnicode::charLetter_p,
973     XalanUnicode::charLetter_r,
974     XalanUnicode::charLetter_o,
975     XalanUnicode::charLetter_p,
976     XalanUnicode::charLetter_e,
977     XalanUnicode::charLetter_r,
978     XalanUnicode::charLetter_t,
979     XalanUnicode::charLetter_y,
980     0
981 };
982 
983 const XalanDOMChar  XPathFunctionTable::s_substringBefore[] =
984 {
985     XalanUnicode::charLetter_s,
986     XalanUnicode::charLetter_u,
987     XalanUnicode::charLetter_b,
988     XalanUnicode::charLetter_s,
989     XalanUnicode::charLetter_t,
990     XalanUnicode::charLetter_r,
991     XalanUnicode::charLetter_i,
992     XalanUnicode::charLetter_n,
993     XalanUnicode::charLetter_g,
994     XalanUnicode::charHyphenMinus,
995     XalanUnicode::charLetter_b,
996     XalanUnicode::charLetter_e,
997     XalanUnicode::charLetter_f,
998     XalanUnicode::charLetter_o,
999     XalanUnicode::charLetter_r,
1000     XalanUnicode::charLetter_e,
1001     0
1002 };
1003 
1004 const XalanDOMChar  XPathFunctionTable::s_elementAvailable[] =
1005 {
1006     XalanUnicode::charLetter_e,
1007     XalanUnicode::charLetter_l,
1008     XalanUnicode::charLetter_e,
1009     XalanUnicode::charLetter_m,
1010     XalanUnicode::charLetter_e,
1011     XalanUnicode::charLetter_n,
1012     XalanUnicode::charLetter_t,
1013     XalanUnicode::charHyphenMinus,
1014     XalanUnicode::charLetter_a,
1015     XalanUnicode::charLetter_v,
1016     XalanUnicode::charLetter_a,
1017     XalanUnicode::charLetter_i,
1018     XalanUnicode::charLetter_l,
1019     XalanUnicode::charLetter_a,
1020     XalanUnicode::charLetter_b,
1021     XalanUnicode::charLetter_l,
1022     XalanUnicode::charLetter_e,
1023     0
1024 };
1025 
1026 const XalanDOMChar  XPathFunctionTable::s_functionAvailable[] =
1027 {
1028     XalanUnicode::charLetter_f,
1029     XalanUnicode::charLetter_u,
1030     XalanUnicode::charLetter_n,
1031     XalanUnicode::charLetter_c,
1032     XalanUnicode::charLetter_t,
1033     XalanUnicode::charLetter_i,
1034     XalanUnicode::charLetter_o,
1035     XalanUnicode::charLetter_n,
1036     XalanUnicode::charHyphenMinus,
1037     XalanUnicode::charLetter_a,
1038     XalanUnicode::charLetter_v,
1039     XalanUnicode::charLetter_a,
1040     XalanUnicode::charLetter_i,
1041     XalanUnicode::charLetter_l,
1042     XalanUnicode::charLetter_a,
1043     XalanUnicode::charLetter_b,
1044     XalanUnicode::charLetter_l,
1045     XalanUnicode::charLetter_e,
1046     0
1047 };
1048 
1049 const XalanDOMChar  XPathFunctionTable::s_unparsedEntityUri[] =
1050 {
1051     XalanUnicode::charLetter_u,
1052     XalanUnicode::charLetter_n,
1053     XalanUnicode::charLetter_p,
1054     XalanUnicode::charLetter_a,
1055     XalanUnicode::charLetter_r,
1056     XalanUnicode::charLetter_s,
1057     XalanUnicode::charLetter_e,
1058     XalanUnicode::charLetter_d,
1059     XalanUnicode::charHyphenMinus,
1060     XalanUnicode::charLetter_e,
1061     XalanUnicode::charLetter_n,
1062     XalanUnicode::charLetter_t,
1063     XalanUnicode::charLetter_i,
1064     XalanUnicode::charLetter_t,
1065     XalanUnicode::charLetter_y,
1066     XalanUnicode::charHyphenMinus,
1067     XalanUnicode::charLetter_u,
1068     XalanUnicode::charLetter_r,
1069     XalanUnicode::charLetter_i,
1070     0
1071 };
1072 
1073 
1074 typedef XPathFunctionTable::SizeType                SizeType;
1075 typedef XPathFunctionTable::FunctionNameTableEntry  FunctionNameTableEntry;
1076 
1077 #define XFTBL_SIZE(str) ((sizeof(str) / sizeof(str[0]) - 1))
1078 
1079 
1080 const FunctionNameTableEntry    XPathFunctionTable::s_functionNames[] =
1081 {
1082     {
1083         s_id,
1084         XFTBL_SIZE(s_id)
1085     },
1086     {
1087         s_key,
1088         XFTBL_SIZE(s_key)
1089     },
1090     {
1091         s_not,
1092         XFTBL_SIZE(s_not)
1093     },
1094     {
1095         s_sum,
1096         XFTBL_SIZE(s_sum)
1097     },
1098     {
1099         s_lang,
1100         XFTBL_SIZE(s_lang)
1101     },
1102     {
1103         s_last,
1104         XFTBL_SIZE(s_last)
1105     },
1106     {
1107         s_name,
1108         XFTBL_SIZE(s_name)
1109     },
1110     {
1111         s_true,
1112         XFTBL_SIZE(s_true)
1113     },
1114     {
1115         s_count,
1116         XFTBL_SIZE(s_count)
1117     },
1118     {
1119         s_false,
1120         XFTBL_SIZE(s_false)
1121     },
1122     {
1123         s_floor,
1124         XFTBL_SIZE(s_floor)
1125     },
1126     {
1127         s_round,
1128         XFTBL_SIZE(s_round)
1129     },
1130     {
1131         s_concat,
1132         XFTBL_SIZE(s_concat)
1133     },
1134     {
1135         s_number,
1136         XFTBL_SIZE(s_number)
1137     },
1138     {
1139         s_string,
1140         XFTBL_SIZE(s_string)
1141     },
1142     {
1143         s_boolean,
1144         XFTBL_SIZE(s_boolean)
1145     },
1146     {
1147         s_ceiling,
1148         XFTBL_SIZE(s_ceiling)
1149     },
1150     {
1151         s_current,
1152         XFTBL_SIZE(s_current)
1153     },
1154     {
1155         s_contains,
1156         XFTBL_SIZE(s_contains)
1157     },
1158     {
1159         s_document,
1160         XFTBL_SIZE(s_document)
1161     },
1162     {
1163         s_position,
1164         XFTBL_SIZE(s_position)
1165     },
1166     {
1167         s_substring,
1168         XFTBL_SIZE(s_substring)
1169     },
1170     {
1171         s_translate,
1172         XFTBL_SIZE(s_translate)
1173     },
1174     {
1175         s_localName,
1176         XFTBL_SIZE(s_localName)
1177     },
1178     {
1179         s_generateId,
1180         XFTBL_SIZE(s_generateId)
1181     },
1182     {
1183         s_startsWith,
1184         XFTBL_SIZE(s_startsWith)
1185     },
1186     {
1187         s_formatNumber,
1188         XFTBL_SIZE(s_formatNumber)
1189     },
1190     {
1191         s_namespaceUri,
1192         XFTBL_SIZE(s_namespaceUri)
1193     },
1194     {
1195         s_stringLength,
1196         XFTBL_SIZE(s_stringLength)
1197     },
1198     {
1199         s_normalizeSpace,
1200         XFTBL_SIZE(s_normalizeSpace)
1201     },
1202     {
1203         s_substringAfter,
1204         XFTBL_SIZE(s_substringAfter)
1205     },
1206     {
1207         s_systemProperty,
1208         XFTBL_SIZE(s_systemProperty)
1209     },
1210     {
1211         s_substringBefore,
1212         XFTBL_SIZE(s_substringBefore)
1213     },
1214     {
1215         s_elementAvailable,
1216         XFTBL_SIZE(s_elementAvailable)
1217     },
1218     {
1219         s_functionAvailable,
1220         XFTBL_SIZE(s_functionAvailable)
1221     },
1222     {
1223         s_unparsedEntityUri,
1224         XFTBL_SIZE(s_unparsedEntityUri)
1225     }
1226 };
1227 
1228 
1229 const FunctionNameTableEntry* const     XPathFunctionTable::s_lastFunctionName =
1230     &s_functionNames[sizeof(s_functionNames) / sizeof(s_functionNames[0]) - 1];
1231 
1232 
1233 const SizeType      XPathFunctionTable::s_functionNamesSize =
1234     sizeof(s_functionNames) / sizeof(s_functionNames[0]);
1235 
1236 
1237 
1238 }
1239