Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.4

Main Page   Namespace List   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 <XalanDOM/XalanDOMString.hpp>
00075 
00076 
00077 
00078 #include <PlatformSupport/FormatterListener.hpp>
00079 
00080 
00081 
00082 #include <XPath/XalanQNameByValue.hpp>
00083 
00084 
00085 
00086 #include <XSLT/NamespacesHandler.hpp>
00087 #include <XSLT/Stylesheet.hpp>
00088 
00089 
00090 
00091 class ElemTemplate;
00092 class ElemTemplateElement;
00093 class ElemTextLiteral;
00094 class ExtensionNSHandler;
00095 class StylesheetConstructionContext;
00096 
00097 
00098 
00105 class XALAN_XSLT_EXPORT StylesheetHandler : public FormatterListener
00106 {
00107 
00108 public:
00109 
00110 #if defined(XALAN_NO_NAMESPACES)
00111     typedef vector<ElemTemplateElement*>        ElemTemplateStackType;
00112     typedef vector<ElemTextLiteral*>            ElemTextLiteralStackType;
00113     typedef set<ElemTemplateElement*,
00114                 less<ElemTemplateElement*> >    ElemTemplateSetType;
00115     typedef vector<bool>                        BoolStackType;
00116     typedef set<XalanQNameByValue,
00117                 less<XalanQNameByValue> >       QNameSetType;
00118     typedef vector<QNameSetType>                QNameSetVectorType;
00119 #else
00120     typedef std::vector<ElemTemplateElement*>   ElemTemplateStackType;
00121     typedef std::vector<ElemTextLiteral*>       ElemTextLiteralStackType;
00122     typedef std::set<ElemTemplateElement*>      ElemTemplateSetType;
00123     typedef std::vector<bool>                   BoolStackType;
00124     typedef std::set<XalanQNameByValue>         QNameSetType;
00125     typedef std::vector<QNameSetType>           QNameSetVectorType;
00126 #endif
00127 
00131     static void
00132     initialize();
00133 
00137     static void
00138     terminate();
00139 
00144     StylesheetHandler(
00145             Stylesheet&                     stylesheetTree,
00146             StylesheetConstructionContext&  constructionContext);
00147 
00148     virtual
00149     ~StylesheetHandler();
00150 
00174     virtual void characters (const XMLCh* const chars, const unsigned int length);
00175 
00186     virtual void charactersRaw(const XMLCh* const chars, const unsigned int length);
00187 
00211     virtual void cdata(const XMLCh* const ch, const unsigned int length);
00212 
00236     virtual void ignorableWhitespace (const XMLCh* const chars, const unsigned int length);
00237 
00254     virtual void processingInstruction (const XMLCh* const target, const XMLCh* const data);
00255 
00262     virtual void comment(const XMLCh* const data);
00263 
00270     virtual void entityReference(const XMLCh* const data);
00271 
00272     // These methods are inherited DocumentHandler ...
00273     
00274     // $$$ Theoretically, shouldn't need javadoc for these, since they are
00275     // inherited from DocumentHandler, but let's leave them in for now -- JMD
00276 
00302     virtual void setDocumentLocator(const Locator* const    locator);
00303 
00313     virtual void startDocument();
00314 
00326     virtual void endDocument ();
00327     
00349     virtual void startElement (const XMLCh* const name, AttributeList& attrs);
00350     
00365     virtual void endElement(const XMLCh* const name);
00366     
00372     virtual void resetDocument();
00373 
00374 protected:
00375 
00385     bool
00386     isAttrOK(
00387             const XalanDOMChar*     attrName,
00388             const AttributeList&    atts,
00389             int                     which);
00390 
00401     bool
00402     processSpaceAttr(
00403             const XalanDOMChar*     aname,
00404             const AttributeList&    atts,
00405             int                     which,
00406             const Locator*          locator,
00407             bool&                   fPreserve);
00408 
00417     bool
00418     processSpaceAttr(
00419             const AttributeList&    atts,
00420             const Locator*          locator,
00421             bool&                   fPreserve);
00422 
00426     void
00427     processImport(
00428             const XalanDOMChar*     name,
00429             const AttributeList&    atts,
00430             const Locator*          locator);
00431 
00435     void
00436     processInclude(
00437             const XalanDOMChar*     name,
00438             const AttributeList&    atts,
00439             const Locator*          locator);
00440 
00441     void
00442     doCleanup();
00443 
00444 private:
00445 
00446     // not implemented
00447     StylesheetHandler(const StylesheetHandler&);
00448 
00449     StylesheetHandler&
00450     operator=(const StylesheetHandler&);
00451 
00452     // Utility functions...
00453     void
00454     error(
00455             const char*     theMessage,
00456             const Locator*  theLocator) const;
00457 
00458     void
00459     error(
00460             const XalanDOMString&   theMessage,
00461             const Locator*          theLocator) const;
00462 
00463     void
00464     processText(
00465             const XMLCh*                chars,
00466             XalanDOMString::size_type   length);
00467 
00468     void
00469     accumulateText(
00470             const XMLCh*                chars,
00471             XalanDOMString::size_type   length);
00472 
00473     void
00474     processAccumulatedText();
00475 
00476     void
00477     processTopLevelElement(
00478             const XalanDOMChar*     name,
00479             const XalanDOMString&   localName,
00480             const XalanDOMString&   ns,
00481             const AttributeList&    atts,
00482             int                     xslToken,
00483             const Locator*          locator,
00484             bool&                   fPreserveSpace,
00485             bool&                   fSpaceAttrProcessed);
00486 
00487     void
00488     processStylesheet(
00489             const XalanDOMChar*     name,
00490             const AttributeList&    atts,
00491             const Locator*          locator,
00492             bool&                   fPreserveSpace,
00493             bool&                   fSpaceAttrProcessed);
00494 
00495     void
00496     processPreserveStripSpace(
00497             const XalanDOMChar*     name,
00498             const AttributeList&    atts,
00499             const Locator*          locator,
00500             int                     xslToken);
00501 
00502     void
00503     appendChildElementToParent(
00504             ElemTemplateElement*    elem,
00505             const Locator*          locator);
00506 
00507     void
00508     appendChildElementToParent(
00509             ElemTemplateElement*    parent,
00510             ElemTemplateElement*    elem);
00511 
00512     void
00513     appendChildElementToParent(
00514             ElemTemplateElement*    parent,
00515             ElemTemplateElement*    elem,
00516             const Locator*          locator);
00517 
00518     bool
00519     inExtensionElement() const;
00520 
00521     void
00522     processExtensionElement(
00523             const XalanDOMChar*     name,
00524             const XalanDOMString&   localName,
00525             const AttributeList&    atts,
00526             const Locator*          locator);
00527 
00528     void
00529     checkForOrAddVariableName(
00530             const XalanQName&   theVariableName,
00531             const Locator*      theLocator);
00532 
00533     // Data members...
00534 
00538     Stylesheet&     m_stylesheet;
00539 
00543     StylesheetConstructionContext&  m_constructionContext;
00544 
00548     ElemTemplateStackType   m_elemStack;
00549 
00555     ElemTemplateSetType     m_elemStackParentedElements;
00556 
00560     ElemTemplateStackType   m_strayElements;
00561 
00567     ElemTextLiteralStackType m_whiteSpaceElems;
00568 
00572     ElemTemplate* m_pTemplate;
00573     
00578     ElemTemplateElement* m_lastPopped;
00579     
00583     bool m_inTemplate;
00584     
00589     bool m_foundStylesheet;
00590     
00596     bool m_foundNotImport;
00597 
00602     XalanDOMString  m_accumulateText;
00603 
00604     XalanDOMString  m_includeBase;
00605 
00606     BoolStackType   m_inExtensionElementStack;
00607 
00608     BoolStackType   m_preserveSpaceStack;
00609 
00610     bool                    m_inLXSLTScript;
00611 
00612     XalanDOMString          m_LXSLTScriptBody;
00613     XalanDOMString          m_LXSLTScriptLang;
00614     XalanDOMString          m_LXSLTScriptSrcURL;
00615     ExtensionNSHandler*     m_pLXSLTExtensionNSH;
00616 
00617     // Note that these variables must not be saved by
00618     // PushPopIncludeState...
00619     unsigned long   m_locatorsPushed;
00620 
00621     QNameSetType        m_globalVariableNames;
00622 
00623     enum { eVariablesStackDefault = 20 };
00624 
00625     QNameSetVectorType  m_inScopeVariableNamesStack;
00626 
00630     ElemTemplateElement*
00631     initWrapperless(
00632             const XalanDOMChar*     name,
00633             const AttributeList&    atts,
00634             int                     lineNumber,
00635             int                     columnNumber);
00636 
00637     const XalanDOMString&
00638     getNamespaceFromStack(const XalanDOMChar*   theName) const;
00639 
00640     const XalanDOMString&
00641     getNamespaceForPrefixFromStack(const XalanDOMString&    thePrefix) const;
00642 
00643     class PushPopIncludeState
00644     {
00645     public:
00646 
00647         PushPopIncludeState(StylesheetHandler&      theHandler);
00648 
00649         ~PushPopIncludeState();
00650 
00651     private:
00652 
00653         StylesheetHandler&                  m_handler;
00654 
00655         ElemTemplateStackType               m_elemStack;
00656 
00657         ElemTemplateSetType                 m_elemStackParentedElements;
00658 
00659         ElemTemplate* const                 m_pTemplate;
00660 
00661         ElemTemplateElement* const          m_lastPopped;       
00662 
00663         const bool                          m_inTemplate;       
00664 
00665         const bool                          m_foundStylesheet;
00666 
00667         const XalanDOMString                m_XSLNameSpaceURL;
00668 
00669         const bool                          m_foundNotImport;
00670 
00671         Stylesheet::NamespaceVectorType     m_namespaceDecls;
00672 
00673         Stylesheet::NamespacesStackType     m_namespaces;
00674 
00675         NamespacesHandler                   m_namespacesHandler;
00676 
00677         BoolStackType                       m_inExtensionElementStack;
00678 
00679         BoolStackType                       m_preserveSpaceStack;
00680     };
00681 
00682     friend class PushPopIncludeState;
00683 
00684     static const XalanDOMString             s_emptyString;
00685 
00686     static const XalanQName&                s_spaceAttrQName;
00687 };
00688 
00689 
00690 
00691 #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.4
Copyright © 2000, 2001, 2002 The Apache Software Foundation. All Rights Reserved.