Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.9

Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

ElemTemplateElement.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 #if !defined(XALAN_ELEMTEMPLATEELEMENT_HEADER_GUARD)
00017 #define XALAN_ELEMTEMPLATEELEMENT_HEADER_GUARD 
00018 
00019 
00020 
00021 // Base include file.  Must be first.
00022 #include <xalanc/XSLT/XSLTDefinitions.hpp>
00023 
00024 
00025 
00026 #include <xalanc/XalanDOM/XalanDOMString.hpp>
00027 #include <xalanc/XalanDOM/XalanNode.hpp>
00028 
00029 
00030 
00031 #include <xalanc/PlatformSupport/DOMStringHelper.hpp>
00032 #include <xalanc/PlatformSupport/PrefixResolver.hpp>
00033 #include <xalanc/PlatformSupport/XalanLocator.hpp>
00034 
00035 
00036 
00037 #include <xalanc/XPath/XalanQNameByReference.hpp>
00038 
00039 
00040 
00041 #include <xalanc/XSLT/NamespacesHandler.hpp>
00042 
00043 
00044 
00045 XALAN_DECLARE_XERCES_CLASS(AttributeList)
00046 XALAN_DECLARE_XERCES_CLASS(Locator)
00047 
00048 
00049 
00050 XALAN_CPP_NAMESPACE_BEGIN
00051 
00052 
00053 
00054 typedef XERCES_CPP_NAMESPACE_QUALIFIER AttributeList    AttributeListType;
00055 typedef XERCES_CPP_NAMESPACE_QUALIFIER Locator          LocatorType;
00056 
00057 
00058 
00059 class ElemTemplate;
00060 class ElemTextLiteral;
00061 class NamespacesHandler;
00062 class Stylesheet;
00063 class StylesheetConstructionContext;
00064 class StylesheetExecutionContext;
00065 class XPath;
00066 
00067 
00068 
00069 class XALAN_XSLT_EXPORT ElemTemplateElement : public PrefixResolver
00070 {
00071      
00072 public:
00073 
00084     ElemTemplateElement(
00085             StylesheetConstructionContext&  constructionContext,
00086             Stylesheet&                     stylesheetTree,
00087             int                             lineNumber,
00088             int                             columnNumber,
00089             int                             xslToken);
00090 
00103     ElemTemplateElement(
00104             StylesheetConstructionContext&  constructionContext,
00105             Stylesheet&                     stylesheetTree,
00106             int                             xslToken,
00107             const XalanDOMString&           baseURI = XalanDOMString(XalanMemMgrs::getDummyMemMgr()),
00108             int                             lineNumber = XalanLocator::getUnknownValue(),
00109             int                             columnNumber = XalanLocator::getUnknownValue());
00110 
00111     virtual
00112     ~ElemTemplateElement();
00113 
00119     virtual const LocatorType*
00120     getLocator() const;
00121 
00132     virtual bool
00133     isAttrOK(
00134             const XalanDOMChar*             attrName,
00135             const AttributeListType&        atts,
00136             int                             which,
00137             StylesheetConstructionContext&  constructionContext) const;
00138 
00148     bool
00149     processSpaceAttr(
00150             const XalanDOMChar*             aname,
00151             const AttributeListType&        atts,
00152             int                             which,
00153             StylesheetConstructionContext&  constructionContext);
00154 
00162     static bool
00163     isValidNCName(const XalanDOMString&     s);
00164 
00165 #if !defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION)
00166 
00174     virtual const ElemTemplateElement*
00175     startElement(StylesheetExecutionContext&    executionContext) const;
00176 
00184     virtual void
00185     endElement(StylesheetExecutionContext&      executionContext) const;
00186 
00192     virtual void
00193     execute(StylesheetExecutionContext&     executionContext) const;
00194 
00200     virtual void
00201     executeChildren(StylesheetExecutionContext&     executionContext) const;
00202 
00207     virtual const ElemTemplateElement*
00208     getInvoker(StylesheetExecutionContext&  executionContext) const;
00209 
00210 #else
00211 
00218     virtual void
00219     execute(StylesheetExecutionContext&     executionContext) const;
00220 
00226     virtual void
00227     executeChildren(StylesheetExecutionContext&     executionContext) const;
00228 
00235     virtual void
00236     executeChildren(
00237             StylesheetExecutionContext&     executionContext,
00238             XalanNode*                      sourceNode) const;
00239 
00251     const XalanDOMString&
00252     childrenToString(
00253             StylesheetExecutionContext&     executionContext,
00254             XalanDOMString&                 result) const;
00255 
00264     void
00265     childrenToResultAttribute(
00266             StylesheetExecutionContext&     executionContext,
00267             const XalanDOMString&           theName) const;
00268 
00276     void
00277     childrenToResultComment(StylesheetExecutionContext& executionContext) const;
00278 
00288     void
00289     childrenToResultPI(
00290             StylesheetExecutionContext&     executionContext,
00291             const XalanDOMString&           theTarget) const;
00292 
00300 #endif
00301     
00302     int
00303     getXSLToken() const
00304     {
00305         return m_xslToken;
00306     }
00307 
00313     int
00314     getLineNumber() const
00315     {
00316         return m_lineNumber;
00317     }
00318 
00324     int
00325     getColumnNumber() const
00326     {
00327         return m_columnNumber;
00328     }
00329 
00335     virtual bool
00336     isWhitespace() const;
00337 
00344     virtual const XalanDOMString&
00345     getElementName() const = 0;
00346 
00353     virtual const XalanQName&
00354     getNameAttribute() const;
00355 
00364     virtual void
00365     addToStylesheet(
00366             StylesheetConstructionContext&  constructionContext,
00367             Stylesheet&                     theStylesheet);
00368 
00380     virtual void
00381     processSortElement(
00382             StylesheetConstructionContext&  constructionContext,
00383             Stylesheet&                     theStylesheet,
00384             const AttributeListType&        atts,
00385             const LocatorType*              locator = 0);
00386 
00392     virtual void
00393     setDefaultTemplate(bool     value);
00394 
00400     const NamespacesHandler&
00401     getNamespacesHandler() const
00402     {
00403         return m_namespacesHandler;
00404     }
00405 
00411     const Stylesheet&
00412     getStylesheet() const
00413     {
00414         return m_stylesheet;
00415     }
00416 
00422     void
00423     setFinishedConstruction(bool    fValue)
00424     {
00425         setFlag(eFinishedConstruction, fValue);
00426     }
00427 
00431     bool
00432     getFinishedConstruction() const
00433     {
00434         return getFlag(eFinishedConstruction);
00435     }
00436 
00440     virtual void
00441     postConstruction(
00442             StylesheetConstructionContext&  constructionContext,
00443             const NamespacesHandler&        theParentHandler);
00444 
00445     // Type-safe getters/setters...
00446 
00452     virtual ElemTemplateElement*
00453     getFirstChildElem() const;
00454 
00455 #if !defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION)
00456 
00462     virtual const ElemTemplateElement*
00463     beginExecuteChildren(
00464             StylesheetExecutionContext& executionContext) const;
00465 
00466 
00473     virtual void
00474     endExecuteChildren(
00475             StylesheetExecutionContext& executionContext) const;
00476 
00485     const ElemTemplateElement*
00486     beginChildrenToString(
00487             StylesheetExecutionContext&     executionContext,
00488             XalanDOMString&                 result) const;
00489 
00490     
00497     void
00498     endChildrenToString(
00499             StylesheetExecutionContext&     executionContext) const;
00500 #endif
00501 
00502 
00510     virtual void
00511     setFirstChildElem(ElemTemplateElement*  theChild);
00512 
00518     virtual ElemTemplateElement*
00519     getLastChildElem() const;
00520 
00526     virtual ElemTemplateElement*
00527     getNextSiblingElem() const;
00528 
00529 #if !defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION)
00530 
00539     virtual const ElemTemplateElement*
00540     getNextChildElemToExecute(
00541             StylesheetExecutionContext& executionContext,
00542             const ElemTemplateElement*  currentElem) const;
00543 
00551     virtual const ElemTemplateElement*
00552     getFirstChildElemToExecute(
00553             StylesheetExecutionContext& executionContext) const;
00554 
00562     virtual bool executeChildElement(
00563             StylesheetExecutionContext& executionContext,
00564             const ElemTemplateElement* element) const;
00565 #endif
00566 
00574     virtual void
00575     setNextSiblingElem(ElemTemplateElement*     theSibling);
00576 
00582     virtual ElemTemplateElement*
00583     getPreviousSiblingElem() const;
00584 
00592     virtual void
00593     setPreviousSiblingElem(ElemTemplateElement*     theSibling);
00594 
00600     virtual ElemTemplateElement*
00601     getParentNodeElem() const;
00602 
00610     virtual void
00611     setParentNodeElem(ElemTemplateElement*      theParent);
00612 
00620     virtual ElemTemplateElement*
00621     appendChildElem(ElemTemplateElement*    newChild);
00622 
00632     virtual const XPath*
00633     getXPath(unsigned int   index = 0) const;
00634 
00635     // These interfaces are inherited from PrefixResolver...
00636 
00637     virtual const XalanDOMString*
00638     getNamespaceForPrefix(const XalanDOMString& prefix) const;
00639 
00640     virtual const XalanDOMString&
00641     getURI() const;
00642 
00643     class LocatorProxy : public XalanLocator
00644     {
00645     public:
00646 
00647         LocatorProxy(const ElemTemplateElement&     theElement);
00648 
00649         virtual
00650         ~LocatorProxy();
00651 
00652         virtual const XMLCh*
00653         getPublicId() const;
00654 
00655         virtual const XMLCh*
00656         getSystemId() const;
00657 
00658         virtual size_type
00659         getLineNumber() const;
00660 
00661         virtual size_type
00662         getColumnNumber() const;
00663 
00664     private:
00665 
00666         // Not implemented...
00667         LocatorProxy(const LocatorProxy&);
00668 
00669         LocatorProxy&
00670         operator=(const LocatorProxy&);
00671 
00672         bool
00673         operator==(const LocatorProxy&) const;
00674 
00675         // data members...
00676         const ElemTemplateElement&  m_element;
00677     };
00678 
00679     bool
00680     hasParams() const
00681     {
00682         return getFlag(eHasParams);
00683     }
00684 
00685     bool
00686     hasVariables() const
00687     {
00688         return getFlag(eHasVariables);
00689     }
00690 
00691     bool
00692     hasSingleTextChild() const
00693     {
00694         return getFlag(eHasSingleTextChild);
00695     }
00696 
00697     bool
00698     hasChildren() const
00699     {
00700         return m_firstChild != 0 ? true : false;
00701     }
00702 
00703     bool
00704     hasDirectTemplate() const
00705     {
00706         return getFlag(eHasDirectTemplate);
00707     }
00708 
00709     bool
00710     canGenerateAttributes() const
00711     {
00712         return getFlag(eCanGenerateAttributes);
00713     }
00714 
00715     bool
00716     isDefaultTemplate() const
00717     {
00718         return getFlag(eDefaultTemplate);
00719     }
00720 
00721 protected:
00722 
00723     void
00724     canGenerateAttributes(bool  value)
00725     {
00726         setFlag(eCanGenerateAttributes, value);
00727     }
00728 
00729     void
00730     hasPrefix(bool  value)
00731     {
00732         setFlag(eHasPrefix, value);
00733     }
00734 
00735     bool
00736     hasPrefix() const
00737     {
00738         return getFlag(eHasPrefix);
00739     }
00740 
00741     void
00742     preserveSpace(bool  value)
00743     {
00744         setFlag(eSpacePreserve, value);
00745     }
00746 
00747     bool
00748     preserveSpace() const
00749     {
00750         return getFlag(eSpacePreserve);
00751     }
00752 
00753     void
00754     disableOutputEscaping(bool  value)
00755     {
00756         setFlag(eDisableOutputEscaping, value);
00757     }
00758 
00759     bool
00760     disableOutputEscaping() const
00761     {
00762         return getFlag(eDisableOutputEscaping);
00763     }
00764 
00774     bool
00775     processPrefixControl(
00776             StylesheetConstructionContext&  constructionContext,
00777             const Stylesheet&               stylesheetTree,
00778             const XalanDOMString&           localName,
00779             const XalanDOMChar*             attrValue);
00780 
00788     const XalanDOMString*
00789     getNamespaceForPrefixInternal(const XalanDOMString&     prefix) const;
00790 
00791 #if !defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION)
00792 
00802     virtual const ElemTemplateElement*
00803     findTemplateToTransformChild(
00804             StylesheetExecutionContext&     executionContext,
00805             const ElemTemplateElement&      xslInstruction,
00806             const ElemTemplateElement*      theTemplate,
00807             XalanNode*                      child) const;
00808 
00820     virtual const ElemTemplateElement*
00821     findTemplateToTransformChild(
00822             StylesheetExecutionContext&     executionContext,
00823             const ElemTemplateElement&      xslInstruction,
00824             const ElemTemplateElement*      theTemplate,
00825             XalanNode*                      child,
00826             XalanNode::NodeType             nodeType) const;
00827 #else
00828 
00837     virtual void
00838     transformChild(
00839             StylesheetExecutionContext&     executionContext,
00840             const ElemTemplateElement&      xslInstruction,
00841             const ElemTemplateElement*      theTemplate,
00842             XalanNode*                      child) const;
00843 
00854     virtual void
00855     transformChild(
00856             StylesheetExecutionContext&     executionContext,
00857             const ElemTemplateElement&      xslInstruction,
00858             const ElemTemplateElement*      theTemplate,
00859             XalanNode*                      child,
00860             XalanNode::NodeType             nodeType) const;
00861 #endif
00862 
00863     
00876     virtual bool
00877     childTypeAllowed(int    xslToken) const;
00878 
00885     virtual void
00886     namespacesPostConstruction(
00887             StylesheetConstructionContext&  constructionContext,
00888             const NamespacesHandler&        theParentHandler,
00889             NamespacesHandler&              theHandler);
00890 
00891     static const XalanDOMString     s_emptyString;
00892 
00893     const NamespacesHandler&
00894     getNamespaces() const
00895     {
00896         return m_namespacesHandler;
00897     }
00898 
00899 private:
00900 
00901     enum eFlags
00902     { 
00903         eHasParams = 1,
00904         eHasSingleTextChild = 2,
00905         eHasVariables = 4,
00906         eHasDirectTemplate = 8,
00907         eCanGenerateAttributes = 16,
00908         eDefaultTemplate = 32,
00909         eSpacePreserve = 64,
00910         eFinishedConstruction = 128,
00911         eHasPrefix = 256,
00912         eDisableOutputEscaping = 512
00913     };
00914 
00915     bool
00916     getFlag(eFlags  theFlag) const
00917     {
00918         return m_flags & theFlag ? true : false;
00919     }
00920 
00921     void
00922     setFlag(
00923             eFlags  theFlag,
00924             bool    theValue)
00925     {
00926         if (theValue == true)
00927         {
00928             m_flags |= theFlag;
00929         }
00930         else
00931         {
00932             m_flags &= ~theFlag;
00933         }
00934     }
00935 
00936 
00937 #if defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION)
00938 
00946     XalanDOMString&
00947     doChildrenToString(
00948             StylesheetExecutionContext&     executionContext, 
00949             XalanDOMString&                 result) const;
00950 #endif
00951 
00952     Stylesheet&             m_stylesheet;
00953 
00954     /*
00955      * This object handles all result tree namespace processing.
00956      */
00957     NamespacesHandler       m_namespacesHandler;
00958 
00959     const int               m_lineNumber;
00960     const int               m_columnNumber;
00961 
00962     const int               m_xslToken;
00963 
00964     ElemTemplateElement*    m_parentNode;
00965     ElemTemplateElement*    m_nextSibling;
00966     ElemTemplateElement*    m_previousSibling;
00967 
00968     union
00969     {
00970         ElemTemplateElement*    m_firstChild;
00971         const ElemTemplate*     m_directTemplate;
00972         const ElemTextLiteral*  m_textLiteralChild;
00973     };
00974 
00975     const XalanDOMString&   m_baseIndentifier;
00976 
00977     LocatorProxy            m_locatorProxy;
00978 
00979     unsigned short          m_flags;
00980 
00981     static const XalanQNameByReference      s_emptyQName;
00982 
00983     // Not implemented...
00984     ElemTemplateElement(const ElemTemplateElement&);
00985 
00986     ElemTemplateElement&
00987     operator=(const ElemTemplateElement&);
00988 
00989     bool
00990     operator==(const ElemTemplateElement&) const;
00991 };
00992 
00993 
00994 
00995 XALAN_CPP_NAMESPACE_END
00996 
00997 
00998 
00999 #endif  // XALAN_ELEMTEMPLATEELEMENT_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.9
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.