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 
19 #include "StylesheetConstructionContextDefault.hpp"
20 
21 
22 
23 #include <algorithm>
24 
25 
26 
27 #include <xalanc/Include/STLHelper.hpp>
28 
29 
30 
31 #include <xalanc/PlatformSupport/StringTokenizer.hpp>
32 #include <xalanc/PlatformSupport/URISupport.hpp>
33 #include <xalanc/PlatformSupport/XalanMessageLoader.hpp>
34 
35 
36 
37 #include <xalanc/DOMSupport/DOMServices.hpp>
38 
39 
40 
41 #include <xalanc/XPath/XObjectFactory.hpp>
42 #include <xalanc/XPath/XPathEnvSupport.hpp>
43 #include <xalanc/XPath/XPathFactory.hpp>
44 #include <xalanc/XPath/XPathProcessorImpl.hpp>
45 
46 
47 
48 #include "Constants.hpp"
49 #include "ElemApplyImport.hpp"
50 #include "ElemChoose.hpp"
51 #include "ElemComment.hpp"
52 #include "ElemCopy.hpp"
53 #include "ElemCopyOf.hpp"
54 #include "ElemDecimalFormat.hpp"
55 #include "ElemExtensionCall.hpp"
56 #include "ElemFallback.hpp"
57 #include "ElemForwardCompatible.hpp"
58 #include "ElemForEach.hpp"
59 #include "ElemIf.hpp"
60 #include "ElemMessage.hpp"
61 #include "ElemNumber.hpp"
62 #include "ElemOtherwise.hpp"
63 #include "ElemParam.hpp"
64 #include "ElemPI.hpp"
65 #include "ElemSort.hpp"
66 #include "ElemWhen.hpp"
67 #include "ElemWithParam.hpp"
68 #include "StylesheetRoot.hpp"
69 #include "XSLTEngineImpl.hpp"
70 #include "XSLTInputSource.hpp"
71 
72 
73 
74 namespace XALAN_CPP_NAMESPACE {
75 
76 
77 
StylesheetConstructionContextDefault(MemoryManager & theManager,XSLTEngineImpl & processor,XPathFactory & xpathFactory,VectorAllocatorSizeType theXalanDOMCharVectorAllocatorBlockSize,XalanAVTAllocator::size_type theAVTAllocatorBlockSize,XalanAVTPartSimpleAllocator::size_type theAVTPartSimpleAllocatorBlockSize,XalanAVTPartXPathAllocator::size_type theAVTPartXPathAllocatorBlockSize,XalanQNameByValueAllocator::size_type theXalanQNameByValueAllocatorBlockSize,VectorAllocatorSizeType thePointerVectorAllocatorBlockSize)78 StylesheetConstructionContextDefault::StylesheetConstructionContextDefault(
79             MemoryManager&                      theManager,
80             XSLTEngineImpl&                         processor,
81             XPathFactory&                           xpathFactory,
82             VectorAllocatorSizeType                 theXalanDOMCharVectorAllocatorBlockSize,
83             XalanAVTAllocator::size_type            theAVTAllocatorBlockSize,
84             XalanAVTPartSimpleAllocator::size_type  theAVTPartSimpleAllocatorBlockSize,
85             XalanAVTPartXPathAllocator::size_type   theAVTPartXPathAllocatorBlockSize,
86             XalanQNameByValueAllocator::size_type   theXalanQNameByValueAllocatorBlockSize,
87             VectorAllocatorSizeType                 thePointerVectorAllocatorBlockSize) :
88     StylesheetConstructionContext(theManager),
89     m_processor(processor),
90     m_xpathFactory(xpathFactory),
91     m_xpathProcessor(
92         theManager,
93         XPathProcessorImpl::create(theManager)),
94     m_stylesheets(theManager),
95     m_stringPool(theManager),
96     m_xalanDOMCharVectorAllocator(
97         theManager,
98         theXalanDOMCharVectorAllocatorBlockSize),
99     m_tempBuffer(theManager),
100     m_scratchQName(theManager),
101     m_stringCache(theManager),
102     m_avtAllocator(
103         theManager,
104         theAVTAllocatorBlockSize),
105     m_avtPartSimpleAllocator(
106         theManager,
107         theAVTPartSimpleAllocatorBlockSize),
108     m_avtPartXPathAllocator(
109         theManager,
110         theAVTPartXPathAllocatorBlockSize),
111     m_xalanQNameByValueAllocator(
112         theManager,
113         theXalanQNameByValueAllocatorBlockSize),
114     m_useAttributeSetsQName(
115         XSLTEngineImpl::getXSLNameSpaceURL(),
116         Constants::ATTRNAME_USEATTRIBUTESETS),
117     m_pointerVectorAllocator(
118         theManager,
119         thePointerVectorAllocatorBlockSize),
120     m_allocatedElements(theManager),
121     m_elemApplyTemplatesAllocator(
122         theManager,
123         eDefaultElemApplyTemplatesBlockSize),
124     m_elemAttributeAllocator(
125         theManager,
126         eDefaultElemAttributeBlockSize),
127     m_elemAttributeSetAllocator(
128         theManager,
129         eDefaultElemAttributeSetBlockSize),
130     m_elemCallTemplateAllocator(
131         theManager,
132         eDefaultElemCallTemplateBlockSize),
133     m_elemElementAllocator(
134         theManager,
135         eDefaultElemElementBlockSize),
136     m_elemLiteralResultAllocator(
137         theManager,
138         eDefaultElemLiteralResultBlockSize),
139     m_elemTemplateAllocator(
140         theManager,
141         eDefaultElemTemplateBlockSize),
142     m_elemTextLiteralAllocator(
143         theManager,
144         eDefaultElemTextLiteralBlockSize),
145     m_elemValueOfAllocator(
146         theManager,
147         eDefaultElemValueOfBlockSize),
148     m_elemVariableAllocator(
149         theManager,
150         eDefaultElemVariableBlockSize),
151     m_matchPatternDataAllocator(
152         theManager,
153         eDefaultMatchPatternDataBlockSize),
154     m_spaceAttrQName(
155         DOMServices::s_XMLNamespaceURI,
156         Constants::ATTRNAME_SPACE)
157 {
158 }
159 
160 
161 
~StylesheetConstructionContextDefault()162 StylesheetConstructionContextDefault::~StylesheetConstructionContextDefault()
163 {
164     reset();
165 }
166 
167 
168 
169 void
problem(eSource source,eClassification classification,const XalanDOMString & msg,const Locator * locator,const XalanNode * sourceNode)170 StylesheetConstructionContextDefault::problem(
171             eSource                 source,
172             eClassification         classification,
173             const XalanDOMString&   msg,
174             const Locator*          locator,
175             const XalanNode*        sourceNode)
176 {
177     m_processor.problem(
178         source,
179         classification,
180         msg,
181         locator,
182         sourceNode);
183 }
184 
185 
186 
187 void
problem(eSource source,eClassification classification,const XalanDOMString & msg,const XalanNode * sourceNode)188 StylesheetConstructionContextDefault::problem(
189             eSource                 source,
190             eClassification         classification,
191             const XalanDOMString&   msg,
192             const XalanNode*        sourceNode)
193 {
194     m_processor.problem(
195         source,
196         classification,
197         msg,
198         sourceNode);
199 }
200 
201 
202 
203 void
reset()204 StylesheetConstructionContextDefault::reset()
205 {
206     using std::for_each;
207 
208     for_each(
209             m_stylesheets.begin(),
210             m_stylesheets.end(),
211             DeleteFunctor<StylesheetRoot>(getMemoryManager()));
212 
213     m_stylesheets.clear();
214 
215     for_each(
216             m_allocatedElements.begin(),
217             m_allocatedElements.end(),
218             DeleteFunctor<ElemTemplateElement>(getMemoryManager()));
219 
220     m_allocatedElements.clear();
221 
222     m_xpathFactory.reset();
223 
224     m_stringPool.clear();
225 
226     m_stringCache.reset();
227 
228     m_avtAllocator.reset();
229 
230     m_avtPartSimpleAllocator.reset();
231 
232     m_avtPartXPathAllocator.reset();
233 
234     m_xalanQNameByValueAllocator.reset();
235 
236     m_pointerVectorAllocator.reset();
237 
238     m_elemApplyTemplatesAllocator.reset();
239 
240     m_elemAttributeAllocator.reset();
241 
242     m_elemAttributeSetAllocator.reset();
243 
244     m_elemCallTemplateAllocator.reset();
245 
246     m_elemElementAllocator.reset();
247 
248     m_elemLiteralResultAllocator.reset();
249 
250     m_elemTemplateAllocator.reset();
251 
252     m_elemTextLiteralAllocator.reset();
253 
254     m_elemValueOfAllocator.reset();
255 
256     m_elemVariableAllocator.reset();
257 
258     m_matchPatternDataAllocator.reset();
259 }
260 
261 
262 
263 StylesheetRoot*
create(const XalanDOMString & theBaseIdentifier)264 StylesheetConstructionContextDefault::create(const XalanDOMString&  theBaseIdentifier)
265 {
266     m_stylesheets.reserve(m_stylesheets.size() + 1);
267 
268     StylesheetRoot* const   theStylesheetRoot =
269         StylesheetRoot::create(
270             getMemoryManager(),
271             theBaseIdentifier,
272             *this);
273 
274     m_stylesheets.push_back(theStylesheetRoot);
275 
276     return theStylesheetRoot;
277 }
278 
279 
280 
281 StylesheetRoot*
create(const XSLTInputSource & theInputSource)282 StylesheetConstructionContextDefault::create(const XSLTInputSource&     theInputSource)
283 {
284     const XMLCh* const  theSystemID =
285                 theInputSource.getSystemId();
286 
287     const GetCachedString   theGuard(*this);
288 
289     XalanDOMString& theBaseIdentifier = theGuard.get();
290 
291     if (theSystemID != 0)
292     {
293         theBaseIdentifier.assign(theSystemID);
294     }
295 
296 
297     return create(theBaseIdentifier);
298 }
299 
300 
301 
302 Stylesheet*
create(StylesheetRoot & theStylesheetRoot,const XalanDOMString & theBaseIdentifier)303 StylesheetConstructionContextDefault::create(
304             StylesheetRoot&         theStylesheetRoot,
305             const XalanDOMString&   theBaseIdentifier)
306 {
307     Stylesheet* const   theStylesheet =
308         Stylesheet::create(
309             getMemoryManager(),
310             theStylesheetRoot,
311             theBaseIdentifier,
312             *this);
313 
314     return theStylesheet;
315 }
316 
317 
318 
319 void
destroy(StylesheetRoot * theStylesheetRoot)320 StylesheetConstructionContextDefault::destroy(StylesheetRoot*   theStylesheetRoot)
321 {
322     using std::find;
323 
324     const StylesheetVectorType::iterator    i =
325         find(
326             m_stylesheets.begin(),
327             m_stylesheets.end(),
328             theStylesheetRoot);
329 
330     if (i != m_stylesheets.end())
331     {
332         m_stylesheets.erase(i);
333 
334         delete theStylesheetRoot;
335     }
336 
337     if (m_stylesheets.empty() == true)
338     {
339         reset();
340     }
341 }
342 
343 
344 
345 StylesheetConstructionContextDefault::URLAutoPtrType
getURLFromString(const XalanDOMString & urlString)346 StylesheetConstructionContextDefault::getURLFromString(const XalanDOMString&    urlString)
347 {
348     return URISupport::getURLFromString(
349                 urlString,
350                 getMemoryManager());
351 }
352 
353 
354 
355 XalanDOMString&
getURLStringFromString(const XalanDOMString & urlString,XalanDOMString & theResult)356 StylesheetConstructionContextDefault::getURLStringFromString(
357             const XalanDOMString&  urlString,
358             XalanDOMString&        theResult)
359 {
360     URISupport::getURLStringFromString(
361             urlString,
362             theResult);
363 
364     return theResult;
365 }
366 
367 
368 
369 StylesheetConstructionContextDefault::URLAutoPtrType
getURLFromString(const XalanDOMString & urlString,const XalanDOMString & base)370 StylesheetConstructionContextDefault::getURLFromString(
371             const XalanDOMString&   urlString,
372             const XalanDOMString&   base)
373 {
374     return URISupport::getURLFromString(
375                 urlString,
376                 base,
377                 getMemoryManager());
378 }
379 
380 
381 
382 XalanDOMString&
getURLStringFromString(const XalanDOMString & urlString,const XalanDOMString & base,XalanDOMString & theResult)383 StylesheetConstructionContextDefault::getURLStringFromString(
384             const XalanDOMString&   urlString,
385             const XalanDOMString&   base,
386             XalanDOMString&         theResult)
387 {
388     URISupport::getURLStringFromString(
389             urlString,
390             base,
391             theResult);
392 
393     return theResult;
394 }
395 
396 
397 
398 const XalanDOMString&
getXSLTNamespaceURI() const399 StylesheetConstructionContextDefault::getXSLTNamespaceURI() const
400 {
401     return XSLTEngineImpl::getXSLNameSpaceURL();
402 }
403 
404 
405 
406 XPath*
createMatchPattern(const Locator * locator,const XalanDOMString & str,const PrefixResolver & resolver,bool allowVariableReferences,bool allowKeyFunction)407 StylesheetConstructionContextDefault::createMatchPattern(
408             const Locator*          locator,
409             const XalanDOMString&   str,
410             const PrefixResolver&   resolver,
411             bool                    allowVariableReferences,
412             bool                    allowKeyFunction)
413 {
414     XPath* const    xpath = m_xpathFactory.create();
415 
416     // Note that we use the current locator from the
417     // processing stack, and not the locator passed in.
418     // This is because the locator on the stack is active,
419     // during construction, while the locator passed in
420     // will be used at run-time.
421     m_xpathProcessor->initMatchPattern(
422             *xpath,
423             *this,
424             str,
425             resolver,
426             getLocatorFromStack(),
427             allowVariableReferences,
428             allowKeyFunction);
429 
430     xpath->setInStylesheet(true);
431 
432     xpath->setLocator(locator);
433 
434     return xpath;
435 }
436 
437 
438 
439 XPath*
createMatchPattern(const Locator * locator,const XalanDOMChar * str,const PrefixResolver & resolver,bool allowVariableReferences,bool allowKeyFunction)440 StylesheetConstructionContextDefault::createMatchPattern(
441             const Locator*          locator,
442             const XalanDOMChar*     str,
443             const PrefixResolver&   resolver,
444             bool                    allowVariableReferences,
445             bool                    allowKeyFunction)
446 {
447     assert(str != 0);
448 
449     m_tempBuffer.assign(str);
450 
451     return createMatchPattern(
452                 locator,
453                 m_tempBuffer,
454                 resolver,
455                 allowVariableReferences,
456                 allowKeyFunction);
457 }
458 
459 
460 
461 XPath*
createXPath(const Locator * locator,const XalanDOMString & str,const PrefixResolver & resolver,bool allowVariableReferences,bool allowKeyFunction)462 StylesheetConstructionContextDefault::createXPath(
463             const Locator*          locator,
464             const XalanDOMString&   str,
465             const PrefixResolver&   resolver,
466             bool                    allowVariableReferences,
467             bool                    allowKeyFunction)
468 {
469     XPath* const    xpath = m_xpathFactory.create();
470 
471     // Note that we use the current locator from the
472     // processing stack, and not the locator passed in.
473     // This is because the locator on the stack is active,
474     // during construction, while the locator passed in
475     // will be used at run-time.
476     m_xpathProcessor->initXPath(
477             *xpath,
478             *this,
479             str,
480             resolver,
481             getLocatorFromStack(),
482             allowVariableReferences,
483             allowKeyFunction);
484 
485     xpath->setInStylesheet(true);
486 
487     xpath->setLocator(locator);
488 
489     return xpath;
490 }
491 
492 
493 
494 XPath*
createXPath(const Locator * locator,const XalanDOMChar * str,const PrefixResolver & resolver,bool allowVariableReferences,bool allowKeyFunction)495 StylesheetConstructionContextDefault::createXPath(
496             const Locator*          locator,
497             const XalanDOMChar*     str,
498             const PrefixResolver&   resolver,
499             bool                    allowVariableReferences,
500             bool                    allowKeyFunction)
501 {
502     assert(str != 0);
503 
504     m_tempBuffer.assign(str);
505 
506     return createXPath(
507                 locator,
508                 m_tempBuffer,
509                 resolver,
510                 allowVariableReferences,
511                 allowKeyFunction);
512 }
513 
514 
515 
516 XPath*
createXPath(const Locator * locator,const XalanDOMChar * str,XalanDOMString::size_type len,const PrefixResolver & resolver,bool allowVariableReferences,bool allowKeyFunction)517 StylesheetConstructionContextDefault::createXPath(
518             const Locator*              locator,
519             const XalanDOMChar*         str,
520             XalanDOMString::size_type   len,
521             const PrefixResolver&       resolver,
522             bool                        allowVariableReferences,
523             bool                        allowKeyFunction)
524 {
525     assert(str != 0);
526 
527     m_tempBuffer.assign(str, len);
528 
529     return createXPath(
530                 locator,
531                 m_tempBuffer,
532                 resolver,
533                 allowVariableReferences,
534                 allowKeyFunction);
535 }
536 
537 
538 
539 const Locator*
getLocatorFromStack() const540 StylesheetConstructionContextDefault::getLocatorFromStack() const
541 {
542     return m_processor.getLocatorFromStack();
543 }
544 
545 
546 
547 void
pushLocatorOnStack(const Locator * locator)548 StylesheetConstructionContextDefault::pushLocatorOnStack(const Locator*     locator)
549 {
550     m_processor.pushLocatorOnStack(locator);
551 }
552 
553 
554 
555 void
popLocatorStack()556 StylesheetConstructionContextDefault::popLocatorStack()
557 {
558     m_processor.popLocatorStack();
559 }
560 
561 
562 
563 const XalanDOMString&
getXalanXSLNameSpaceURL() const564 StylesheetConstructionContextDefault::getXalanXSLNameSpaceURL() const
565 {
566     return XSLTEngineImpl::getXalanXSLNameSpaceURL();
567 }
568 
569 
570 
571 XalanDocument*
parseXML(const XalanDOMString & urlString,DocumentHandler * docHandler,XalanDocument * docToRegister,ErrorHandler * theErrorHandler)572 StylesheetConstructionContextDefault::parseXML(
573             const XalanDOMString&   urlString,
574             DocumentHandler*        docHandler,
575             XalanDocument*          docToRegister,
576             ErrorHandler*           theErrorHandler)
577 {
578     return m_processor.parseXML(
579                 urlString,
580                 docHandler,
581                 docToRegister,
582                 theErrorHandler);
583 }
584 
585 
586 
587 bool
isXMLSpaceAttribute(const XalanDOMChar * theAttributeName,const Stylesheet & theStylesheet,const Locator * theLocator)588 StylesheetConstructionContextDefault::isXMLSpaceAttribute(
589             const XalanDOMChar*     theAttributeName,
590             const Stylesheet&       theStylesheet,
591             const Locator*          theLocator)
592 {
593     assert(theAttributeName != 0);
594 
595     m_scratchQName.set(
596         theAttributeName,
597         theStylesheet.getNamespaces(),
598         theLocator,
599         true);
600 
601     return m_spaceAttrQName == m_scratchQName;
602 }
603 
604 
605 
606 bool
isXSLUseAttributeSetsAttribute(const XalanDOMChar * theAttributeName,const Stylesheet & theStylesheet,const Locator * theLocator)607 StylesheetConstructionContextDefault::isXSLUseAttributeSetsAttribute(
608             const XalanDOMChar*     theAttributeName,
609             const Stylesheet&       theStylesheet,
610             const Locator*          theLocator)
611 {
612     assert(theAttributeName != 0);
613 
614     m_scratchQName.set(
615         theAttributeName,
616         theStylesheet.getNamespaces(),
617         theLocator,
618         true);
619 
620     return m_useAttributeSetsQName == m_scratchQName;
621 }
622 
623 
624 
625 bool
isValidQName(const XalanDOMChar * theName,const Stylesheet & theStylesheet,const Locator * theLocator)626 StylesheetConstructionContextDefault::isValidQName(
627             const XalanDOMChar*     theName,
628             const Stylesheet&       theStylesheet,
629             const Locator*          theLocator)
630 {
631     assert(theName != 0);
632 
633     m_scratchQName.set(
634         theName,
635         theStylesheet.getNamespaces(),
636         theLocator,
637         false);
638 
639     return m_scratchQName.isValid();
640 }
641 
642 
643 
644 template <class Type>
645 class CreateElementFunctor
646 {
647 public:
648 
649     Type*
operator ()(MemoryManager & theManager,StylesheetConstructionContext & constructionContext,Stylesheet & stylesheetTree,const AttributeListType & atts,XalanFileLoc lineNumber,XalanFileLoc columnNumber)650     operator()(
651         MemoryManager&              theManager,
652         StylesheetConstructionContext&  constructionContext,
653         Stylesheet&                     stylesheetTree,
654         const AttributeListType&        atts,
655         XalanFileLoc                    lineNumber,
656         XalanFileLoc                    columnNumber)
657     {
658         Type*   theResult;
659 
660         return XalanConstruct(
661                     theManager,
662                     theResult,
663                     constructionContext,
664                     stylesheetTree,
665                     atts,
666                     lineNumber,
667                     columnNumber);
668     }
669 };
670 
671 
672 
673 ElemTemplateElement*
createElement(int token,Stylesheet & stylesheetTree,const AttributeListType & atts,const Locator * locator)674 StylesheetConstructionContextDefault::createElement(
675             int                         token,
676             Stylesheet&                 stylesheetTree,
677             const AttributeListType&    atts,
678             const Locator*              locator)
679 {
680     const XalanFileLoc  lineNumber =
681         XalanLocator::getLineNumber(locator);
682 
683     const XalanFileLoc  columnNumber =
684         XalanLocator::getColumnNumber(locator);
685 
686     ElemTemplateElement*    theElement = 0;
687 
688     switch(token)
689     {
690     case ELEMNAME_APPLY_IMPORTS:
691         m_allocatedElements.push_back(0);
692 
693         theElement = CreateElementFunctor<ElemApplyImport>() (
694             getMemoryManager(),
695             *this,
696             stylesheetTree,
697             atts,
698             lineNumber,
699             columnNumber);
700         break;
701 
702     case ELEMNAME_APPLY_TEMPLATES:
703         return m_elemApplyTemplatesAllocator.create(
704             *this,
705             stylesheetTree,
706             atts,
707             lineNumber,
708             columnNumber);
709         break;
710 
711     case ELEMNAME_ATTRIBUTE:
712         return m_elemAttributeAllocator.create(
713             *this,
714             stylesheetTree,
715             atts,
716             lineNumber,
717             columnNumber);
718         break;
719 
720     case ELEMNAME_ATTRIBUTE_SET:
721         return m_elemAttributeSetAllocator.create(
722             *this,
723             stylesheetTree,
724             atts,
725             lineNumber,
726             columnNumber);
727         break;
728 
729     case ELEMNAME_CALL_TEMPLATE:
730         return m_elemCallTemplateAllocator.create(
731             *this,
732             stylesheetTree,
733             atts,
734             lineNumber,
735             columnNumber);
736         break;
737 
738     case ELEMNAME_CHOOSE:
739         m_allocatedElements.push_back(0);
740 
741         theElement = CreateElementFunctor<ElemChoose>()(
742              getMemoryManager(),
743             *this,
744             stylesheetTree,
745             atts,
746             lineNumber,
747             columnNumber);
748         break;
749 
750     case ELEMNAME_COMMENT:
751         m_allocatedElements.push_back(0);
752 
753         theElement = CreateElementFunctor<ElemComment>()(
754              getMemoryManager(),
755             *this,
756             stylesheetTree,
757             atts,
758             lineNumber,
759             columnNumber);
760       break;
761 
762     case ELEMNAME_COPY:
763         m_allocatedElements.push_back(0);
764 
765         theElement = CreateElementFunctor<ElemCopy>()(
766             getMemoryManager(),
767             *this,
768             stylesheetTree,
769             atts,
770             lineNumber,
771             columnNumber);
772         break;
773 
774     case ELEMNAME_COPY_OF:
775         m_allocatedElements.push_back(0);
776 
777         theElement = CreateElementFunctor<ElemCopyOf>()(
778             getMemoryManager(),
779             *this,
780             stylesheetTree,
781             atts,
782             lineNumber,
783             columnNumber);
784         break;
785 
786     case ELEMNAME_DECIMAL_FORMAT:
787         m_allocatedElements.push_back(0);
788 
789         theElement = CreateElementFunctor<ElemDecimalFormat>()(
790             getMemoryManager(),
791             *this,
792             stylesheetTree,
793             atts,
794             lineNumber,
795             columnNumber);
796         break;
797 
798     case ELEMNAME_ELEMENT:
799         return m_elemElementAllocator.create(
800             *this,
801             stylesheetTree,
802             atts,
803             lineNumber,
804             columnNumber);
805       break;
806 
807     case ELEMNAME_FALLBACK:
808         m_allocatedElements.push_back(0);
809 
810         theElement = CreateElementFunctor<ElemFallback>()(
811              getMemoryManager(),
812             *this,
813             stylesheetTree,
814             atts,
815             lineNumber,
816             columnNumber);
817         break;
818 
819     case ELEMNAME_FOR_EACH:
820         m_allocatedElements.push_back(0);
821 
822         theElement = CreateElementFunctor<ElemForEach>()(
823              getMemoryManager(),
824             *this,
825             stylesheetTree,
826             atts,
827             lineNumber,
828             columnNumber);
829         break;
830 
831     case ELEMNAME_IF:
832         m_allocatedElements.push_back(0);
833 
834         theElement = CreateElementFunctor<ElemIf>()(
835              getMemoryManager(),
836             *this,
837             stylesheetTree,
838             atts,
839             lineNumber,
840             columnNumber);
841         break;
842 
843     case ELEMNAME_MESSAGE:
844         m_allocatedElements.push_back(0);
845 
846         theElement = CreateElementFunctor<ElemMessage>()(
847              getMemoryManager(),
848             *this,
849             stylesheetTree,
850             atts,
851             lineNumber,
852             columnNumber);
853         break;
854 
855     case ELEMNAME_NUMBER:
856         m_allocatedElements.push_back(0);
857 
858         theElement = ElemNumber::create(
859              getMemoryManager(),
860             *this,
861             stylesheetTree,
862             atts,
863             lineNumber,
864             columnNumber,
865             stylesheetTree.getStylesheetRoot().getNextElemNumberID());
866         break;
867 
868     case ELEMNAME_OTHERWISE:
869         m_allocatedElements.push_back(0);
870 
871         theElement = CreateElementFunctor<ElemOtherwise>()(
872             getMemoryManager(),
873             *this,
874             stylesheetTree,
875             atts,
876             lineNumber,
877             columnNumber);
878         break;
879 
880     case ELEMNAME_PARAM:
881         m_allocatedElements.push_back(0);
882 
883         theElement = CreateElementFunctor<ElemParam>()(
884             getMemoryManager(),
885             *this,
886             stylesheetTree,
887             atts,
888             lineNumber,
889             columnNumber);
890         break;
891 
892     case ELEMNAME_PI:
893         m_allocatedElements.push_back(0);
894 
895         theElement = CreateElementFunctor<ElemPI>()(
896              getMemoryManager(),
897             *this,
898             stylesheetTree,
899             atts,
900             lineNumber,
901             columnNumber);
902       break;
903 
904     case ELEMNAME_SORT:
905         m_allocatedElements.push_back(0);
906 
907         theElement = CreateElementFunctor<ElemSort>()(
908              getMemoryManager(),
909             *this,
910             stylesheetTree,
911             atts,
912             lineNumber,
913             columnNumber);
914         break;
915 
916     case ELEMNAME_TEMPLATE:
917         return m_elemTemplateAllocator.create(
918             *this,
919             stylesheetTree,
920             atts,
921             lineNumber,
922             columnNumber);
923         break;
924 
925     case ELEMNAME_VALUE_OF:
926         return m_elemValueOfAllocator.create(
927             *this,
928             stylesheetTree,
929             atts,
930             lineNumber,
931             columnNumber);
932         break;
933 
934     case ELEMNAME_VARIABLE:
935         return m_elemVariableAllocator.create(
936             *this,
937             stylesheetTree,
938             atts,
939             lineNumber,
940             columnNumber);
941         break;
942 
943     case ELEMNAME_WITH_PARAM:
944         m_allocatedElements.push_back(0);
945 
946         theElement = CreateElementFunctor<ElemWithParam>()(
947              getMemoryManager(),
948             *this,
949             stylesheetTree,
950             atts,
951             lineNumber,
952             columnNumber);
953         break;
954 
955     case ELEMNAME_WHEN:
956         m_allocatedElements.push_back(0);
957 
958         theElement = CreateElementFunctor<ElemWhen>()(
959             getMemoryManager(),
960             *this,
961             stylesheetTree,
962             atts,
963             lineNumber,
964             columnNumber);
965         break;
966 
967     default:
968         {
969             const GetCachedString   theGuard1(*this);
970             const GetCachedString   theGuard2(*this);
971 
972             problem(
973                 eXSLTProcessor,
974                 eError,
975                 XalanMessageLoader::getMessage(
976                     theGuard1.get(),
977                     XalanMessages::UnknownXSLTToken_1Param,
978                     NumberToDOMString(
979                         token,
980                         theGuard2.get())),
981                 locator,
982                 0);
983         }
984         break;
985     };
986 
987     assert(theElement != 0 && m_allocatedElements.back() == 0);
988 
989     m_allocatedElements.back() = theElement;
990 
991     return theElement;
992 }
993 
994 
995 
996 ElemTemplateElement*
createElement(int token,Stylesheet & stylesheetTree,const XalanDOMChar * name,const AttributeListType & atts,const Locator * locator)997 StylesheetConstructionContextDefault::createElement(
998             int                         token,
999             Stylesheet&                 stylesheetTree,
1000             const XalanDOMChar*         name,
1001             const AttributeListType&    atts,
1002             const Locator*              locator)
1003 {
1004     const XalanFileLoc  lineNumber =
1005         XalanLocator::getLineNumber(locator);
1006 
1007     const XalanFileLoc  columnNumber =
1008         XalanLocator::getColumnNumber(locator);
1009 
1010     ElemTemplateElement*    theElement = 0;
1011 
1012     if (token == ELEMNAME_LITERAL_RESULT)
1013     {
1014         theElement = m_elemLiteralResultAllocator.create(
1015             *this,
1016             stylesheetTree,
1017             name,
1018             atts,
1019             lineNumber,
1020             columnNumber);
1021     }
1022     else if (token == ELEMNAME_FORWARD_COMPATIBLE)
1023     {
1024         m_allocatedElements.push_back(0);
1025 
1026         theElement = ElemForwardCompatible::create(
1027              getMemoryManager(),
1028             *this,
1029             stylesheetTree,
1030             name,
1031             atts,
1032             lineNumber,
1033             columnNumber);
1034 
1035         m_allocatedElements.back() = theElement;
1036     }
1037     else
1038     {
1039         const GetCachedString   theGuard1(*this);
1040         const GetCachedString   theGuard2(*this);
1041 
1042         problem(
1043             eXSLTProcessor,
1044             eError,
1045             XalanMessageLoader::getMessage(
1046                 theGuard1.get(),
1047                 XalanMessages::UnknownXSLTToken_1Param,
1048                 NumberToDOMString(
1049                     token,
1050                     theGuard2.get())),
1051             locator,
1052             0);
1053     }
1054 
1055     return theElement;
1056 }
1057 
1058 
1059 
1060 ElemTemplateElement*
createElement(Stylesheet & stylesheetTree,const XalanDOMChar * name,const AttributeListType & atts,ExtensionNSHandler & handler,const Locator * locator)1061 StylesheetConstructionContextDefault::createElement(
1062             Stylesheet&                 stylesheetTree,
1063             const XalanDOMChar*         name,
1064             const AttributeListType&    atts,
1065             ExtensionNSHandler&         handler,
1066             const Locator*              locator)
1067 {
1068     m_allocatedElements.push_back(0);
1069 
1070     m_allocatedElements.back() = ElemExtensionCall::create(
1071             getMemoryManager(),
1072             *this,
1073             stylesheetTree,
1074             name,
1075             atts,
1076             XalanLocator::getLineNumber(locator),
1077             XalanLocator::getColumnNumber(locator),
1078             handler);
1079 
1080     return m_allocatedElements.back();
1081 }
1082 
1083 
1084 
1085 ElemTemplateElement*
createElement(Stylesheet & stylesheetTree,const XalanDOMChar * chars,XalanDOMString::size_type length,bool preserveSpace,bool disableOutputEscaping,const Locator * locator)1086 StylesheetConstructionContextDefault::createElement(
1087             Stylesheet&                 stylesheetTree,
1088             const XalanDOMChar*         chars,
1089             XalanDOMString::size_type   length,
1090             bool                        preserveSpace,
1091             bool                        disableOutputEscaping,
1092             const Locator*              locator)
1093 {
1094     return m_elemTextLiteralAllocator.create(
1095             *this,
1096             stylesheetTree,
1097             XalanLocator::getLineNumber(locator),
1098             XalanLocator::getColumnNumber(locator),
1099             chars,
1100             0,
1101             length,
1102             preserveSpace,
1103             disableOutputEscaping);
1104 }
1105 
1106 
1107 
1108 const XalanMatchPatternData*
createXalanMatchPatternData(const ElemTemplate & theTemplate,size_type thePosition,const XalanDOMString & theTargetString,const XPath & theMatchPattern,const XalanDOMString & thePatternString,XPath::eMatchScore thePriority)1109 StylesheetConstructionContextDefault::createXalanMatchPatternData(
1110             const ElemTemplate&     theTemplate,
1111             size_type               thePosition,
1112             const XalanDOMString&   theTargetString,
1113             const XPath&            theMatchPattern,
1114             const XalanDOMString&   thePatternString,
1115             XPath::eMatchScore      thePriority)
1116 {
1117     return m_matchPatternDataAllocator.create(
1118             theTemplate,
1119             thePosition,
1120             theTargetString,
1121             theMatchPattern,
1122             thePatternString,
1123             thePriority);
1124 }
1125 
1126 
1127 
1128 StylesheetConstructionContextDefault::eElementToken
getElementToken(const XalanDOMString & name) const1129 StylesheetConstructionContextDefault::getElementToken(const XalanDOMString&     name) const
1130 {
1131     return getElementNameToken(name);
1132 }
1133 
1134 
1135 
1136 StylesheetConstructionContextDefault::eElementToken
getElementNameToken(const XalanDOMString & name)1137 StylesheetConstructionContextDefault::getElementNameToken(const XalanDOMString&     name)
1138 {
1139     // Find the entity, if any...
1140     const ElementTokenTableEntry*   theFirst = s_elementTokenTable;
1141     const ElementTokenTableEntry*   theLast = &s_elementTokenTableLast;
1142 
1143     while(theFirst <= theLast)
1144     {
1145         const ElementTokenTableEntry* const
1146             theCurrent = theFirst + (theLast - theFirst) / 2;
1147 
1148         const int   theResult =
1149             compareIgnoreCaseASCII(name, theCurrent->m_name);
1150 
1151         if (theResult < 0)
1152         {
1153             theLast = theCurrent - 1;
1154         }
1155         else if (theResult > 0)
1156         {
1157             theFirst = theCurrent + 1;
1158         }
1159         else
1160         {
1161             return theCurrent->m_token;
1162         }
1163     }
1164 
1165     return s_elementTokenTableDummy.m_token;
1166 }
1167 
1168 
1169 
1170 double
getXSLTVersionSupported() const1171 StylesheetConstructionContextDefault::getXSLTVersionSupported() const
1172 {
1173     return 1.0L;
1174 }
1175 
1176 
1177 
1178 const XalanDOMString&
getPooledString(const XalanDOMString & theString)1179 StylesheetConstructionContextDefault::getPooledString(const XalanDOMString&     theString)
1180 {
1181     return m_stringPool.get(theString);
1182 }
1183 
1184 
1185 
1186 const XalanDOMString&
getPooledString(const XalanDOMChar * theString,XalanDOMString::size_type theLength)1187 StylesheetConstructionContextDefault::getPooledString(
1188             const XalanDOMChar*         theString,
1189             XalanDOMString::size_type   theLength)
1190 {
1191     return m_stringPool.get(theString, theLength);
1192 }
1193 
1194 
1195 
1196 XalanDOMString&
getCachedString()1197 StylesheetConstructionContextDefault::getCachedString()
1198 {
1199     return m_stringCache.get();
1200 }
1201 
1202 
1203 
1204 bool
releaseCachedString(XalanDOMString & theString)1205 StylesheetConstructionContextDefault::releaseCachedString(XalanDOMString&   theString)
1206 {
1207     return m_stringCache.release(theString);
1208 }
1209 
1210 
1211 
1212 XalanDOMChar*
allocateXalanDOMCharVector(XalanDOMString::size_type theLength)1213 StylesheetConstructionContextDefault::allocateXalanDOMCharVector(XalanDOMString::size_type  theLength)
1214 {
1215     return m_xalanDOMCharVectorAllocator.allocate(theLength);
1216 }
1217 
1218 
1219 
1220 XalanDOMChar*
allocateXalanDOMCharVector(const XalanDOMChar * theString,XalanDOMString::size_type theLength,bool fTerminate)1221 StylesheetConstructionContextDefault::allocateXalanDOMCharVector(
1222             const XalanDOMChar*         theString,
1223             XalanDOMString::size_type   theLength,
1224             bool                        fTerminate)
1225 {
1226     assert(theString != 0);
1227 
1228     const XalanDOMString::size_type     theActualLength =
1229         theLength == XalanDOMString::npos ?
1230             XalanDOMString::length(theString) :
1231             theLength;
1232 
1233     XalanDOMChar*   theVector =
1234         m_xalanDOMCharVectorAllocator.allocate(
1235             fTerminate == true ? theActualLength + 1 : theActualLength);
1236 
1237     XalanDOMChar* const     theEnd =
1238         XalanCopy(
1239             theString,
1240             theString + theActualLength,
1241             theVector);
1242 
1243     if (fTerminate == true)
1244     {
1245         *theEnd = XalanDOMChar(0);
1246     }
1247 
1248     return theVector;
1249 }
1250 
1251 
1252 
1253 const AVT*
createAVT(const Locator * locator,const XalanDOMChar * name,const XalanDOMChar * stringedValue,const PrefixResolver & resolver)1254 StylesheetConstructionContextDefault::createAVT(
1255             const Locator*                  locator,
1256             const XalanDOMChar*             name,
1257             const XalanDOMChar*             stringedValue,
1258             const PrefixResolver&           resolver)
1259 {
1260     return m_avtAllocator.create(
1261                 *this,
1262                 locator,
1263                 name,
1264                 stringedValue,
1265                 resolver);
1266 }
1267 
1268 
1269 
1270 const AVTPart*
createAVTPart(const XalanDOMChar * theString,XalanDOMString::size_type theLength)1271 StylesheetConstructionContextDefault::createAVTPart(
1272             const XalanDOMChar*         theString,
1273             XalanDOMString::size_type   theLength)
1274 {
1275     return m_avtPartSimpleAllocator.create(
1276                 *this,
1277                 theString,
1278                 theLength);
1279 }
1280 
1281 
1282 
1283 const AVTPart*
createAVTPart(const Locator * locator,const XalanDOMChar * str,XalanDOMString::size_type len,const PrefixResolver & resolver)1284 StylesheetConstructionContextDefault::createAVTPart(
1285             const Locator*              locator,
1286             const XalanDOMChar*         str,
1287             XalanDOMString::size_type   len,
1288             const PrefixResolver&       resolver)
1289 {
1290     const XPath* const  xpath =
1291         createXPath(
1292             locator,
1293             str,
1294             len,
1295             resolver);
1296 
1297     assert(xpath != 0);
1298 
1299     return m_avtPartXPathAllocator.create(xpath);
1300 }
1301 
1302 
1303 
1304 const AVT**
allocateAVTPointerVector(size_type theLength)1305 StylesheetConstructionContextDefault::allocateAVTPointerVector(size_type    theLength)
1306 {
1307     return doAllocateAVTPointerVector(theLength);
1308 }
1309 
1310 
1311 
1312 const AVTPart**
allocateAVTPartPointerVector(size_type theLength)1313 StylesheetConstructionContextDefault::allocateAVTPartPointerVector(size_type    theLength)
1314 {
1315     return doAllocateAVTPartPointerVector(theLength);
1316 }
1317 
1318 
1319 
1320 const XalanQName*
createXalanQName(const XalanDOMString & qname,const NamespacesStackType & namespaces,const Locator * locator,bool fUseDefault)1321 StylesheetConstructionContextDefault::createXalanQName(
1322             const XalanDOMString&       qname,
1323             const NamespacesStackType&  namespaces,
1324             const Locator*              locator,
1325             bool                        fUseDefault)
1326 {
1327     return  m_xalanQNameByValueAllocator.create(
1328                 qname,
1329                 namespaces,
1330                 locator,
1331                 fUseDefault);
1332 }
1333 
1334 
1335 
1336 const XalanQName*
createXalanQName(const XalanDOMChar * qname,const NamespacesStackType & namespaces,const Locator * locator,bool fUseDefault)1337 StylesheetConstructionContextDefault::createXalanQName(
1338             const XalanDOMChar*         qname,
1339             const NamespacesStackType&  namespaces,
1340             const Locator*              locator,
1341             bool                        fUseDefault)
1342 {
1343     return  m_xalanQNameByValueAllocator.create(
1344                 qname,
1345                 namespaces,
1346                 locator,
1347                 fUseDefault);
1348 }
1349 
1350 
1351 
1352 const XalanQName**
tokenizeQNames(size_type & count,const XalanDOMChar * qnameTokens,const NamespacesStackType & namespaces,const Locator * locator,bool fUseDefault)1353 StylesheetConstructionContextDefault::tokenizeQNames(
1354             size_type&                  count,
1355             const XalanDOMChar*         qnameTokens,
1356             const NamespacesStackType&  namespaces,
1357             const Locator*              locator,
1358             bool                        fUseDefault)
1359 {
1360     assert(qnameTokens != 0);
1361 
1362     StringTokenizer     tokenizer(qnameTokens);
1363 
1364     count = tokenizer.countTokens();
1365 
1366     if (count == 0)
1367     {
1368         return 0;
1369     }
1370     else
1371     {
1372         const XalanQName**  theResult =
1373             doAllocateXalanQNamePointerVector(count);
1374         assert(theResult != 0);
1375 
1376         const GetCachedString   theGuard(*this);
1377 
1378         XalanDOMString&     qname = theGuard.get();
1379 
1380         size_type   theCurrentIndex = 0;
1381 
1382         while(tokenizer.hasMoreTokens())
1383         {
1384             tokenizer.nextToken(qname);
1385             assert(qname.empty() == false);
1386 
1387             theResult[theCurrentIndex++] =
1388                     m_xalanQNameByValueAllocator.create(
1389                         qname,
1390                         namespaces,
1391                         locator,
1392                         fUseDefault);
1393         }
1394 
1395         assert(theCurrentIndex == count);
1396 
1397         return theResult;
1398     }
1399 }
1400 
1401 
1402 
1403 const XalanDOMChar  StylesheetConstructionContextDefault::s_if[] =
1404 {
1405     XalanUnicode::charLetter_i,
1406     XalanUnicode::charLetter_f,
1407     0
1408 };
1409 
1410 const XalanDOMChar  StylesheetConstructionContextDefault::s_key[] =
1411 {
1412     XalanUnicode::charLetter_k,
1413     XalanUnicode::charLetter_e,
1414     XalanUnicode::charLetter_y,
1415     0
1416 };
1417 
1418 const XalanDOMChar  StylesheetConstructionContextDefault::s_copy[] =
1419 {
1420     XalanUnicode::charLetter_c,
1421     XalanUnicode::charLetter_o,
1422     XalanUnicode::charLetter_p,
1423     XalanUnicode::charLetter_y,
1424     0
1425 };
1426 
1427 const XalanDOMChar  StylesheetConstructionContextDefault::s_sort[] =
1428 {
1429     XalanUnicode::charLetter_s,
1430     XalanUnicode::charLetter_o,
1431     XalanUnicode::charLetter_r,
1432     XalanUnicode::charLetter_t,
1433     0
1434 };
1435 
1436 const XalanDOMChar  StylesheetConstructionContextDefault::s_text[] =
1437 {
1438     XalanUnicode::charLetter_t,
1439     XalanUnicode::charLetter_e,
1440     XalanUnicode::charLetter_x,
1441     XalanUnicode::charLetter_t,
1442     0
1443 };
1444 
1445 const XalanDOMChar  StylesheetConstructionContextDefault::s_when[] =
1446 {
1447     XalanUnicode::charLetter_w,
1448     XalanUnicode::charLetter_h,
1449     XalanUnicode::charLetter_e,
1450     XalanUnicode::charLetter_n,
1451     0
1452 };
1453 
1454 const XalanDOMChar  StylesheetConstructionContextDefault::s_empty[] =
1455 {
1456     XalanUnicode::charLetter_e,
1457     XalanUnicode::charLetter_m,
1458     XalanUnicode::charLetter_p,
1459     XalanUnicode::charLetter_t,
1460     XalanUnicode::charLetter_y,
1461     0
1462 };
1463 
1464 const XalanDOMChar  StylesheetConstructionContextDefault::s_param[] =
1465 {
1466     XalanUnicode::charLetter_p,
1467     XalanUnicode::charLetter_a,
1468     XalanUnicode::charLetter_r,
1469     XalanUnicode::charLetter_a,
1470     XalanUnicode::charLetter_m,
1471     0
1472 };
1473 
1474 const XalanDOMChar  StylesheetConstructionContextDefault::s_choose[] =
1475 {
1476     XalanUnicode::charLetter_c,
1477     XalanUnicode::charLetter_h,
1478     XalanUnicode::charLetter_o,
1479     XalanUnicode::charLetter_o,
1480     XalanUnicode::charLetter_s,
1481     XalanUnicode::charLetter_e,
1482     0
1483 };
1484 
1485 const XalanDOMChar  StylesheetConstructionContextDefault::s_import[] =
1486 {
1487     XalanUnicode::charLetter_i,
1488     XalanUnicode::charLetter_m,
1489     XalanUnicode::charLetter_p,
1490     XalanUnicode::charLetter_o,
1491     XalanUnicode::charLetter_r,
1492     XalanUnicode::charLetter_t,
1493     0
1494 };
1495 
1496 const XalanDOMChar  StylesheetConstructionContextDefault::s_number[] =
1497 {
1498     XalanUnicode::charLetter_n,
1499     XalanUnicode::charLetter_u,
1500     XalanUnicode::charLetter_m,
1501     XalanUnicode::charLetter_b,
1502     XalanUnicode::charLetter_e,
1503     XalanUnicode::charLetter_r,
1504     0
1505 };
1506 
1507 const XalanDOMChar  StylesheetConstructionContextDefault::s_output[] =
1508 {
1509     XalanUnicode::charLetter_o,
1510     XalanUnicode::charLetter_u,
1511     XalanUnicode::charLetter_t,
1512     XalanUnicode::charLetter_p,
1513     XalanUnicode::charLetter_u,
1514     XalanUnicode::charLetter_t,
1515     0
1516 };
1517 
1518 const XalanDOMChar  StylesheetConstructionContextDefault::s_comment[] =
1519 {
1520     XalanUnicode::charLetter_c,
1521     XalanUnicode::charLetter_o,
1522     XalanUnicode::charLetter_m,
1523     XalanUnicode::charLetter_m,
1524     XalanUnicode::charLetter_e,
1525     XalanUnicode::charLetter_n,
1526     XalanUnicode::charLetter_t,
1527     0
1528 };
1529 
1530 const XalanDOMChar  StylesheetConstructionContextDefault::s_copyOf[] =
1531 {
1532     XalanUnicode::charLetter_c,
1533     XalanUnicode::charLetter_o,
1534     XalanUnicode::charLetter_p,
1535     XalanUnicode::charLetter_y,
1536     XalanUnicode::charHyphenMinus,
1537     XalanUnicode::charLetter_o,
1538     XalanUnicode::charLetter_f,
1539     0
1540 };
1541 
1542 const XalanDOMChar  StylesheetConstructionContextDefault::s_element[] =
1543 {
1544     XalanUnicode::charLetter_e,
1545     XalanUnicode::charLetter_l,
1546     XalanUnicode::charLetter_e,
1547     XalanUnicode::charLetter_m,
1548     XalanUnicode::charLetter_e,
1549     XalanUnicode::charLetter_n,
1550     XalanUnicode::charLetter_t,
1551     0
1552 };
1553 
1554 const XalanDOMChar  StylesheetConstructionContextDefault::s_include[] =
1555 {
1556     XalanUnicode::charLetter_i,
1557     XalanUnicode::charLetter_n,
1558     XalanUnicode::charLetter_c,
1559     XalanUnicode::charLetter_l,
1560     XalanUnicode::charLetter_u,
1561     XalanUnicode::charLetter_d,
1562     XalanUnicode::charLetter_e,
1563     0
1564 };
1565 
1566 const XalanDOMChar  StylesheetConstructionContextDefault::s_message[] =
1567 {
1568     XalanUnicode::charLetter_m,
1569     XalanUnicode::charLetter_e,
1570     XalanUnicode::charLetter_s,
1571     XalanUnicode::charLetter_s,
1572     XalanUnicode::charLetter_a,
1573     XalanUnicode::charLetter_g,
1574     XalanUnicode::charLetter_e,
1575     0
1576 };
1577 
1578 const XalanDOMChar  StylesheetConstructionContextDefault::s_fallback[] =
1579 {
1580     XalanUnicode::charLetter_f,
1581     XalanUnicode::charLetter_a,
1582     XalanUnicode::charLetter_l,
1583     XalanUnicode::charLetter_l,
1584     XalanUnicode::charLetter_b,
1585     XalanUnicode::charLetter_a,
1586     XalanUnicode::charLetter_c,
1587     XalanUnicode::charLetter_k,
1588     0
1589 };
1590 
1591 const XalanDOMChar  StylesheetConstructionContextDefault::s_forEach[] =
1592 {
1593     XalanUnicode::charLetter_f,
1594     XalanUnicode::charLetter_o,
1595     XalanUnicode::charLetter_r,
1596     XalanUnicode::charHyphenMinus,
1597     XalanUnicode::charLetter_e,
1598     XalanUnicode::charLetter_a,
1599     XalanUnicode::charLetter_c,
1600     XalanUnicode::charLetter_h,
1601     0
1602 };
1603 
1604 const XalanDOMChar  StylesheetConstructionContextDefault::s_template[] =
1605 {
1606     XalanUnicode::charLetter_t,
1607     XalanUnicode::charLetter_e,
1608     XalanUnicode::charLetter_m,
1609     XalanUnicode::charLetter_p,
1610     XalanUnicode::charLetter_l,
1611     XalanUnicode::charLetter_a,
1612     XalanUnicode::charLetter_t,
1613     XalanUnicode::charLetter_e,
1614     0
1615 };
1616 
1617 const XalanDOMChar  StylesheetConstructionContextDefault::s_valueOf[] =
1618 {
1619     XalanUnicode::charLetter_v,
1620     XalanUnicode::charLetter_a,
1621     XalanUnicode::charLetter_l,
1622     XalanUnicode::charLetter_u,
1623     XalanUnicode::charLetter_e,
1624     XalanUnicode::charHyphenMinus,
1625     XalanUnicode::charLetter_o,
1626     XalanUnicode::charLetter_f,
1627     0
1628 };
1629 
1630 const XalanDOMChar  StylesheetConstructionContextDefault::s_variable[] =
1631 {
1632     XalanUnicode::charLetter_v,
1633     XalanUnicode::charLetter_a,
1634     XalanUnicode::charLetter_r,
1635     XalanUnicode::charLetter_i,
1636     XalanUnicode::charLetter_a,
1637     XalanUnicode::charLetter_b,
1638     XalanUnicode::charLetter_l,
1639     XalanUnicode::charLetter_e,
1640     0
1641 };
1642 
1643 const XalanDOMChar  StylesheetConstructionContextDefault::s_attribute[] =
1644 {
1645     XalanUnicode::charLetter_a,
1646     XalanUnicode::charLetter_t,
1647     XalanUnicode::charLetter_t,
1648     XalanUnicode::charLetter_r,
1649     XalanUnicode::charLetter_i,
1650     XalanUnicode::charLetter_b,
1651     XalanUnicode::charLetter_u,
1652     XalanUnicode::charLetter_t,
1653     XalanUnicode::charLetter_e,
1654     0
1655 };
1656 
1657 const XalanDOMChar  StylesheetConstructionContextDefault::s_otherwise[] =
1658 {
1659     XalanUnicode::charLetter_o,
1660     XalanUnicode::charLetter_t,
1661     XalanUnicode::charLetter_h,
1662     XalanUnicode::charLetter_e,
1663     XalanUnicode::charLetter_r,
1664     XalanUnicode::charLetter_w,
1665     XalanUnicode::charLetter_i,
1666     XalanUnicode::charLetter_s,
1667     XalanUnicode::charLetter_e,
1668     0
1669 };
1670 
1671 const XalanDOMChar  StylesheetConstructionContextDefault::s_transform[] =
1672 {
1673     XalanUnicode::charLetter_t,
1674     XalanUnicode::charLetter_r,
1675     XalanUnicode::charLetter_a,
1676     XalanUnicode::charLetter_n,
1677     XalanUnicode::charLetter_s,
1678     XalanUnicode::charLetter_f,
1679     XalanUnicode::charLetter_o,
1680     XalanUnicode::charLetter_r,
1681     XalanUnicode::charLetter_m,
1682     0
1683 };
1684 
1685 const XalanDOMChar  StylesheetConstructionContextDefault::s_stylesheet[] =
1686 {
1687     XalanUnicode::charLetter_s,
1688     XalanUnicode::charLetter_t,
1689     XalanUnicode::charLetter_y,
1690     XalanUnicode::charLetter_l,
1691     XalanUnicode::charLetter_e,
1692     XalanUnicode::charLetter_s,
1693     XalanUnicode::charLetter_h,
1694     XalanUnicode::charLetter_e,
1695     XalanUnicode::charLetter_e,
1696     XalanUnicode::charLetter_t,
1697     0
1698 };
1699 
1700 const XalanDOMChar  StylesheetConstructionContextDefault::s_withParam[] =
1701 {
1702     XalanUnicode::charLetter_w,
1703     XalanUnicode::charLetter_i,
1704     XalanUnicode::charLetter_t,
1705     XalanUnicode::charLetter_h,
1706     XalanUnicode::charHyphenMinus,
1707     XalanUnicode::charLetter_p,
1708     XalanUnicode::charLetter_a,
1709     XalanUnicode::charLetter_r,
1710     XalanUnicode::charLetter_a,
1711     XalanUnicode::charLetter_m,
1712     0
1713 };
1714 
1715 const XalanDOMChar  StylesheetConstructionContextDefault::s_stripSpace[] =
1716 {
1717     XalanUnicode::charLetter_s,
1718     XalanUnicode::charLetter_t,
1719     XalanUnicode::charLetter_r,
1720     XalanUnicode::charLetter_i,
1721     XalanUnicode::charLetter_p,
1722     XalanUnicode::charHyphenMinus,
1723     XalanUnicode::charLetter_s,
1724     XalanUnicode::charLetter_p,
1725     XalanUnicode::charLetter_a,
1726     XalanUnicode::charLetter_c,
1727     XalanUnicode::charLetter_e,
1728     0
1729 };
1730 
1731 const XalanDOMChar  StylesheetConstructionContextDefault::s_applyImports[] =
1732 {
1733     XalanUnicode::charLetter_a,
1734     XalanUnicode::charLetter_p,
1735     XalanUnicode::charLetter_p,
1736     XalanUnicode::charLetter_l,
1737     XalanUnicode::charLetter_y,
1738     XalanUnicode::charHyphenMinus,
1739     XalanUnicode::charLetter_i,
1740     XalanUnicode::charLetter_m,
1741     XalanUnicode::charLetter_p,
1742     XalanUnicode::charLetter_o,
1743     XalanUnicode::charLetter_r,
1744     XalanUnicode::charLetter_t,
1745     XalanUnicode::charLetter_s,
1746     0
1747 };
1748 
1749 const XalanDOMChar  StylesheetConstructionContextDefault::s_attributeSet[] =
1750 {
1751     XalanUnicode::charLetter_a,
1752     XalanUnicode::charLetter_t,
1753     XalanUnicode::charLetter_t,
1754     XalanUnicode::charLetter_r,
1755     XalanUnicode::charLetter_i,
1756     XalanUnicode::charLetter_b,
1757     XalanUnicode::charLetter_u,
1758     XalanUnicode::charLetter_t,
1759     XalanUnicode::charLetter_e,
1760     XalanUnicode::charHyphenMinus,
1761     XalanUnicode::charLetter_s,
1762     XalanUnicode::charLetter_e,
1763     XalanUnicode::charLetter_t,
1764     0
1765 };
1766 
1767 const XalanDOMChar  StylesheetConstructionContextDefault::s_callTemplate[] =
1768 {
1769     XalanUnicode::charLetter_c,
1770     XalanUnicode::charLetter_a,
1771     XalanUnicode::charLetter_l,
1772     XalanUnicode::charLetter_l,
1773     XalanUnicode::charHyphenMinus,
1774     XalanUnicode::charLetter_t,
1775     XalanUnicode::charLetter_e,
1776     XalanUnicode::charLetter_m,
1777     XalanUnicode::charLetter_p,
1778     XalanUnicode::charLetter_l,
1779     XalanUnicode::charLetter_a,
1780     XalanUnicode::charLetter_t,
1781     XalanUnicode::charLetter_e,
1782     0
1783 };
1784 
1785 const XalanDOMChar  StylesheetConstructionContextDefault::s_decimalFormat[] =
1786 {
1787     XalanUnicode::charLetter_d,
1788     XalanUnicode::charLetter_e,
1789     XalanUnicode::charLetter_c,
1790     XalanUnicode::charLetter_i,
1791     XalanUnicode::charLetter_m,
1792     XalanUnicode::charLetter_a,
1793     XalanUnicode::charLetter_l,
1794     XalanUnicode::charHyphenMinus,
1795     XalanUnicode::charLetter_f,
1796     XalanUnicode::charLetter_o,
1797     XalanUnicode::charLetter_r,
1798     XalanUnicode::charLetter_m,
1799     XalanUnicode::charLetter_a,
1800     XalanUnicode::charLetter_t,
1801     0
1802 };
1803 
1804 const XalanDOMChar  StylesheetConstructionContextDefault::s_preserveSpace[] =
1805 {
1806     XalanUnicode::charLetter_p,
1807     XalanUnicode::charLetter_r,
1808     XalanUnicode::charLetter_e,
1809     XalanUnicode::charLetter_s,
1810     XalanUnicode::charLetter_e,
1811     XalanUnicode::charLetter_r,
1812     XalanUnicode::charLetter_v,
1813     XalanUnicode::charLetter_e,
1814     XalanUnicode::charHyphenMinus,
1815     XalanUnicode::charLetter_s,
1816     XalanUnicode::charLetter_p,
1817     XalanUnicode::charLetter_a,
1818     XalanUnicode::charLetter_c,
1819     XalanUnicode::charLetter_e,
1820     0
1821 };
1822 
1823 const XalanDOMChar  StylesheetConstructionContextDefault::s_applyTemplates[] =
1824 {
1825     XalanUnicode::charLetter_a,
1826     XalanUnicode::charLetter_p,
1827     XalanUnicode::charLetter_p,
1828     XalanUnicode::charLetter_l,
1829     XalanUnicode::charLetter_y,
1830     XalanUnicode::charHyphenMinus,
1831     XalanUnicode::charLetter_t,
1832     XalanUnicode::charLetter_e,
1833     XalanUnicode::charLetter_m,
1834     XalanUnicode::charLetter_p,
1835     XalanUnicode::charLetter_l,
1836     XalanUnicode::charLetter_a,
1837     XalanUnicode::charLetter_t,
1838     XalanUnicode::charLetter_e,
1839     XalanUnicode::charLetter_s,
1840     0
1841 };
1842 
1843 const XalanDOMChar  StylesheetConstructionContextDefault::s_namespaceAlias[] =
1844 {
1845     XalanUnicode::charLetter_n,
1846     XalanUnicode::charLetter_a,
1847     XalanUnicode::charLetter_m,
1848     XalanUnicode::charLetter_e,
1849     XalanUnicode::charLetter_s,
1850     XalanUnicode::charLetter_p,
1851     XalanUnicode::charLetter_a,
1852     XalanUnicode::charLetter_c,
1853     XalanUnicode::charLetter_e,
1854     XalanUnicode::charHyphenMinus,
1855     XalanUnicode::charLetter_a,
1856     XalanUnicode::charLetter_l,
1857     XalanUnicode::charLetter_i,
1858     XalanUnicode::charLetter_a,
1859     XalanUnicode::charLetter_s,
1860     0
1861 };
1862 
1863 const XalanDOMChar  StylesheetConstructionContextDefault::s_processingInstruction[] =
1864 {
1865     XalanUnicode::charLetter_p,
1866     XalanUnicode::charLetter_r,
1867     XalanUnicode::charLetter_o,
1868     XalanUnicode::charLetter_c,
1869     XalanUnicode::charLetter_e,
1870     XalanUnicode::charLetter_s,
1871     XalanUnicode::charLetter_s,
1872     XalanUnicode::charLetter_i,
1873     XalanUnicode::charLetter_n,
1874     XalanUnicode::charLetter_g,
1875     XalanUnicode::charHyphenMinus,
1876     XalanUnicode::charLetter_i,
1877     XalanUnicode::charLetter_n,
1878     XalanUnicode::charLetter_s,
1879     XalanUnicode::charLetter_t,
1880     XalanUnicode::charLetter_r,
1881     XalanUnicode::charLetter_u,
1882     XalanUnicode::charLetter_c,
1883     XalanUnicode::charLetter_t,
1884     XalanUnicode::charLetter_i,
1885     XalanUnicode::charLetter_o,
1886     XalanUnicode::charLetter_n,
1887     0
1888 };
1889 
1890 
1891 const StylesheetConstructionContextDefault::ElementTokenTableEntry  StylesheetConstructionContextDefault::s_elementTokenTable[] =
1892 {
1893     {
1894         s_if,
1895         ELEMNAME_IF
1896     },
1897     {
1898         s_key,
1899         ELEMNAME_KEY
1900     },
1901     {
1902         s_copy,
1903         ELEMNAME_COPY
1904     },
1905     {
1906         s_sort,
1907         ELEMNAME_SORT
1908     },
1909     {
1910         s_text,
1911         ELEMNAME_TEXT
1912     },
1913     {
1914         s_when,
1915         ELEMNAME_WHEN
1916     },
1917     {
1918         s_empty,
1919         ELEMNAME_EMPTY
1920     },
1921     {
1922         s_param,
1923         ELEMNAME_PARAM
1924     },
1925     {
1926         s_choose,
1927         ELEMNAME_CHOOSE
1928     },
1929     {
1930         s_import,
1931         ELEMNAME_IMPORT
1932     },
1933     {
1934         s_number,
1935         ELEMNAME_NUMBER
1936     },
1937     {
1938         s_output,
1939         ELEMNAME_OUTPUT
1940     },
1941     {
1942         s_comment,
1943         ELEMNAME_COMMENT
1944     },
1945     {
1946         s_copyOf,
1947         ELEMNAME_COPY_OF
1948     },
1949     {
1950         s_element,
1951         ELEMNAME_ELEMENT
1952     },
1953     {
1954         s_include,
1955         ELEMNAME_INCLUDE
1956     },
1957     {
1958         s_message,
1959         ELEMNAME_MESSAGE
1960     },
1961     {
1962         s_fallback,
1963         ELEMNAME_FALLBACK
1964     },
1965     {
1966         s_forEach,
1967         ELEMNAME_FOR_EACH
1968     },
1969     {
1970         s_template,
1971         ELEMNAME_TEMPLATE
1972     },
1973     {
1974         s_valueOf,
1975         ELEMNAME_VALUE_OF
1976     },
1977     {
1978         s_variable,
1979         ELEMNAME_VARIABLE
1980     },
1981     {
1982         s_attribute,
1983         ELEMNAME_ATTRIBUTE
1984     },
1985     {
1986         s_otherwise,
1987         ELEMNAME_OTHERWISE
1988     },
1989     {
1990         s_transform,
1991         ELEMNAME_STYLESHEET
1992     },
1993     {
1994         s_stylesheet,
1995         ELEMNAME_STYLESHEET
1996     },
1997     {
1998         s_withParam,
1999         ELEMNAME_WITH_PARAM
2000     },
2001     {
2002         s_stripSpace,
2003         ELEMNAME_STRIP_SPACE
2004     },
2005     {
2006         s_applyImports,
2007         ELEMNAME_APPLY_IMPORTS
2008     },
2009     {
2010         s_attributeSet,
2011         ELEMNAME_ATTRIBUTE_SET
2012     },
2013     {
2014         s_callTemplate,
2015         ELEMNAME_CALL_TEMPLATE
2016     },
2017     {
2018         s_decimalFormat,
2019         ELEMNAME_DECIMAL_FORMAT
2020     },
2021     {
2022         s_preserveSpace,
2023         ELEMNAME_PRESERVE_SPACE
2024     },
2025     {
2026         s_applyTemplates,
2027         ELEMNAME_APPLY_TEMPLATES
2028     },
2029     {
2030         s_namespaceAlias,
2031         ELEMNAME_NAMESPACE_ALIAS
2032     },
2033     {
2034         s_processingInstruction,
2035         ELEMNAME_PI
2036     },
2037     // This must be the last one...
2038     {
2039         0,
2040         ELEMNAME_UNDEFINED
2041     }
2042 };
2043 
2044 const XalanSize_t  StylesheetConstructionContextDefault::s_elementTokenTableSize =
2045         sizeof(s_elementTokenTable) / sizeof(s_elementTokenTable[0]);
2046 
2047 const StylesheetConstructionContextDefault::ElementTokenTableEntry&     StylesheetConstructionContextDefault::s_elementTokenTableLast =
2048     StylesheetConstructionContextDefault::s_elementTokenTable[s_elementTokenTableSize - 2];
2049 
2050 const StylesheetConstructionContextDefault::ElementTokenTableEntry&     StylesheetConstructionContextDefault::s_elementTokenTableDummy =
2051     StylesheetConstructionContextDefault::s_elementTokenTable[s_elementTokenTableSize - 1];
2052 
2053 
2054 
2055 }
2056