## Xalan-C++ API Documentation

### The Xalan C++ XSLT Processor Version 1.10

Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members

# StylesheetHandler.hpp

Go to the documentation of this file.

    00001 /*
    00002  * Copyright 1999-2004 The Apache Software Foundation.
    00003  *
    00004  * Licensed under the Apache License, Version 2.0 (the "License");
    00005  * you may not use this file except in compliance with the License.
    00006  * You may obtain a copy of the License at
    00007  *
    00008  *     http://www.apache.org/licenses/LICENSE-2.0
    00009  *
    00010  * Unless required by applicable law or agreed to in writing, software
    00011  * distributed under the License is distributed on an "AS IS" BASIS,
    00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    00013  * See the License for the specific language governing permissions and
    00014  * limitations under the License.
    00015  */
    00016
    00017 #if !defined(XALAN_STYLESHEETHANDLER_HEADER_GUARD)
    00018 #define XALAN_STYLESHEETHANDLER_HEADER_GUARD
    00019
    00020 // Base include file.   Must be first.
    00021 #include "XSLTDefinitions.hpp"
    00022
    00023
    00024
    00025 #include <xalanc/Include/XalanVector.hpp>
    00026 #include <xalanc/Include/XalanSet.hpp>
    00027
    00028
    00029
    00030 #include <xalanc/XalanDOM/XalanDOMString.hpp>
    00031
    00032
    00033
    00034 #include <xalanc/PlatformSupport/FormatterListener.hpp>
    00035
    00036
    00037
    00038 #include <xalanc/XPath/XalanQNameByValue.hpp>
    00039
    00040
    00041
    00042 #include <xalanc/XSLT/NamespacesHandler.hpp>
    00043 #include <xalanc/XSLT/Stylesheet.hpp>
    00044 #include <xalanc/XSLT/XalanElemEmptyAllocator.hpp>
    00045 #include <xalanc/XSLT/XalanElemTextAllocator.hpp>
    00046
    00047
    00048
    00049 XALAN_CPP_NAMESPACE_BEGIN
    00050
    00051
    00052
    00053 class ElemTemplate;
    00054 class ElemTemplateElement;
    00055 class ElemTextLiteral;
    00056 class ExtensionNSHandler;
    00057 class StylesheetConstructionContext;
    00058
    00059
    00060
    00067 class XALAN_XSLT_EXPORT StylesheetHandler : public FormatterListener
    00068 {
    00069
    00070 public:
    00071
    00072     typedef XalanVector<ElemTemplateElement*>       ElemTemplateStackType;
    00073     typedef XalanVector<ElemTemplateElement*>       ElemTextLiteralStackType;
    00074
    00075     typedef XalanVector<bool>                       BoolStackType;
    00076     typedef XalanSet<XalanQNameByReference>         QNameSetType;
    00077     typedef XalanVector<QNameSetType, ConstructWithMemoryManagerTraits<QNameSetType> >
    00078                                                     QNameSetVectorType;
    00079
    00083     static void
    00084     initialize(MemoryManagerType&  theManager);
    00085
    00089     static void
    00090     terminate();
    00091
    00096     StylesheetHandler(
    00097             Stylesheet&                     stylesheetTree,
    00098             StylesheetConstructionContext&  constructionContext);
    00099
    00100     MemoryManagerType&
    00101     getMemoryManager()
    00102     {
    00103         return m_constructionContext.getMemoryManager();
    00104     }
    00105
    00106     virtual
    00107     ~StylesheetHandler();
    00108
    00132     virtual void characters (const XMLCh* const chars, const unsigned int length);
    00133
    00144     virtual void charactersRaw(const XMLCh* const chars, const unsigned int length);
    00145
    00169     virtual void cdata(const XMLCh* const ch, const unsigned int length);
    00170
    00194     virtual void ignorableWhitespace (const XMLCh* const chars, const unsigned int length);
    00195
    00212     virtual void processingInstruction (const XMLCh* const target, const XMLCh* const data);
    00213
    00220     virtual void comment(const XMLCh* const data);
    00221
    00228     virtual void entityReference(const XMLCh* const data);
    00229
    00230     // These methods are inherited DocumentHandler ...
    00231
    00232     // $$$ Theoretically, shouldn't need javadoc for these, since they are
    00233     // inherited from DocumentHandler, but let's leave them in for now -- JMD
    00234
    00260     virtual void setDocumentLocator(const LocatorType* const    locator);
    00261
    00271     virtual void startDocument();
    00272
    00284     virtual void endDocument();
    00285
    00307     virtual void startElement(const XMLCh* const name, AttributeListType& attrs);
    00308
    00323     virtual void endElement(const XMLCh* const name);
    00324
    00330     virtual void resetDocument();
    00331
    00332 protected:
    00333
    00343     bool
    00344     isAttrOK(
    00345             const XalanDOMChar*         attrName,
    00346             const AttributeListType&    atts,
    00347             int                         which);
    00348
    00360     bool
    00361     processSpaceAttr(
    00362             const XalanDOMChar*         elementName,
    00363             const XalanDOMChar*         aname,
    00364             const AttributeListType&    atts,
    00365             int                         which,
    00366             const LocatorType*          locator,
    00367             bool&                       fPreserve);
    00368
    00378     bool
    00379     processSpaceAttr(
    00380             const XalanDOMChar*         elementName,
    00381             const AttributeListType&    atts,
    00382             const LocatorType*          locator,
    00383             bool&                       fPreserve);
    00384
    00388     void
    00389     processImport(
    00390             const XalanDOMChar*         name,
    00391             const AttributeListType&    atts,
    00392             const LocatorType*          locator);
    00393
    00397     void
    00398     processInclude(
    00399             const XalanDOMChar*         name,
    00400             const AttributeListType&    atts,
    00401             const LocatorType*          locator);
    00402
    00403     void
    00404     doCleanup();
    00405
    00406 private:
    00407
    00408     enum { eElemEmptyAllocatorBlockSize = 10, eElemTextBlockSize = 10 };
    00409
    00410     // not implemented
    00411     StylesheetHandler(const StylesheetHandler&);
    00412
    00413     StylesheetHandler&
    00414     operator=(const StylesheetHandler&);
    00415
    00416     // Utility functions...
    00417     void
    00418     illegalAttributeError(
    00419             const XalanDOMChar*     theElementName,
    00420             const XalanDOMChar*     theAttributeName,
    00421             const LocatorType*      theLocator) const;
    00422
    00423     void
    00424     error(
    00425             const XalanDOMChar*     theMessage1,
    00426             const XalanDOMChar*     theMessage2,
    00427             const LocatorType*      theLocator) const;
    00428
    00429     void
    00430     error(
    00431             const XalanDOMChar*     theMessage1,
    00432             const XalanDOMString&   theMessage2,
    00433             const LocatorType*      theLocator) const;
    00434
    00435     void
    00436     error(
    00437             const XalanDOMString&   theMessage1,
    00438             const XalanDOMChar*     theMessage2,
    00439             const LocatorType*      theLocator) const;
    00440
    00441     void
    00442     error(
    00443             const XalanDOMString&   theMessage1,
    00444             const XalanDOMString&   theMessage2,
    00445             const LocatorType*      theLocator) const;
    00446
    00447     void
    00448     warn(
    00449             const XalanDOMChar*     theMessage1,
    00450             const XalanDOMChar*     theMessage2,
    00451             const LocatorType*      theLocator) const;
    00452
    00453     void
    00454     warn(
    00455             const XalanDOMChar*     theMessage1,
    00456             const XalanDOMString&   theMessage2,
    00457             const LocatorType*      theLocator) const;
    00458     void
    00459     warn(
    00460             const XalanDOMString&   theMessage,
    00461             const LocatorType*      theLocator) const;
    00462
    00463     void
    00464     error(
    00465             const XalanDOMString&   theMessage,
    00466             const LocatorType*      theLocator) const;
    00467
    00468     void
    00469     processText(
    00470             const XMLCh*                chars,
    00471             XalanDOMString::size_type   length);
    00472
    00473     void
    00474     accumulateText(
    00475             const XMLCh*                chars,
    00476             XalanDOMString::size_type   length);
    00477
    00478     void
    00479     processAccumulatedText();
    00480
    00481     void
    00482     processTopLevelElement(
    00483             const XalanDOMChar*         name,
    00484             const AttributeListType&    atts,
    00485             int                         xslToken,
    00486             const LocatorType*          locator,
    00487             bool&                       fPreserveSpace,
    00488             bool&                       fSpaceAttrProcessed);
    00489
    00490     void
    00491     processStylesheet(
    00492             const XalanDOMChar*         name,
    00493             const AttributeListType&    atts,
    00494             const LocatorType*          locator,
    00495             bool&                       fPreserveSpace,
    00496             bool&                       fSpaceAttrProcessed);
    00497
    00498     void
    00499     processPreserveStripSpace(
    00500             const XalanDOMChar*         name,
    00501             const AttributeListType&    atts,
    00502             const LocatorType*          locator,
    00503             int                         xslToken);
    00504
    00505     void
    00506     appendChildElementToParent(
    00507             ElemTemplateElement*    elem,
    00508             const LocatorType*      locator);
    00509
    00510     void
    00511     appendChildElementToParent(
    00512             ElemTemplateElement*    parent,
    00513             ElemTemplateElement*    elem);
    00514
    00515     void
    00516     appendChildElementToParent(
    00517             ElemTemplateElement*    parent,
    00518             ElemTemplateElement*    elem,
    00519             const LocatorType*      locator);
    00520
    00521     bool
    00522     inExtensionElement() const;
    00523
    00524     void
    00525     processExtensionElement(
    00526             const XalanDOMChar*         name,
    00527             const XalanDOMString&       localName,
    00528             const AttributeListType&    atts,
    00529             const LocatorType*          locator);
    00530
    00531     void
    00532     checkForOrAddVariableName(
    00533             const XalanQName&   theVariableName,
    00534             const LocatorType*  theLocator);
    00535
    00536     // Data members...
    00537
    00541     Stylesheet&     m_stylesheet;
    00542
    00546     StylesheetConstructionContext&  m_constructionContext;
    00547
    00551     XalanElemEmptyAllocator     m_elemEmptyAllocator;
    00552
    00556     XalanElemTextAllocator      m_elemTextAllocator;
    00557
    00561     ElemTemplateStackType   m_elemStack;
    00562
    00568     ElemTextLiteralStackType    m_whiteSpaceElems;
    00569
    00573     ElemTemplateElement*    m_pTemplate;
    00574
    00575     class LastPoppedHolder
    00576     {
    00577     public:
    00578
    00579         LastPoppedHolder(StylesheetHandler&     theStylesheetHandler) :
    00580             m_stylesheetHandler(theStylesheetHandler),
    00581             m_lastPopped(0)
    00582         {
    00583         }
    00584
    00585         ~LastPoppedHolder()
    00586         {
    00587             cleanup();
    00588         }
    00589
    00590         ElemTemplateElement*
    00591         operator->() const
    00592         {
    00593             return m_lastPopped;
    00594         }
    00595
    00596         bool
    00597         operator==(ElemTemplateElement*     theRHS)
    00598         {
    00599             return m_lastPopped == theRHS;
    00600         }
    00601
    00602         bool
    00603         operator!=(ElemTemplateElement*     theRHS)
    00604         {
    00605             return m_lastPopped != theRHS;
    00606         }
    00607
    00608         void
    00609         operator=(ElemTemplateElement*  theRHS)
    00610         {
    00611             if (theRHS != m_lastPopped)
    00612             {
    00613                 cleanup();
    00614
    00615                 m_lastPopped = theRHS;
    00616             }
    00617         }
    00618
    00619         void
    00620         swap(LastPoppedHolder&  theOther)
    00621         {
    00622             ElemTemplateElement* const  theTemp = m_lastPopped;
    00623
    00624             m_lastPopped = theOther.m_lastPopped;
    00625
    00626             theOther.m_lastPopped = theTemp;
    00627         }
    00628
    00629         ElemTemplateElement*
    00630         get() const
    00631         {
    00632             return m_lastPopped;
    00633         }
    00634
    00635     private:
    00636
    00637         void
    00638         set(ElemTemplateElement*    theNewElement)
    00639         {
    00640             if (theNewElement != m_lastPopped)
    00641             {
    00642                 cleanup();
    00643
    00644                 m_lastPopped = theNewElement;
    00645             }
    00646         }
    00647
    00648         // Not implemented...
    00649         LastPoppedHolder&
    00650         operator=(const LastPoppedHolder&);
    00651
    00652         LastPoppedHolder(const LastPoppedHolder&);
    00653
    00654         // Helper functions...
    00655         void
    00656         cleanup();
    00657
    00658         // Data members...
    00659         StylesheetHandler&      m_stylesheetHandler;
    00660
    00661         ElemTemplateElement*    m_lastPopped;
    00662     };
    00663
    00664     friend class LastPoppedHolder;
    00665
    00669     LastPoppedHolder    m_lastPopped;
    00670
    00674     bool m_inTemplate;
    00675
    00680     bool m_foundStylesheet;
    00681
    00687     bool m_foundNotImport;
    00688
    00689     XalanDOMString      m_elementLocalName;
    00690
    00695     XalanDOMString  m_accumulateText;
    00696
    00697     XalanDOMString  m_includeBase;
    00698
    00699     BoolStackType   m_inExtensionElementStack;
    00700
    00701     BoolStackType   m_preserveSpaceStack;
    00702
    00703     // Note that these variables must not be saved by
    00704     // PushPopIncludeState...
    00705     unsigned long   m_locatorsPushed;
    00706
    00707     QNameSetType    m_globalVariableNames;
    00708
    00709     enum { eVariablesStackDefault = 20 };
    00710
    00711     QNameSetVectorType  m_inScopeVariableNamesStack;
    00712
    00716     ElemTemplateElement*
    00717     initWrapperless(
    00718             const XalanDOMChar*         name,
    00719             const AttributeListType&    atts,
    00720             const LocatorType*          locator);
    00721
    00722     const XalanDOMString*
    00723     getNamespaceFromStack(const XalanDOMChar*   theName,
    00724                             XalanDOMString&     theBuffer) const;
    00725
    00726     const XalanDOMString*
    00727     getNamespaceForPrefixFromStack(const XalanDOMString&    thePrefix) const;
    00728
    00729     class PushPopIncludeState;
    00730
    00731     friend class StylesheetHandler::PushPopIncludeState;
    00732
    00733     class PushPopIncludeState
    00734     {
    00735     public:
    00736
    00737         PushPopIncludeState(StylesheetHandler&      theHandler);
    00738
    00739         ~PushPopIncludeState();
    00740
    00741     private:
    00742
    00743         StylesheetHandler&                  m_handler;
    00744
    00745         ElemTemplateStackType               m_elemStack;
    00746
    00747         ElemTemplateElement* const          m_pTemplate;
    00748
    00749         LastPoppedHolder                    m_lastPopped;
    00750
    00751         const bool                          m_inTemplate;
    00752
    00753         const bool                          m_foundStylesheet;
    00754
    00755         const XalanDOMString                m_XSLNameSpaceURL;
    00756
    00757         const bool                          m_foundNotImport;
    00758
    00759         Stylesheet::NamespaceVectorType     m_namespaceDecls;
    00760
    00761         Stylesheet::NamespacesStackType     m_namespaces;
    00762
    00763         NamespacesHandler                   m_namespacesHandler;
    00764
    00765         BoolStackType                       m_inExtensionElementStack;
    00766
    00767         BoolStackType                       m_preserveSpaceStack;
    00768     };
    00769
    00770     static const XalanDOMString             s_emptyString;
    00771 };
    00772
    00773
    00774
    00775 XALAN_CPP_NAMESPACE_END
    00776
    00777
    00778
    00779 #endif  // XALAN_STYLESHEETHANDLER_HEADER_GUARD

Interpreting class diagrams

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

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