Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

StylesheetHandler.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #if !defined(XALAN_STYLESHEETHANDLER_HEADER_GUARD)
18 #define XALAN_STYLESHEETHANDLER_HEADER_GUARD
19 
20 // Base include file. Must be first.
21 #include "XSLTDefinitions.hpp"
22 
23 
24 
27 
28 
29 
31 
32 
33 
35 
36 
37 
39 
40 
41 
46 
47 
48 
49 XALAN_CPP_NAMESPACE_BEGIN
50 
51 
52 
53 class ElemTemplate;
55 class ElemTextLiteral;
56 class ExtensionNSHandler;
58 
59 
60 
68 {
69 
70 public:
71 
74 
79 
83  static void
84  initialize(MemoryManagerType& theManager);
85 
89  static void
90  terminate();
91 
97  Stylesheet& stylesheetTree,
98  StylesheetConstructionContext& constructionContext);
99 
101  getMemoryManager()
102  {
103  return m_constructionContext.getMemoryManager();
104  }
105 
106  virtual
108 
132  virtual void characters (const XMLCh* const chars, const unsigned int length);
133 
144  virtual void charactersRaw(const XMLCh* const chars, const unsigned int length);
145 
169  virtual void cdata(const XMLCh* const ch, const unsigned int length);
170 
194  virtual void ignorableWhitespace (const XMLCh* const chars, const unsigned int length);
195 
212  virtual void processingInstruction (const XMLCh* const target, const XMLCh* const data);
213 
220  virtual void comment(const XMLCh* const data);
221 
228  virtual void entityReference(const XMLCh* const data);
229 
230  // These methods are inherited DocumentHandler ...
231 
232  // $$$ Theoretically, shouldn't need javadoc for these, since they are
233  // inherited from DocumentHandler, but let's leave them in for now -- JMD
234 
260  virtual void setDocumentLocator(const LocatorType* const locator);
261 
271  virtual void startDocument();
272 
284  virtual void endDocument();
285 
307  virtual void startElement(const XMLCh* const name, AttributeListType& attrs);
308 
323  virtual void endElement(const XMLCh* const name);
324 
330  virtual void resetDocument();
331 
332 protected:
333 
343  bool
344  isAttrOK(
345  const XalanDOMChar* attrName,
346  const AttributeListType& atts,
347  int which);
348 
360  bool
361  processSpaceAttr(
362  const XalanDOMChar* elementName,
363  const XalanDOMChar* aname,
364  const AttributeListType& atts,
365  int which,
366  const LocatorType* locator,
367  bool& fPreserve);
368 
378  bool
379  processSpaceAttr(
380  const XalanDOMChar* elementName,
381  const AttributeListType& atts,
382  const LocatorType* locator,
383  bool& fPreserve);
384 
388  void
389  processImport(
390  const XalanDOMChar* name,
391  const AttributeListType& atts,
392  const LocatorType* locator);
393 
397  void
398  processInclude(
399  const XalanDOMChar* name,
400  const AttributeListType& atts,
401  const LocatorType* locator);
402 
403  void
404  doCleanup();
405 
406 private:
407 
408  enum { eElemEmptyAllocatorBlockSize = 10, eElemTextBlockSize = 10 };
409 
410  // not implemented
412 
414  operator=(const StylesheetHandler&);
415 
416  // Utility functions...
417  void
418  illegalAttributeError(
419  const XalanDOMChar* theElementName,
420  const XalanDOMChar* theAttributeName,
421  const LocatorType* theLocator) const;
422 
423  void
424  error(
425  const XalanDOMChar* theMessage1,
426  const XalanDOMChar* theMessage2,
427  const LocatorType* theLocator) const;
428 
429  void
430  error(
431  const XalanDOMChar* theMessage1,
432  const XalanDOMString& theMessage2,
433  const LocatorType* theLocator) const;
434 
435  void
436  error(
437  const XalanDOMString& theMessage1,
438  const XalanDOMChar* theMessage2,
439  const LocatorType* theLocator) const;
440 
441  void
442  error(
443  const XalanDOMString& theMessage1,
444  const XalanDOMString& theMessage2,
445  const LocatorType* theLocator) const;
446 
447  void
448  warn(
449  const XalanDOMChar* theMessage1,
450  const XalanDOMChar* theMessage2,
451  const LocatorType* theLocator) const;
452 
453  void
454  warn(
455  const XalanDOMChar* theMessage1,
456  const XalanDOMString& theMessage2,
457  const LocatorType* theLocator) const;
458  void
459  warn(
460  const XalanDOMString& theMessage,
461  const LocatorType* theLocator) const;
462 
463  void
464  error(
465  const XalanDOMString& theMessage,
466  const LocatorType* theLocator) const;
467 
468  void
469  processText(
470  const XMLCh* chars,
472 
473  void
474  accumulateText(
475  const XMLCh* chars,
477 
478  void
479  processAccumulatedText();
480 
481  void
482  processTopLevelElement(
483  const XalanDOMChar* name,
484  const AttributeListType& atts,
485  int xslToken,
486  const LocatorType* locator,
487  bool& fPreserveSpace,
488  bool& fSpaceAttrProcessed);
489 
490  void
491  processStylesheet(
492  const XalanDOMChar* name,
493  const AttributeListType& atts,
494  const LocatorType* locator,
495  bool& fPreserveSpace,
496  bool& fSpaceAttrProcessed);
497 
498  void
499  processPreserveStripSpace(
500  const XalanDOMChar* name,
501  const AttributeListType& atts,
502  const LocatorType* locator,
503  int xslToken);
504 
505  void
506  appendChildElementToParent(
507  ElemTemplateElement* elem,
508  const LocatorType* locator);
509 
510  void
511  appendChildElementToParent(
512  ElemTemplateElement* parent,
513  ElemTemplateElement* elem);
514 
515  void
516  appendChildElementToParent(
517  ElemTemplateElement* parent,
518  ElemTemplateElement* elem,
519  const LocatorType* locator);
520 
521  bool
522  inExtensionElement() const;
523 
524  void
525  processExtensionElement(
526  const XalanDOMChar* name,
527  const XalanDOMString& localName,
528  const AttributeListType& atts,
529  const LocatorType* locator);
530 
531  void
532  checkForOrAddVariableName(
533  const XalanQName& theVariableName,
534  const LocatorType* theLocator);
535 
536  // Data members...
537 
541  Stylesheet& m_stylesheet;
542 
546  StylesheetConstructionContext& m_constructionContext;
547 
551  XalanElemEmptyAllocator m_elemEmptyAllocator;
552 
556  XalanElemTextAllocator m_elemTextAllocator;
557 
561  ElemTemplateStackType m_elemStack;
562 
568  ElemTextLiteralStackType m_whiteSpaceElems;
569 
573  ElemTemplateElement* m_pTemplate;
574 
575  class LastPoppedHolder
576  {
577  public:
578 
579  LastPoppedHolder(StylesheetHandler& theStylesheetHandler) :
580  m_stylesheetHandler(theStylesheetHandler),
581  m_lastPopped(0)
582  {
583  }
584 
585  ~LastPoppedHolder()
586  {
587  cleanup();
588  }
589 
591  operator->() const
592  {
593  return m_lastPopped;
594  }
595 
596  bool
598  {
599  return m_lastPopped == theRHS;
600  }
601 
602  bool
604  {
605  return m_lastPopped != theRHS;
606  }
607 
608  void
609  operator=(ElemTemplateElement* theRHS)
610  {
611  if (theRHS != m_lastPopped)
612  {
613  cleanup();
614 
615  m_lastPopped = theRHS;
616  }
617  }
618 
619  void
620  swap(LastPoppedHolder& theOther)
621  {
622  ElemTemplateElement* const theTemp = m_lastPopped;
623 
624  m_lastPopped = theOther.m_lastPopped;
625 
626  theOther.m_lastPopped = theTemp;
627  }
628 
630  get() const
631  {
632  return m_lastPopped;
633  }
634 
635  private:
636 
637  void
638  set(ElemTemplateElement* theNewElement)
639  {
640  if (theNewElement != m_lastPopped)
641  {
642  cleanup();
643 
644  m_lastPopped = theNewElement;
645  }
646  }
647 
648  // Not implemented...
649  LastPoppedHolder&
650  operator=(const LastPoppedHolder&);
651 
652  LastPoppedHolder(const LastPoppedHolder&);
653 
654  // Helper functions...
655  void
656  cleanup();
657 
658  // Data members...
659  StylesheetHandler& m_stylesheetHandler;
660 
661  ElemTemplateElement* m_lastPopped;
662  };
663 
664  friend class LastPoppedHolder;
665 
669  LastPoppedHolder m_lastPopped;
670 
674  bool m_inTemplate;
675 
680  bool m_foundStylesheet;
681 
687  bool m_foundNotImport;
688 
689  XalanDOMString m_elementLocalName;
690 
695  XalanDOMString m_accumulateText;
696 
697  XalanDOMString m_includeBase;
698 
699  BoolStackType m_inExtensionElementStack;
700 
701  BoolStackType m_preserveSpaceStack;
702 
703  // Note that these variables must not be saved by
704  // PushPopIncludeState...
705  unsigned long m_locatorsPushed;
706 
707  QNameSetType m_globalVariableNames;
708 
709  enum { eVariablesStackDefault = 20 };
710 
711  QNameSetVectorType m_inScopeVariableNamesStack;
712 
717  initWrapperless(
718  const XalanDOMChar* name,
719  const AttributeListType& atts,
720  const LocatorType* locator);
721 
722  const XalanDOMString*
723  getNamespaceFromStack(const XalanDOMChar* theName,
724  XalanDOMString& theBuffer) const;
725 
726  const XalanDOMString*
727  getNamespaceForPrefixFromStack(const XalanDOMString& thePrefix) const;
728 
729  class PushPopIncludeState;
730 
731  friend class StylesheetHandler::PushPopIncludeState;
732 
733  class PushPopIncludeState
734  {
735  public:
736 
737  PushPopIncludeState(StylesheetHandler& theHandler);
738 
739  ~PushPopIncludeState();
740 
741  private:
742 
743  StylesheetHandler& m_handler;
744 
745  ElemTemplateStackType m_elemStack;
746 
747  ElemTemplateElement* const m_pTemplate;
748 
749  LastPoppedHolder m_lastPopped;
750 
751  const bool m_inTemplate;
752 
753  const bool m_foundStylesheet;
754 
755  const XalanDOMString m_XSLNameSpaceURL;
756 
757  const bool m_foundNotImport;
758 
759  Stylesheet::NamespaceVectorType m_namespaceDecls;
760 
761  Stylesheet::NamespacesStackType m_namespaces;
762 
763  NamespacesHandler m_namespacesHandler;
764 
765  BoolStackType m_inExtensionElementStack;
766 
767  BoolStackType m_preserveSpaceStack;
768  };
769 
770  static const XalanDOMString s_emptyString;
771 };
772 
773 
774 
775 XALAN_CPP_NAMESPACE_END
776 
777 
778 
779 #endif // XALAN_STYLESHEETHANDLER_HEADER_GUARD

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

dot

Xalan-C++ XSLT Processor Version 1.10
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.

Apache Logo