Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.3

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 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 <XalanDOM/XalanDOMString.hpp>
00075 
00076 
00077 
00078 #include <PlatformSupport/FormatterListener.hpp>
00079 
00080 
00081 
00082 #include <XSLT/NamespacesHandler.hpp>
00083 #include <XSLT/Stylesheet.hpp>
00084 
00085 
00086 
00087 class ElemTemplate;
00088 class ElemTemplateElement;
00089 class ElemTextLiteral;
00090 class ExtensionNSHandler;
00091 class StylesheetConstructionContext;
00092 class XalanQName;
00093 
00094 
00095 
00102 class XALAN_XSLT_EXPORT StylesheetHandler : public FormatterListener
00103 {
00104 
00105 public:
00106 
00107 #if defined(XALAN_NO_NAMESPACES)
00108     typedef vector<ElemTemplateElement*>        ElemTemplateStackType;
00109     typedef vector<ElemTextLiteral*>            ElemTextLiteralStackType;
00110     typedef set<ElemTemplateElement*,
00111                 less<ElemTemplateElement*> >    ElemTemplateSetType;
00112     typedef vector<bool>                        BoolStackType;
00113 #else
00114     typedef std::vector<ElemTemplateElement*>   ElemTemplateStackType;
00115     typedef std::vector<ElemTextLiteral*>       ElemTextLiteralStackType;
00116     typedef std::set<ElemTemplateElement*>      ElemTemplateSetType;
00117     typedef std::vector<bool>                   BoolStackType;
00118 #endif
00119 
00123     static void
00124     initialize();
00125 
00129     static void
00130     terminate();
00131 
00136     StylesheetHandler(
00137             Stylesheet&                     stylesheetTree,
00138             StylesheetConstructionContext&  constructionContext);
00139 
00140     virtual
00141     ~StylesheetHandler();
00142 
00166     virtual void characters (const XMLCh* const chars, const unsigned int length);
00167 
00178     virtual void charactersRaw(const XMLCh* const chars, const unsigned int length);
00179 
00203     virtual void cdata(const XMLCh* const ch, const unsigned int length);
00204 
00228     virtual void ignorableWhitespace (const XMLCh* const chars, const unsigned int length);
00229 
00246     virtual void processingInstruction (const XMLCh* const target, const XMLCh* const data);
00247 
00254     virtual void comment(const XMLCh* const data);
00255 
00262     virtual void entityReference(const XMLCh* const data);
00263 
00264     // These methods are inherited DocumentHandler ...
00265     
00266     // $$$ Theoretically, shouldn't need javadoc for these, since they are
00267     // inherited from DocumentHandler, but let's leave them in for now -- JMD
00268 
00294     virtual void setDocumentLocator(const Locator* const    locator);
00295 
00305     virtual void startDocument();
00306 
00318     virtual void endDocument ();
00319     
00341     virtual void startElement (const XMLCh* const name, AttributeList& attrs);
00342     
00357     virtual void endElement(const XMLCh* const name);
00358     
00364     virtual void resetDocument();
00365 
00366 protected:
00367 
00377     bool
00378     isAttrOK(
00379             const XalanDOMChar*     attrName,
00380             const AttributeList&    atts,
00381             int                     which);
00382 
00393     bool
00394     processSpaceAttr(
00395             const XalanDOMChar*     aname,
00396             const AttributeList&    atts,
00397             int                     which,
00398             const Locator*          locator,
00399             bool&                   fPreserve);
00400 
00409     bool
00410     processSpaceAttr(
00411             const AttributeList&    atts,
00412             const Locator*          locator,
00413             bool&                   fPreserve);
00414 
00418     void
00419     processImport(
00420             const XalanDOMChar*     name,
00421             const AttributeList&    atts,
00422             const Locator*          locator);
00423 
00427     void
00428     processInclude(
00429             const XalanDOMChar*     name,
00430             const AttributeList&    atts,
00431             const Locator*          locator);
00432 
00433     void
00434     doCleanup();
00435 
00436 private:
00437 
00438     // not implemented
00439     StylesheetHandler(const StylesheetHandler&);
00440 
00441     StylesheetHandler&
00442     operator=(const StylesheetHandler&);
00443 
00444     // Utility functions...
00445     void
00446     error(
00447             const char*     theMessage,
00448             const Locator*  theLocator) const;
00449 
00450     void
00451     error(
00452             const XalanDOMString&   theMessage,
00453             const Locator*          theLocator) const;
00454 
00455     void
00456     processText(
00457             const XMLCh*                chars,
00458             XalanDOMString::size_type   length);
00459 
00460     void
00461     accumulateText(
00462             const XMLCh*                chars,
00463             XalanDOMString::size_type   length);
00464 
00465     void
00466     processAccumulatedText();
00467 
00468     void
00469     processTopLevelElement(
00470             const XalanDOMChar*     name,
00471             const XalanDOMString&   localName,
00472             const XalanDOMString&   ns,
00473             const AttributeList&    atts,
00474             int                     xslToken,
00475             const Locator*          locator,
00476             bool&                   fPreserveSpace,
00477             bool&                   fSpaceAttrProcessed);
00478 
00479     void
00480     processStylesheet(
00481             const XalanDOMChar*     name,
00482             const AttributeList&    atts,
00483             const Locator*          locator,
00484             bool&                   fPreserveSpace,
00485             bool&                   fSpaceAttrProcessed);
00486 
00487     void
00488     processPreserveStripSpace(
00489             const XalanDOMChar*     name,
00490             const AttributeList&    atts,
00491             const Locator*          locator,
00492             int                     xslToken);
00493 
00494     void
00495     appendChildElementToParent(
00496             ElemTemplateElement*    elem,
00497             const Locator*          locator);
00498 
00499     bool
00500     inExtensionElement() const;
00501 
00502     void
00503     processExtensionElement(
00504             const XalanDOMChar*     name,
00505             const XalanDOMString&   localName,
00506             const AttributeList&    atts,
00507             const Locator*          locator);
00508 
00509     // Data members...
00510 
00514     Stylesheet&     m_stylesheet;
00515 
00519     StylesheetConstructionContext&  m_constructionContext;
00520 
00524     ElemTemplateStackType   m_elemStack;
00525 
00531     ElemTemplateSetType     m_elemStackParentedElements;
00532 
00536     ElemTemplateStackType   m_strayElements;
00537 
00543     ElemTextLiteralStackType m_whiteSpaceElems;
00544 
00548     ElemTemplate* m_pTemplate;
00549     
00554     ElemTemplateElement* m_lastPopped;
00555     
00559     bool m_inTemplate;
00560     
00565     bool m_foundStylesheet;
00566     
00572     bool m_foundNotImport;
00573 
00578     XalanDOMString  m_accumulateText;
00579 
00580     XalanDOMString  m_includeBase;
00581 
00582     BoolStackType   m_inExtensionElementStack;
00583 
00584     BoolStackType   m_preserveSpaceStack;
00585 
00586     bool                    m_inLXSLTScript;
00587 
00588     XalanDOMString          m_LXSLTScriptBody;
00589     XalanDOMString          m_LXSLTScriptLang;
00590     XalanDOMString          m_LXSLTScriptSrcURL;
00591     ExtensionNSHandler*     m_pLXSLTExtensionNSH;
00592 
00593     // Note that this variable must not be saved by
00594     // PushPopIncludeState...
00595     unsigned long   m_locatorsPushed;
00596 
00600     ElemTemplateElement*
00601     initWrapperless(
00602             const XalanDOMChar*     name,
00603             const AttributeList&    atts,
00604             int                     lineNumber,
00605             int                     columnNumber);
00606 
00607     const XalanDOMString&
00608     getNamespaceFromStack(const XalanDOMChar*   theName) const;
00609 
00610     const XalanDOMString&
00611     getNamespaceForPrefixFromStack(const XalanDOMString&    thePrefix) const;
00612 
00613     class PushPopIncludeState
00614     {
00615     public:
00616 
00617         PushPopIncludeState(StylesheetHandler&      theHandler);
00618 
00619         ~PushPopIncludeState();
00620 
00621     private:
00622 
00623         StylesheetHandler&                  m_handler;
00624 
00625         ElemTemplateStackType               m_elemStack;
00626 
00627         ElemTemplateSetType                 m_elemStackParentedElements;
00628 
00629         ElemTemplate* const                 m_pTemplate;
00630 
00631         ElemTemplateElement* const          m_lastPopped;       
00632 
00633         const bool                          m_inTemplate;       
00634 
00635         const bool                          m_foundStylesheet;
00636 
00637         const XalanDOMString                m_XSLNameSpaceURL;
00638 
00639         const bool                          m_foundNotImport;
00640 
00641         Stylesheet::NamespaceVectorType     m_namespaceDecls;
00642 
00643         Stylesheet::NamespacesStackType     m_namespaces;
00644 
00645         NamespacesHandler                   m_namespacesHandler;
00646 
00647         BoolStackType                       m_inExtensionElementStack;
00648 
00649         BoolStackType                       m_preserveSpaceStack;
00650     };
00651 
00652     friend class PushPopIncludeState;
00653 
00654     static const XalanDOMString             s_emptyString;
00655 
00656     static const XalanQName&                s_spaceAttrQName;
00657 };
00658 
00659 
00660 
00661 #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.3
Copyright © 2000, 2001 The Apache Software Foundation. All Rights Reserved.