Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.7

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-2004 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 <xalanc/XSLT/XSLTDefinitions.hpp>
00064 
00065 
00066 
00067 #include <xalanc/XalanDOM/XalanDOMString.hpp>
00068 #include <xalanc/XalanDOM/XalanNode.hpp>
00069 
00070 
00071 
00072 #include <xalanc/PlatformSupport/DOMStringHelper.hpp>
00073 #include <xalanc/PlatformSupport/PrefixResolver.hpp>
00074 #include <xalanc/PlatformSupport/XalanLocator.hpp>
00075 
00076 
00077 
00078 #include <xalanc/XPath/XalanQNameByReference.hpp>
00079 
00080 
00081 
00082 #include <xalanc/XSLT/NamespacesHandler.hpp>
00083 
00084 
00085 
00086 XALAN_DECLARE_XERCES_CLASS(AttributeList)
00087 XALAN_DECLARE_XERCES_CLASS(Locator)
00088 
00089 
00090 
00091 XALAN_CPP_NAMESPACE_BEGIN
00092 
00093 
00094 
00095 typedef XERCES_CPP_NAMESPACE_QUALIFIER AttributeList    AttributeListType;
00096 typedef XERCES_CPP_NAMESPACE_QUALIFIER Locator          LocatorType;
00097 
00098 
00099 
00100 class ElemTemplate;
00101 class ElemTextLiteral;
00102 class NamespacesHandler;
00103 class Stylesheet;
00104 class StylesheetConstructionContext;
00105 class StylesheetExecutionContext;
00106 class XPath;
00107 
00108 
00109 class XALAN_XSLT_EXPORT ElemTemplateElement : public PrefixResolver
00110 {
00111 public:
00112 
00123     ElemTemplateElement(
00124             StylesheetConstructionContext&  constructionContext,
00125             Stylesheet&                     stylesheetTree,
00126             int                             lineNumber,
00127             int                             columnNumber,
00128             int                             xslToken);
00129 
00142     ElemTemplateElement(
00143             StylesheetConstructionContext&  constructionContext,
00144             Stylesheet&                     stylesheetTree,
00145             int                             xslToken,
00146             const XalanDOMString&           baseURI = XalanDOMString(),
00147             int                             lineNumber = XalanLocator::getUnknownValue(),
00148             int                             columnNumber = XalanLocator::getUnknownValue());
00149 
00150     virtual
00151     ~ElemTemplateElement();
00152 
00158     virtual const LocatorType*
00159     getLocator() const;
00160 
00171     virtual bool
00172     isAttrOK(
00173             const XalanDOMChar*             attrName,
00174             const AttributeListType&        atts,
00175             int                             which,
00176             StylesheetConstructionContext&  constructionContext) const;
00177 
00187     bool
00188     processSpaceAttr(
00189             const XalanDOMChar*             aname,
00190             const AttributeListType&        atts,
00191             int                             which,
00192             StylesheetConstructionContext&  constructionContext);
00193 
00201     static bool
00202     isValidNCName(const XalanDOMString&     s);
00203 
00210     virtual void
00211     execute(StylesheetExecutionContext&     executionContext) const;
00212 
00218     virtual void
00219     executeChildren(StylesheetExecutionContext&     executionContext) const;
00220 
00227     virtual void
00228     executeChildren(
00229             StylesheetExecutionContext&     executionContext,
00230             XalanNode*                      sourceNode) const;
00231 
00243     const XalanDOMString&
00244     childrenToString(
00245             StylesheetExecutionContext&     executionContext,
00246             XalanDOMString&                 result) const;
00247 
00256     void
00257     childrenToResultAttribute(
00258             StylesheetExecutionContext&     executionContext,
00259             const XalanDOMString&           theName) const;
00260 
00268     void
00269     childrenToResultComment(StylesheetExecutionContext& executionContext) const;
00270 
00280     void
00281     childrenToResultPI(
00282             StylesheetExecutionContext&     executionContext,
00283             const XalanDOMString&           theTarget) const;
00284 
00292     int
00293     getXSLToken() const
00294     {
00295         return m_xslToken;
00296     }
00297 
00303     int
00304     getLineNumber() const
00305     {
00306         return m_lineNumber;
00307     }
00308 
00314     int
00315     getColumnNumber() const
00316     {
00317         return m_columnNumber;
00318     }
00319 
00325     virtual bool
00326     isWhitespace() const;
00327 
00334     virtual const XalanDOMString&
00335     getElementName() const = 0;
00336 
00343     virtual const XalanQName&
00344     getNameAttribute() const;
00345 
00354     virtual void
00355     addToStylesheet(
00356             StylesheetConstructionContext&  constructionContext,
00357             Stylesheet&                     theStylesheet);
00358 
00370     virtual void
00371     processSortElement(
00372             StylesheetConstructionContext&  constructionContext,
00373             Stylesheet&                     theStylesheet,
00374             const AttributeListType&        atts,
00375             const LocatorType*              locator = 0);
00376 
00382     virtual void
00383     setDefaultTemplate(bool     value);
00384 
00390     const NamespacesHandler&
00391     getNamespacesHandler() const
00392     {
00393         return m_namespacesHandler;
00394     }
00395 
00401     const Stylesheet&
00402     getStylesheet() const
00403     {
00404         return m_stylesheet;
00405     }
00406 
00412     void
00413     setFinishedConstruction(bool    fValue)
00414     {
00415         setFlag(eFinishedConstruction, fValue);
00416     }
00417 
00421     bool
00422     getFinishedConstruction() const
00423     {
00424         return getFlag(eFinishedConstruction);
00425     }
00426 
00430     virtual void
00431     postConstruction(
00432             StylesheetConstructionContext&  constructionContext,
00433             const NamespacesHandler&        theParentHandler);
00434 
00435     // Type-safe getters/setters...
00436 
00442     virtual ElemTemplateElement*
00443     getFirstChildElem() const;
00444 
00452     virtual void
00453     setFirstChildElem(ElemTemplateElement*  theChild);
00454 
00460     virtual ElemTemplateElement*
00461     getLastChildElem() const;
00462 
00468     virtual ElemTemplateElement*
00469     getNextSiblingElem() const;
00470 
00478     virtual void
00479     setNextSiblingElem(ElemTemplateElement*     theSibling);
00480 
00486     virtual ElemTemplateElement*
00487     getPreviousSiblingElem() const;
00488 
00496     virtual void
00497     setPreviousSiblingElem(ElemTemplateElement*     theSibling);
00498 
00504     virtual ElemTemplateElement*
00505     getParentNodeElem() const;
00506 
00514     virtual void
00515     setParentNodeElem(ElemTemplateElement*      theParent);
00516 
00524     virtual ElemTemplateElement*
00525     appendChildElem(ElemTemplateElement*    newChild);
00526 
00536     virtual const XPath*
00537     getXPath(unsigned int   index = 0) const;
00538 
00539     // These interfaces are inherited from PrefixResolver...
00540 
00541     virtual const XalanDOMString*
00542     getNamespaceForPrefix(const XalanDOMString& prefix) const;
00543 
00544     virtual const XalanDOMString&
00545     getURI() const;
00546 
00547     class LocatorProxy : public XalanLocator
00548     {
00549     public:
00550 
00551         LocatorProxy(const ElemTemplateElement&     theElement);
00552 
00553         virtual
00554         ~LocatorProxy();
00555 
00556         virtual const XMLCh*
00557         getPublicId() const;
00558 
00559         virtual const XMLCh*
00560         getSystemId() const;
00561 
00562         virtual size_type
00563         getLineNumber() const;
00564 
00565         virtual size_type
00566         getColumnNumber() const;
00567 
00568     private:
00569 
00570         // Not implemented...
00571         LocatorProxy(const LocatorProxy&);
00572 
00573         LocatorProxy&
00574         operator=(const LocatorProxy&);
00575 
00576         bool
00577         operator==(const LocatorProxy&) const;
00578 
00579         // data members...
00580         const ElemTemplateElement&  m_element;
00581     };
00582 
00583     bool
00584     hasParams() const
00585     {
00586         return getFlag(eHasParams);
00587     }
00588 
00589     bool
00590     hasVariables() const
00591     {
00592         return getFlag(eHasVariables);
00593     }
00594 
00595     bool
00596     hasSingleTextChild() const
00597     {
00598         return getFlag(eHasSingleTextChild);
00599     }
00600 
00601     bool
00602     hasChildren() const
00603     {
00604         return m_firstChild != 0 ? true : false;
00605     }
00606 
00607     bool
00608     hasDirectTemplate() const
00609     {
00610         return getFlag(eHasDirectTemplate);
00611     }
00612 
00613     bool
00614     canGenerateAttributes() const
00615     {
00616         return getFlag(eCanGenerateAttributes);
00617     }
00618 
00619     bool
00620     isDefaultTemplate() const
00621     {
00622         return getFlag(eDefaultTemplate);
00623     }
00624 
00625 protected:
00626 
00627     void
00628     canGenerateAttributes(bool  value)
00629     {
00630         setFlag(eCanGenerateAttributes, value);
00631     }
00632 
00633     void
00634     hasPrefix(bool  value)
00635     {
00636         setFlag(eHasPrefix, value);
00637     }
00638 
00639     bool
00640     hasPrefix() const
00641     {
00642         return getFlag(eHasPrefix);
00643     }
00644 
00645     void
00646     preserveSpace(bool  value)
00647     {
00648         setFlag(eSpacePreserve, value);
00649     }
00650 
00651     bool
00652     preserveSpace() const
00653     {
00654         return getFlag(eSpacePreserve);
00655     }
00656 
00657     void
00658     disableOutputEscaping(bool  value)
00659     {
00660         setFlag(eDisableOutputEscaping, value);
00661     }
00662 
00663     bool
00664     disableOutputEscaping() const
00665     {
00666         return getFlag(eDisableOutputEscaping);
00667     }
00668 
00678     bool
00679     processPrefixControl(
00680             StylesheetConstructionContext&  constructionContext,
00681             const Stylesheet&               stylesheetTree,
00682             const XalanDOMString&           localName,
00683             const XalanDOMChar*             attrValue);
00684 
00692     const XalanDOMString*
00693     getNamespaceForPrefixInternal(const XalanDOMString&     prefix) const;
00694 
00704     virtual void
00705     transformChild(
00706             StylesheetExecutionContext&     executionContext,
00707             const ElemTemplateElement&      xslInstruction,
00708             const ElemTemplateElement*      theTemplate,
00709             XalanNode*                      child) const;
00710 
00721     virtual void
00722     transformChild(
00723             StylesheetExecutionContext&     executionContext,
00724             const ElemTemplateElement&      xslInstruction,
00725             const ElemTemplateElement*      theTemplate,
00726             XalanNode*                      child,
00727             XalanNode::NodeType             nodeType) const;
00728 
00741     virtual bool
00742     childTypeAllowed(int    xslToken) const;
00743 
00750     virtual void
00751     namespacesPostConstruction(
00752             StylesheetConstructionContext&  constructionContext,
00753             const NamespacesHandler&        theParentHandler,
00754             NamespacesHandler&              theHandler);
00755 
00756     static const XalanDOMString     s_emptyString;
00757 
00758     const NamespacesHandler&
00759     getNamespaces() const
00760     {
00761         return m_namespacesHandler;
00762     }
00763 
00764 private:
00765 
00766     enum eFlags
00767     { 
00768         eHasParams = 1,
00769         eHasSingleTextChild = 2,
00770         eHasVariables = 4,
00771         eHasDirectTemplate = 8,
00772         eCanGenerateAttributes = 16,
00773         eDefaultTemplate = 32,
00774         eSpacePreserve = 64,
00775         eFinishedConstruction = 128,
00776         eHasPrefix = 256,
00777         eDisableOutputEscaping = 512
00778     };
00779 
00780     bool
00781     getFlag(eFlags  theFlag) const
00782     {
00783         return m_flags & theFlag ? true : false;
00784     }
00785 
00786     void
00787     setFlag(
00788             eFlags  theFlag,
00789             bool    theValue)
00790     {
00791         if (theValue == true)
00792         {
00793             m_flags |= theFlag;
00794         }
00795         else
00796         {
00797             m_flags &= ~theFlag;
00798         }
00799     }
00800 
00809     XalanDOMString&
00810     doChildrenToString(
00811             StylesheetExecutionContext&     executionContext, 
00812             XalanDOMString&                 result) const;
00813 
00814     Stylesheet&             m_stylesheet;
00815 
00816     /*
00817      * This object handles all result tree namespace processing.
00818      */
00819     NamespacesHandler       m_namespacesHandler;
00820 
00821     const int               m_lineNumber;
00822     const int               m_columnNumber;
00823 
00824     const int               m_xslToken;
00825 
00826     ElemTemplateElement*    m_parentNode;
00827     ElemTemplateElement*    m_nextSibling;
00828     ElemTemplateElement*    m_previousSibling;
00829 
00830     union
00831     {
00832         ElemTemplateElement*    m_firstChild;
00833         const ElemTemplate*     m_directTemplate;
00834         const ElemTextLiteral*  m_textLiteralChild;
00835     };
00836 
00837     const XalanDOMString&   m_baseIndentifier;
00838 
00839     LocatorProxy            m_locatorProxy;
00840 
00841     unsigned short          m_flags;
00842 
00843     static const XalanQNameByReference      s_emptyQName;
00844 
00845     // Not implemented...
00846     ElemTemplateElement(const ElemTemplateElement&);
00847 
00848     ElemTemplateElement&
00849     operator=(const ElemTemplateElement&);
00850 
00851     bool
00852     operator==(const ElemTemplateElement&) const;
00853 };
00854 
00855 
00856 
00857 XALAN_CPP_NAMESPACE_END
00858 
00859 
00860 
00861 #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.7
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.