Xalan-C++ API Documentation

The Xalan C++ XSL Transformer Version 1.1

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 <XMLSupport/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 
00093 
00094 
00101 class XALAN_XSLT_EXPORT StylesheetHandler : public FormatterListener
00102 {
00103 
00104 public:
00105 
00106 #if defined(XALAN_NO_NAMESPACES)
00107     typedef vector<ElemTemplateElement*>        ElemTemplateStackType;
00108     typedef vector<ElemTextLiteral*>            ElemTextLiteralStackType;
00109     typedef set<ElemTemplateElement*,
00110                 less<ElemTemplateElement*> >    ElemTemplateSetType;
00111     typedef vector<bool>                        BoolStackType;
00112 #else
00113     typedef std::vector<ElemTemplateElement*>   ElemTemplateStackType;
00114     typedef std::vector<ElemTextLiteral*>       ElemTextLiteralStackType;
00115     typedef std::set<ElemTemplateElement*>      ElemTemplateSetType;
00116     typedef std::vector<bool>                   BoolStackType;
00117 #endif
00118 
00122     XalanDOMString m_includeBase;
00123 
00128     StylesheetHandler(
00129             Stylesheet&                     stylesheetTree,
00130             StylesheetConstructionContext&  constructionContext);
00131 
00132     virtual
00133     ~StylesheetHandler();
00134 
00158     virtual void characters (const XMLCh* const chars, const unsigned int length);
00159 
00170     virtual void charactersRaw(const XMLCh* const chars, const unsigned int length);
00171 
00195     virtual void cdata(const XMLCh* const ch, const unsigned int length);
00196 
00220     virtual void ignorableWhitespace (const XMLCh* const chars, const unsigned int length);
00221 
00238     virtual void processingInstruction (const XMLCh* const target, const XMLCh* const data);
00239 
00246     virtual void comment(const XMLCh* const data);
00247 
00254     virtual void entityReference(const XMLCh* const data);
00255 
00256     // These methods are inherited DocumentHandler ...
00257     
00258     // $$$ Theoretically, shouldn't need javadoc for these, since they are
00259     // inherited from DocumentHandler, but let's leave them in for now -- JMD
00260 
00286     virtual void setDocumentLocator(const Locator* const    locator);
00287 
00297     virtual void startDocument();
00298 
00310     virtual void endDocument ();
00311     
00333     virtual void startElement (const XMLCh* const name, AttributeList& attrs);
00334     
00349     virtual void endElement(const XMLCh* const name);
00350     
00356     virtual void resetDocument();
00357 
00358 protected:
00359 
00369     bool
00370     isAttrOK(
00371             const XalanDOMChar*     attrName,
00372             const AttributeList&    atts,
00373             int                     which);
00374 
00384     bool
00385     processSpaceAttr(
00386             const XalanDOMChar*     aname,
00387             const AttributeList&    atts,
00388             int                     which,
00389             bool&                   fPreserve);
00390 
00398     bool
00399     processSpaceAttr(
00400             const AttributeList&    atts,
00401             bool&                   fPreserve);
00402 
00406     void
00407     processImport(
00408             const XalanDOMChar*     name,
00409             const AttributeList&    atts);
00410 
00414     void
00415     processInclude(const XalanDOMChar*      name,
00416                    const AttributeList&     atts);
00417 
00418     void
00419     error(
00420             const XalanDOMString&   theMessage,
00421             int                     theLineNumber,
00422             int                     theColumnNumber) const;
00423 
00424     void
00425     doCleanup();
00426 
00427 private:
00428 
00429     // not implemented
00430     StylesheetHandler(const StylesheetHandler&);
00431 
00432     StylesheetHandler&
00433     operator=(const StylesheetHandler&);
00434 
00435     // Utility function...
00436     void
00437     processText(
00438             const XMLCh* const  chars,
00439             const unsigned int  length);
00440 
00441     void
00442     accumulateText(
00443             const XMLCh* const  chars,
00444             const unsigned int  length);
00445 
00446     void
00447     processAccumulatedText();
00448 
00449     void
00450     processTopLevelElement(
00451             const XalanDOMChar*     name,
00452             const XalanDOMString&   localName,
00453             const XalanDOMString&   ns,
00454             const AttributeList&    atts,
00455             int                     xslToken,
00456             int                     lineNumber,
00457             int                     columnNumber,
00458             bool&                   fPreserveSpace,
00459             bool&                   fSpaceAttrProcessed);
00460 
00461     void
00462     processStylesheet(
00463             const XalanDOMChar*     name,
00464             const AttributeList&    atts,
00465             int                     lineNumber,
00466             int                     columnNumber,
00467             bool&                   fPreserveSpace,
00468             bool&                   fSpaceAttrProcessed);
00469 
00470     void
00471     processPreserveStripSpace(
00472             const XalanDOMChar*     name,
00473             const AttributeList&    atts,
00474             int                     lineNumber,
00475             int                     columnNumber,
00476             int                     xslToken);
00477 
00478     void
00479     appendChildElementToParent(
00480             ElemTemplateElement*    elem,
00481             int                     lineNumber,
00482             int                     columnNumber);
00483 
00484     bool
00485     inExtensionElement() const;
00486 
00487     void
00488     processExtensionElement(
00489             const XalanDOMChar*     name,
00490             const XalanDOMString&   localName,
00491             const AttributeList&    atts);
00492 
00493     // Data members...
00494     XalanDOMString  m_pendingException;
00495 
00496     bool            m_exceptionPending;
00497 
00501     Stylesheet&     m_stylesheet;
00502 
00506     StylesheetConstructionContext&  m_constructionContext;
00507 
00511     ElemTemplateStackType   m_elemStack;
00512 
00518     ElemTemplateSetType     m_elemStackParentedElements;
00519 
00523     ElemTemplateStackType   m_strayElements;
00524 
00530     ElemTextLiteralStackType m_whiteSpaceElems;
00531 
00535     ElemTemplate* m_pTemplate;
00536     
00541     ElemTemplateElement* m_lastPopped;
00542     
00546     bool m_inTemplate;
00547     
00552     bool m_foundStylesheet;
00553     
00559     bool m_foundNotImport;
00560 
00565     XalanDOMString  m_accumulateText;
00566 
00567     BoolStackType   m_inExtensionElementStack;
00568 
00569     BoolStackType   m_preserveSpaceStack;
00570 
00571     bool                    m_inLXSLTScript;
00572 
00573     XalanDOMString          m_LXSLTScriptBody;
00574     XalanDOMString          m_LXSLTScriptLang;
00575     XalanDOMString          m_LXSLTScriptSrcURL;
00576     ExtensionNSHandler*     m_pLXSLTExtensionNSH;
00577 
00578     // Note that this variable must not be saved by
00579     // PushPopIncludeState...
00580     unsigned long   m_locatorsPushed;
00581 
00585     ElemTemplateElement*
00586     initWrapperless(
00587             const XalanDOMChar*     name,
00588             const AttributeList&    atts,
00589             int                     lineNumber,
00590             int                     columnNumber);
00591 
00592 
00593     class PushPopIncludeState
00594     {
00595     public:
00596 
00597         PushPopIncludeState(StylesheetHandler&      theHandler);
00598 
00599         ~PushPopIncludeState();
00600 
00601     private:
00602 
00603         StylesheetHandler&                  m_handler;
00604 
00605         ElemTemplateStackType               m_elemStack;
00606 
00607         ElemTemplateSetType                 m_elemStackParentedElements;
00608 
00609         ElemTemplate* const                 m_pTemplate;
00610 
00611         ElemTemplateElement* const          m_lastPopped;       
00612 
00613         const bool                          m_inTemplate;       
00614 
00615         const bool                          m_foundStylesheet;
00616 
00617         const XalanDOMString                m_XSLNameSpaceURL;
00618 
00619         const bool                          m_foundNotImport;
00620 
00621         Stylesheet::NamespaceVectorType     m_namespaceDecls;
00622 
00623         Stylesheet::NamespacesStackType     m_namespaces;
00624 
00625         NamespacesHandler                   m_namespacesHandler;
00626 
00627         BoolStackType                       m_inExtensionElementStack;
00628 
00629         BoolStackType                       m_preserveSpaceStack;
00630     };
00631 
00632     friend class PushPopIncludeState;
00633 };
00634 
00635 
00636 
00637 #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++ XSL Transformer Version 1.1
Copyright © 2000, 2001 The Apache Software Foundation. All Rights Reserved.