## Xalan-C++ API Documentation

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

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  * The Apache Software License, Version 1.1
    00003  *
    00004  *
    00005  * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
    00006  * reserved.
    00007  *
    00008  * Redistribution and use in source and binary forms, with or without
    00009  * modification, are permitted provided that the following conditions
    00010  * are met:
    00011  *
    00012  * 1. Redistributions of source code must retain the above copyright
    00013  *    notice, this list of conditions and the following disclaimer.
    00014  *
    00015  * 2. Redistributions in binary form must reproduce the above copyright
    00016  *    notice, this list of conditions and the following disclaimer in
    00017  *    the documentation and/or other materials provided with the
    00018  *    distribution.
    00019  *
    00020  * 3. The end-user documentation included with the redistribution,
    00021  *    if any, must include the following acknowledgment:
    00022  *       "This product includes software developed by the
    00023  *        Apache Software Foundation (http://www.apache.org/)."
    00024  *    Alternately, this acknowledgment may appear in the software itself,
    00025  *    if and wherever such third-party acknowledgments normally appear.
    00026  *
    00027  * 4. The names "Xalan" and "Apache Software Foundation" must
    00028  *    not be used to endorse or promote products derived from this
    00029  *    software without prior written permission. For written
    00030  *    permission, please contact apache@apache.org.
    00031  *
    00032  * 5. Products derived from this software may not be called "Apache",
    00033  *    nor may "Apache" appear in their name, without prior written
    00034  *    permission of the Apache Software Foundation.
    00035  *
    00036  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    00037  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    00038  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    00039  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
    00040  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    00041  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    00042  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
    00043  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    00044  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    00045  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    00046  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    00047  * SUCH DAMAGE.
    00048  * ====================================================================
    00049  *
    00050  * This software consists of voluntary contributions made by many
    00051  * individuals on behalf of the Apache Software Foundation and was
    00052  * originally based on software copyright (c) 1999, International
    00053  * Business Machines, Inc., http://www.ibm.com.  For more
    00054  * information on the Apache Software Foundation, please see
    00055  * <http://www.apache.org/>.
    00056  *
    00057  * $ Id: $
    00058  *
    00059  */
    00060
    00061 #if !defined(XALAN_STYLESHEETHANDLER_HEADER_GUARD)
    00062 #define XALAN_STYLESHEETHANDLER_HEADER_GUARD
    00063
    00064 // Base include file.   Must be first.
    00065 #include "XSLTDefinitions.hpp"
    00066
    00067
    00068
    00069 #include <vector>
    00070 #include <set>
    00071
    00072
    00073
    00074 #include <xalanc/XalanDOM/XalanDOMString.hpp>
    00075
    00076
    00077
    00078 #include <xalanc/PlatformSupport/FormatterListener.hpp>
    00079
    00080
    00081
    00082 #include <xalanc/XPath/XalanQNameByValue.hpp>
    00083
    00084
    00085
    00086 #include <xalanc/XSLT/NamespacesHandler.hpp>
    00087 #include <xalanc/XSLT/Stylesheet.hpp>
    00088 #include <xalanc/XSLT/XalanElemEmptyAllocator.hpp>
    00089 #include <xalanc/XSLT/XalanElemTextAllocator.hpp>
    00090
    00091
    00092
    00093 XALAN_CPP_NAMESPACE_BEGIN
    00094
    00095
    00096
    00097 class ElemTemplate;
    00098 class ElemTemplateElement;
    00099 class ElemTextLiteral;
    00100 class ExtensionNSHandler;
    00101 class StylesheetConstructionContext;
    00102
    00103
    00104
    00111 class XALAN_XSLT_EXPORT StylesheetHandler : public FormatterListener
    00112 {
    00113
    00114 public:
    00115
    00116 #if defined(XALAN_NO_STD_NAMESPACE)
    00117     typedef vector<ElemTemplateElement*>        ElemTemplateStackType;
    00118     typedef vector<ElemTemplateElement*>        ElemTextLiteralStackType;
    00119 #if defined(XALAN_USE_DEQUE_FOR_VECTOR_BOOL)
    00120     typedef deque<bool>                         BoolVectorType;
    00121 #else
    00122     typedef vector<bool>                        BoolStackType;
    00123 #endif
    00124     typedef set<XalanQNameByReference,
    00125                 less<XalanQName> >              QNameSetType;
    00126     typedef vector<QNameSetType>                QNameSetVectorType;
    00127 #else
    00128     typedef std::vector<ElemTemplateElement*>   ElemTemplateStackType;
    00129     typedef std::vector<ElemTemplateElement*>   ElemTextLiteralStackType;
    00130 #if defined(XALAN_USE_DEQUE_FOR_VECTOR_BOOL)
    00131     typedef std::deque<bool>                    BoolVectorType;
    00132 #else
    00133     typedef std::vector<bool>                   BoolStackType;
    00134 #endif
    00135     typedef std::set<XalanQNameByReference,
    00136                      std::less<XalanQName> >    QNameSetType;
    00137     typedef std::vector<QNameSetType>           QNameSetVectorType;
    00138 #endif
    00139
    00143     static void
    00144     initialize();
    00145
    00149     static void
    00150     terminate();
    00151
    00156     StylesheetHandler(
    00157             Stylesheet&                     stylesheetTree,
    00158             StylesheetConstructionContext&  constructionContext);
    00159
    00160     virtual
    00161     ~StylesheetHandler();
    00162
    00186     virtual void characters (const XMLCh* const chars, const unsigned int length);
    00187
    00198     virtual void charactersRaw(const XMLCh* const chars, const unsigned int length);
    00199
    00223     virtual void cdata(const XMLCh* const ch, const unsigned int length);
    00224
    00248     virtual void ignorableWhitespace (const XMLCh* const chars, const unsigned int length);
    00249
    00266     virtual void processingInstruction (const XMLCh* const target, const XMLCh* const data);
    00267
    00274     virtual void comment(const XMLCh* const data);
    00275
    00282     virtual void entityReference(const XMLCh* const data);
    00283
    00284     // These methods are inherited DocumentHandler ...
    00285
    00286     // $$$ Theoretically, shouldn't need javadoc for these, since they are
    00287     // inherited from DocumentHandler, but let's leave them in for now -- JMD
    00288
    00314     virtual void setDocumentLocator(const LocatorType* const    locator);
    00315
    00325     virtual void startDocument();
    00326
    00338     virtual void endDocument();
    00339
    00361     virtual void startElement(const XMLCh* const name, AttributeListType& attrs);
    00362
    00377     virtual void endElement(const XMLCh* const name);
    00378
    00384     virtual void resetDocument();
    00385
    00386 protected:
    00387
    00397     bool
    00398     isAttrOK(
    00399             const XalanDOMChar*         attrName,
    00400             const AttributeListType&    atts,
    00401             int                         which);
    00402
    00413     bool
    00414     processSpaceAttr(
    00415             const XalanDOMChar*         aname,
    00416             const AttributeListType&    atts,
    00417             int                         which,
    00418             const LocatorType*          locator,
    00419             bool&                       fPreserve);
    00420
    00429     bool
    00430     processSpaceAttr(
    00431             const AttributeListType&    atts,
    00432             const LocatorType*          locator,
    00433             bool&                       fPreserve);
    00434
    00438     void
    00439     processImport(
    00440             const XalanDOMChar*         name,
    00441             const AttributeListType&    atts,
    00442             const LocatorType*          locator);
    00443
    00447     void
    00448     processInclude(
    00449             const XalanDOMChar*         name,
    00450             const AttributeListType&    atts,
    00451             const LocatorType*          locator);
    00452
    00453     void
    00454     doCleanup();
    00455
    00456 private:
    00457
    00458     enum { eElemEmptyAllocatorBlockSize = 10, eElemTextBlockSize = 10 };
    00459
    00460     // not implemented
    00461     StylesheetHandler(const StylesheetHandler&);
    00462
    00463     StylesheetHandler&
    00464     operator=(const StylesheetHandler&);
    00465
    00466     // Utility functions...
    00467     void
    00468     error(
    00469             const char*         theMessage,
    00470             const LocatorType*  theLocator) const;
    00471
    00472     void
    00473     illegalAttributeError(
    00474             const XalanDOMChar*     theElementName,
    00475             const XalanDOMChar*     theAttributeName,
    00476             const LocatorType*      theLocator) const;
    00477
    00478     void
    00479     error(
    00480             const XalanDOMChar*     theMessage1,
    00481             const XalanDOMChar*     theMessage2,
    00482             const LocatorType*      theLocator) const;
    00483
    00484     void
    00485     error(
    00486             const XalanDOMChar*     theMessage1,
    00487             const XalanDOMString&   theMessage2,
    00488             const LocatorType*      theLocator) const;
    00489
    00490     void
    00491     error(
    00492             const XalanDOMString&   theMessage1,
    00493             const XalanDOMChar*     theMessage2,
    00494             const LocatorType*      theLocator) const;
    00495
    00496     void
    00497     error(
    00498             const XalanDOMString&   theMessage1,
    00499             const XalanDOMString&   theMessage2,
    00500             const LocatorType*      theLocator) const;
    00501
    00502     void
    00503     warn(
    00504             const XalanDOMChar*     theMessage1,
    00505             const XalanDOMChar*     theMessage2,
    00506             const LocatorType*      theLocator) const;
    00507
    00508     void
    00509     warn(
    00510             const XalanDOMChar*     theMessage1,
    00511             const XalanDOMString&   theMessage2,
    00512             const LocatorType*      theLocator) const;
    00513
    00514     void
    00515     error(
    00516             const XalanDOMString&   theMessage,
    00517             const LocatorType*      theLocator) const;
    00518
    00519     void
    00520     processText(
    00521             const XMLCh*                chars,
    00522             XalanDOMString::size_type   length);
    00523
    00524     void
    00525     accumulateText(
    00526             const XMLCh*                chars,
    00527             XalanDOMString::size_type   length);
    00528
    00529     void
    00530     processAccumulatedText();
    00531
    00532     void
    00533     processTopLevelElement(
    00534             const XalanDOMChar*         name,
    00535             const AttributeListType&    atts,
    00536             int                         xslToken,
    00537             const LocatorType*          locator,
    00538             bool&                       fPreserveSpace,
    00539             bool&                       fSpaceAttrProcessed);
    00540
    00541     void
    00542     processStylesheet(
    00543             const XalanDOMChar*         name,
    00544             const AttributeListType&    atts,
    00545             const LocatorType*          locator,
    00546             bool&                       fPreserveSpace,
    00547             bool&                       fSpaceAttrProcessed);
    00548
    00549     void
    00550     processPreserveStripSpace(
    00551             const XalanDOMChar*         name,
    00552             const AttributeListType&    atts,
    00553             const LocatorType*          locator,
    00554             int                         xslToken);
    00555
    00556     void
    00557     appendChildElementToParent(
    00558             ElemTemplateElement*    elem,
    00559             const LocatorType*      locator);
    00560
    00561     void
    00562     appendChildElementToParent(
    00563             ElemTemplateElement*    parent,
    00564             ElemTemplateElement*    elem);
    00565
    00566     void
    00567     appendChildElementToParent(
    00568             ElemTemplateElement*    parent,
    00569             ElemTemplateElement*    elem,
    00570             const LocatorType*      locator);
    00571
    00572     bool
    00573     inExtensionElement() const;
    00574
    00575     void
    00576     processExtensionElement(
    00577             const XalanDOMChar*         name,
    00578             const XalanDOMString&       localName,
    00579             const AttributeListType&    atts,
    00580             const LocatorType*          locator);
    00581
    00582     void
    00583     checkForOrAddVariableName(
    00584             const XalanQName&   theVariableName,
    00585             const LocatorType*  theLocator);
    00586
    00587     // Data members...
    00588
    00592     Stylesheet&     m_stylesheet;
    00593
    00597     StylesheetConstructionContext&  m_constructionContext;
    00598
    00602     XalanElemEmptyAllocator     m_elemEmptyAllocator;
    00603
    00607     XalanElemTextAllocator      m_elemTextAllocator;
    00608
    00612     ElemTemplateStackType   m_elemStack;
    00613
    00619     ElemTextLiteralStackType    m_whiteSpaceElems;
    00620
    00624     ElemTemplateElement*    m_pTemplate;
    00625
    00626     class LastPoppedHolder
    00627     {
    00628     public:
    00629
    00630         LastPoppedHolder(StylesheetHandler&     theStylesheetHandler) :
    00631             m_stylesheetHandler(theStylesheetHandler),
    00632             m_lastPopped(0)
    00633         {
    00634         }
    00635
    00636         ~LastPoppedHolder()
    00637         {
    00638             cleanup();
    00639         }
    00640
    00641         ElemTemplateElement*
    00642         operator->() const
    00643         {
    00644             return m_lastPopped;
    00645         }
    00646
    00647         bool
    00648         operator==(ElemTemplateElement*     theRHS)
    00649         {
    00650             return m_lastPopped == theRHS;
    00651         }
    00652
    00653         bool
    00654         operator!=(ElemTemplateElement*     theRHS)
    00655         {
    00656             return m_lastPopped != theRHS;
    00657         }
    00658
    00659         void
    00660         operator=(ElemTemplateElement*  theRHS)
    00661         {
    00662             if (theRHS != m_lastPopped)
    00663             {
    00664                 cleanup();
    00665
    00666                 m_lastPopped = theRHS;
    00667             }
    00668         }
    00669
    00670         void
    00671         swap(LastPoppedHolder&  theOther)
    00672         {
    00673             ElemTemplateElement* const  theTemp = m_lastPopped;
    00674
    00675             m_lastPopped = theOther.m_lastPopped;
    00676
    00677             theOther.m_lastPopped = theTemp;
    00678         }
    00679
    00680         ElemTemplateElement*
    00681         get() const
    00682         {
    00683             return m_lastPopped;
    00684         }
    00685
    00686     private:
    00687
    00688         void
    00689         set(ElemTemplateElement*    theNewElement)
    00690         {
    00691             if (theNewElement != m_lastPopped)
    00692             {
    00693                 cleanup();
    00694
    00695                 m_lastPopped = theNewElement;
    00696             }
    00697         }
    00698
    00699         // Not implemented...
    00700         LastPoppedHolder&
    00701         operator=(const LastPoppedHolder&);
    00702
    00703         LastPoppedHolder(const LastPoppedHolder&);
    00704
    00705         // Helper functions...
    00706         void
    00707         cleanup();
    00708
    00709         // Data members...
    00710         StylesheetHandler&      m_stylesheetHandler;
    00711
    00712         ElemTemplateElement*    m_lastPopped;
    00713     };
    00714
    00715     friend class LastPoppedHolder;
    00716
    00720     LastPoppedHolder    m_lastPopped;
    00721
    00725     bool m_inTemplate;
    00726
    00731     bool m_foundStylesheet;
    00732
    00738     bool m_foundNotImport;
    00739
    00740     XalanDOMString      m_elementLocalName;
    00741
    00746     XalanDOMString  m_accumulateText;
    00747
    00748     XalanDOMString  m_includeBase;
    00749
    00750     BoolStackType   m_inExtensionElementStack;
    00751
    00752     BoolStackType   m_preserveSpaceStack;
    00753
    00754     // Note that these variables must not be saved by
    00755     // PushPopIncludeState...
    00756     unsigned long   m_locatorsPushed;
    00757
    00758     QNameSetType    m_globalVariableNames;
    00759
    00760     enum { eVariablesStackDefault = 20 };
    00761
    00762     QNameSetVectorType  m_inScopeVariableNamesStack;
    00763
    00767     ElemTemplateElement*
    00768     initWrapperless(
    00769             const XalanDOMChar*         name,
    00770             const AttributeListType&    atts,
    00771             const LocatorType*          locator);
    00772
    00773     const XalanDOMString*
    00774     getNamespaceFromStack(const XalanDOMChar*   theName) const;
    00775
    00776     const XalanDOMString*
    00777     getNamespaceForPrefixFromStack(const XalanDOMString&    thePrefix) const;
    00778
    00779     class PushPopIncludeState;
    00780
    00781     friend class StylesheetHandler::PushPopIncludeState;
    00782
    00783     class PushPopIncludeState
    00784     {
    00785     public:
    00786
    00787         PushPopIncludeState(StylesheetHandler&      theHandler);
    00788
    00789         ~PushPopIncludeState();
    00790
    00791     private:
    00792
    00793         StylesheetHandler&                  m_handler;
    00794
    00795         ElemTemplateStackType               m_elemStack;
    00796
    00797         ElemTemplateElement* const          m_pTemplate;
    00798
    00799         LastPoppedHolder                    m_lastPopped;
    00800
    00801         const bool                          m_inTemplate;
    00802
    00803         const bool                          m_foundStylesheet;
    00804
    00805         const XalanDOMString                m_XSLNameSpaceURL;
    00806
    00807         const bool                          m_foundNotImport;
    00808
    00809         Stylesheet::NamespaceVectorType     m_namespaceDecls;
    00810
    00811         Stylesheet::NamespacesStackType     m_namespaces;
    00812
    00813         NamespacesHandler                   m_namespacesHandler;
    00814
    00815         BoolStackType                       m_inExtensionElementStack;
    00816
    00817         BoolStackType                       m_preserveSpaceStack;
    00818     };
    00819
    00820     static const XalanDOMString             s_emptyString;
    00821 };
    00822
    00823
    00824
    00825 XALAN_CPP_NAMESPACE_END
    00826
    00827
    00828
    00829 #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.6 Copyright © 2000, 2001, 2002, 2003 The Apache Software Foundation. All Rights Reserved.