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  

ElemTemplateElement.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 #if !defined(XALAN_ELEMTEMPLATEELEMENT_HEADER_GUARD)
00058 #define XALAN_ELEMTEMPLATEELEMENT_HEADER_GUARD 
00059 
00060 
00061 
00062 // Base include file.  Must be first.
00063 #include <XSLT/XSLTDefinitions.hpp>
00064 
00065 
00066 
00067 #include <vector>
00068 #include <map>
00069 
00070 
00071 
00072 #include <sax/Locator.hpp>
00073 
00074 
00075 
00076 #include <XalanDOM/XalanDOMString.hpp>
00077 #include <XalanDOM/XalanElement.hpp>
00078 #include <XalanDOM/XalanEmptyNamedNodeMap.hpp>
00079 #include <XalanDOM/XalanNodeListSurrogate.hpp>
00080 
00081 
00082 
00083 #include <PlatformSupport/DOMStringHelper.hpp>
00084 #include <PlatformSupport/PrefixResolver.hpp>
00085 
00086 
00087 
00088 #include <XPath/NodeRefListBase.hpp>
00089 
00090 
00091 
00092 #include <XSLT/NamespacesHandler.hpp>
00093 
00094 
00095 
00096 class AttributeList;
00097 class ElemTemplate;
00098 class NamespacesHandler;
00099 class NodeSorter;
00100 class Stylesheet;
00101 class StylesheetConstructionContext;
00102 class StylesheetExecutionContext;
00103 class XPath;
00104 
00105 
00106 
00107 class XALAN_XSLT_EXPORT ElemTemplateElement : public XalanElement, public PrefixResolver
00108 {
00109 public:
00110 
00121     ElemTemplateElement(
00122             StylesheetConstructionContext&  constructionContext,
00123             Stylesheet&                     stylesheetTree,
00124             int                             lineNumber,
00125             int                             columnNumber,
00126             int                             xslToken);
00127 
00128     virtual
00129     ~ElemTemplateElement();
00130 
00136     virtual const Locator*
00137     getLocator() const;
00138 
00148     virtual bool
00149     isAttrOK(
00150             int                     tok,
00151             const XalanDOMChar*     attrName,
00152             const AttributeList&    atts,
00153             int                     which) const;
00154 
00165     virtual bool
00166     isAttrOK(
00167             const XalanDOMChar*             attrName,
00168             const AttributeList&            atts,
00169             int                             which,
00170             StylesheetConstructionContext&  constructionContext) const;
00171 
00180     void
00181     processSpaceAttr(
00182             const AttributeList&            atts,
00183             int                             which,
00184             StylesheetConstructionContext&  constructionContext);
00185 
00195     bool
00196     processSpaceAttr(
00197             const XalanDOMChar*             aname,
00198             const AttributeList&            atts,
00199             int                             which,
00200             StylesheetConstructionContext&  constructionContext);
00201 
00209     static bool
00210     isValidNCName(const XalanDOMString&     s);
00211 
00218     virtual void
00219     execute(StylesheetExecutionContext&     executionContext) const;
00220 
00226     void
00227     executeChildren(StylesheetExecutionContext&     executionContext) const;
00228 
00235     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     int
00301     getXSLToken() const
00302     {
00303         return m_xslToken;
00304     }
00305 
00312     int
00313     getLineNumber() const
00314     {
00315         return m_lineNumber;
00316     }
00317 
00324     int
00325     getColumnNumber() const
00326     {
00327         return m_columnNumber;
00328     }
00329 
00335     virtual bool
00336     isWhitespace() const;
00337 
00338     virtual const XalanDOMString&
00339     getElementName() const = 0;
00340 
00341 #if defined(XALAN_NO_NAMESPACES)
00342     typedef map<XalanDOMString,
00343                 XalanDOMString,
00344                 less<XalanDOMString> >  StringToStringMapType;
00345 #else
00346     typedef std::map<XalanDOMString,
00347                      XalanDOMString>    StringToStringMapType;
00348 #endif
00349 
00355     const NamespacesHandler&
00356     getNamespacesHandler() const
00357     {
00358         return m_namespacesHandler;
00359     }
00360 
00366     const Stylesheet&
00367     getStylesheet() const
00368     {
00369         return m_stylesheet;
00370     }
00371 
00375     void
00376     finishedConstruction()
00377     {
00378         m_finishedConstruction = true;
00379     }
00380 
00384     virtual void
00385     postConstruction(
00386             StylesheetConstructionContext&  constructionContext,
00387             const NamespacesHandler&        theParentHandler);
00388 
00389     // Type-safe getters/setters...
00390 
00396     virtual ElemTemplateElement*
00397     getFirstChildElem() const;
00398 
00406     virtual void
00407     setFirstChildElem(ElemTemplateElement*  theChild);
00408 
00414     virtual ElemTemplateElement*
00415     getLastChildElem() const;
00416 
00422     virtual ElemTemplateElement*
00423     getNextSiblingElem() const;
00424 
00432     virtual void
00433     setNextSiblingElem(ElemTemplateElement*     theSibling);
00434 
00440     virtual ElemTemplateElement*
00441     getPreviousSiblingElem() const;
00442 
00450     virtual void
00451     setPreviousSiblingElem(ElemTemplateElement*     theSibling);
00452 
00458     virtual ElemTemplateElement*
00459     getParentNodeElem() const;
00460 
00468     virtual void
00469     setParentNodeElem(ElemTemplateElement*      theParent);
00470 
00478     virtual ElemTemplateElement*
00479     appendChildElem(ElemTemplateElement*    newChild);
00480 
00481     // Type-safe getters...
00482 
00491     virtual ElemTemplateElement*
00492     insertBeforeElem(
00493             ElemTemplateElement*    newChild,
00494             ElemTemplateElement*    refChild);
00495 
00504     virtual ElemTemplateElement*
00505     replaceChildElem(
00506             ElemTemplateElement*    newChild,
00507             ElemTemplateElement*    oldChild);
00508 
00509     // These interfaces are inherited from XalanElement ...
00510 
00511     virtual const XalanDOMString&
00512     getNodeName() const;
00513 
00514     virtual const XalanDOMString&
00515     getNodeValue() const;
00516 
00517     virtual NodeType
00518     getNodeType() const;
00519 
00520     virtual XalanNode*
00521     getParentNode() const;
00522 
00523     virtual const XalanNodeList*
00524     getChildNodes() const;
00525 
00526     virtual XalanNode*
00527     getFirstChild() const;
00528 
00529     virtual XalanNode*
00530     getLastChild() const;
00531 
00532     virtual XalanNode*
00533     getPreviousSibling() const;
00534 
00535     virtual XalanNode*
00536     getNextSibling() const;
00537 
00538     virtual const XalanNamedNodeMap*
00539     getAttributes() const;
00540 
00541     virtual XalanDocument*
00542     getOwnerDocument() const;
00543 
00544 #if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
00545     virtual XalanNode*
00546 #else
00547     virtual ElemTemplateElement*
00548 #endif
00549     cloneNode(bool  deep) const;
00550 
00551     virtual XalanNode*
00552     insertBefore(
00553             XalanNode*  newChild,
00554             XalanNode*  refChild);
00555 
00556     virtual XalanNode*
00557     replaceChild(
00558             XalanNode*  newChild,
00559             XalanNode*  oldChild);
00560 
00561     virtual XalanNode*
00562     removeChild(XalanNode*  oldChild);
00563 
00570     virtual XalanNode*
00571     appendChild(XalanNode*  newChild);
00572 
00573     virtual bool
00574     hasChildNodes() const;
00575 
00576     virtual void
00577     setNodeValue(const XalanDOMString&  nodeValue);
00578 
00579     virtual void
00580     normalize();
00581 
00582     virtual bool
00583     supports(
00584             const XalanDOMString&   feature,
00585             const XalanDOMString&   version) const;
00586 
00587     virtual const XalanDOMString&
00588     getNamespaceURI() const;
00589 
00590     virtual const XalanDOMString&
00591     getPrefix() const;
00592 
00593     virtual const XalanDOMString&
00594     getLocalName() const;
00595 
00596     virtual void
00597     setPrefix(const XalanDOMString& prefix);
00598 
00599     virtual bool
00600     isIndexed() const;
00601 
00602     virtual unsigned long
00603     getIndex() const;
00604 
00605     virtual const XalanDOMString&
00606     getTagName() const;
00607 
00608     virtual const XalanDOMString&
00609     getAttribute(const XalanDOMString&  name) const;
00610 
00611     virtual XalanAttr*
00612     getAttributeNode(const XalanDOMString&  name) const;
00613 
00614     virtual XalanNodeList*
00615     getElementsByTagName(const XalanDOMString&  name) const;
00616 
00617     virtual void
00618     setAttribute(
00619             const XalanDOMString&   name, 
00620             const XalanDOMString&   value);
00621 
00622     virtual XalanAttr*
00623     setAttributeNode(XalanAttr*     newAttr);
00624 
00625     virtual XalanAttr*
00626     removeAttributeNode(XalanAttr*  oldAttr);
00627 
00628     virtual void
00629     removeAttribute(const XalanDOMString&   name);
00630 
00631     virtual const XalanDOMString&
00632     getAttributeNS(
00633             const XalanDOMString&   namespaceURI,
00634             const XalanDOMString&   localName) const;
00635 
00636     virtual void
00637     setAttributeNS(
00638             const XalanDOMString&   namespaceURI,
00639             const XalanDOMString&   qualifiedName,
00640             const XalanDOMString&   value);
00641 
00642     virtual void
00643     removeAttributeNS(
00644             const XalanDOMString&   namespaceURI,
00645             const XalanDOMString&   localName);
00646 
00647     virtual XalanAttr*
00648     getAttributeNodeNS(
00649             const XalanDOMString&   namespaceURI,
00650             const XalanDOMString&   localName) const;
00651 
00652     virtual XalanAttr*
00653     setAttributeNodeNS(XalanAttr*   newAttr);
00654 
00655     virtual XalanNodeList*
00656     getElementsByTagNameNS(
00657             const XalanDOMString&   namespaceURI,
00658             const XalanDOMString&   localName) const;
00659 
00660 
00661     // These interfaces are inherited from PrefixResolver...
00662 
00663     virtual const XalanDOMString*
00664     getNamespaceForPrefix(const XalanDOMString& prefix) const;
00665 
00666     virtual const XalanDOMString&
00667     getURI() const;
00668 
00669 
00670     // These optimization interfaces are new to ElemTemplateElement...
00671     bool
00672     hasParams() const
00673     {
00674         return m_optimizationFlags & eHasParams ? true : false;
00675     }
00676 
00677     bool
00678     hasVariables() const
00679     {
00680         return m_optimizationFlags & eHasVariables ? true : false;
00681     }
00682 
00683     bool
00684     hasSingleTextChild() const
00685     {
00686         return m_optimizationFlags & eHasSingleTextChild ? true : false;
00687     }
00688 
00689     bool
00690     hasChildren() const
00691     {
00692         return m_firstChild != 0 ? true : false;
00693     }
00694 
00695     bool
00696     hasDirectTemplate() const
00697     {
00698         return m_optimizationFlags & eHasDirectTemplate ? true : false;
00699     }
00700 
00705     bool
00706     canGenerateAttributes() const
00707     {
00708         return m_optimizationFlags & eCanGenerateAttributes ? true : false;
00709     }
00710 
00711 protected:
00712 
00713     void
00714     canGenerateAttributes(bool  value)
00715     {
00716         if (value == true)
00717         {
00718             m_optimizationFlags |= eCanGenerateAttributes;
00719         }
00720         else
00721         {
00722             m_optimizationFlags &= ~eCanGenerateAttributes;
00723         }
00724     }
00725 
00733     const XalanDOMString*
00734     getNamespaceForPrefixInternal(const XalanDOMString&     prefix) const;
00735 
00748     void
00749     transformSelectedChildren(
00750             StylesheetExecutionContext&     executionContext,
00751             const ElemTemplateElement&      xslInstruction,
00752             const ElemTemplateElement*      theTemplate,
00753             XalanNode*                      sourceNodeContext,
00754             const XPath&                    selectPattern,
00755             NodeSorter*                     sorter,
00756             int                             selectStackFrameIndex) const;
00757 
00767     void
00768     transformSelectedChildren(
00769             StylesheetExecutionContext&         executionContext,
00770             const ElemTemplateElement&          xslInstruction,
00771             const ElemTemplateElement*          theTemplate,
00772             const NodeRefListBase&              sourceNodes,
00773             NodeRefListBase::size_type          sourceNodesCount) const;
00774 
00786     bool
00787     transformChild(
00788             StylesheetExecutionContext&     executionContext,
00789             const ElemTemplateElement&      xslInstruction,
00790             const ElemTemplateElement*      theTemplate,
00791             XalanNode*                      child) const;
00792 
00805     virtual bool
00806     childTypeAllowed(int    xslToken) const;
00807 
00808     bool                    m_finishedConstruction;
00809 
00810     /*
00811      * This object handles all result tree namespace processing.
00812      */
00813     NamespacesHandler       m_namespacesHandler;
00814 
00815     static const XalanDOMString     s_emptyString;
00816 
00817 private:
00818 
00819     class LocatorProxy : public Locator
00820     {
00821     public:
00822 
00823         LocatorProxy(const ElemTemplateElement&     theElement);
00824 
00825         virtual
00826         ~LocatorProxy();
00827 
00828         virtual const XMLCh*
00829         getPublicId() const;
00830 
00831         virtual const XMLCh*
00832         getSystemId() const;
00833 
00834         virtual int
00835         getLineNumber() const;
00836 
00837         virtual int
00838         getColumnNumber() const;
00839 
00840     private:
00841 
00842         const ElemTemplateElement&  m_element;
00843     };
00844 
00853     XalanDOMString&
00854     doChildrenToString(
00855             StylesheetExecutionContext&     executionContext, 
00856             XalanDOMString&                 result) const;
00857 
00858     Stylesheet&             m_stylesheet;
00859 
00860     const int               m_lineNumber;
00861     const int               m_columnNumber;
00862 
00863     bool                    m_defaultSpace;
00864 
00865     const int               m_xslToken;
00866 
00867     ElemTemplateElement*    m_parentNode;
00868     ElemTemplateElement*    m_nextSibling;
00869     ElemTemplateElement*    m_previousSibling;
00870 
00871     union
00872     {
00873         ElemTemplateElement*    m_firstChild;
00874         const ElemTemplate*     m_directTemplate;
00875     };
00876 
00877     XalanNodeListSurrogate  m_surrogateChildren;
00878 
00879     const XalanDOMString    m_baseIndentifier;
00880 
00881     enum { eHasParams = 1,
00882            eHasSingleTextChild = 2,
00883            eHasVariables = 4,
00884            eHasDirectTemplate = 8,
00885            eCanGenerateAttributes = 16 };
00886 
00887     unsigned                m_optimizationFlags;
00888 
00889     LocatorProxy            m_locatorProxy;
00890 
00891     static const XalanEmptyNamedNodeMap     s_fakeAttributes;
00892 };
00893 
00894 
00895 
00896 #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.3
Copyright © 2000, 2001 The Apache Software Foundation. All Rights Reserved.