Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.5

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-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 #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 <XalanDOM/XalanDOMString.hpp>
00068 #include <XalanDOM/XalanElement.hpp>
00069 #include <XalanDOM/XalanEmptyNamedNodeMap.hpp>
00070 
00071 
00072 
00073 #include <PlatformSupport/DOMStringHelper.hpp>
00074 #include <PlatformSupport/PrefixResolver.hpp>
00075 #include <PlatformSupport/XalanLocator.hpp>
00076 
00077 
00078 
00079 #include <XPath/XalanQNameByReference.hpp>
00080 
00081 
00082 
00083 #include <XSLT/NamespacesHandler.hpp>
00084 
00085 
00086 
00087 XALAN_DECLARE_XERCES_CLASS(AttributeList)
00088 XALAN_DECLARE_XERCES_CLASS(Locator)
00089 
00090 
00091 
00092 XALAN_CPP_NAMESPACE_BEGIN
00093 
00094 
00095 
00096 typedef XERCES_CPP_NAMESPACE_QUALIFIER AttributeList    AttributeListType;
00097 typedef XERCES_CPP_NAMESPACE_QUALIFIER Locator          LocatorType;
00098 
00099 
00100 
00101 class ElemTemplate;
00102 class ElemTextLiteral;
00103 class NamespacesHandler;
00104 class Stylesheet;
00105 class StylesheetConstructionContext;
00106 class StylesheetExecutionContext;
00107 
00108 
00109 
00110 class XALAN_XSLT_EXPORT ElemTemplateElement : public XalanElement, public PrefixResolver
00111 {
00112 public:
00113 
00114     typedef XalanElement::NodeType  NodeType;
00115 
00126     ElemTemplateElement(
00127             StylesheetConstructionContext&  constructionContext,
00128             Stylesheet&                     stylesheetTree,
00129             int                             lineNumber,
00130             int                             columnNumber,
00131             int                             xslToken);
00132 
00143     ElemTemplateElement(
00144             Stylesheet&                     stylesheetTree,
00145             int                             xslToken,
00146             int                             lineNumber = XalanLocator::getUnknownValue(),
00147             int                             columnNumber = XalanLocator::getUnknownValue());
00148 
00149     virtual
00150     ~ElemTemplateElement();
00151 
00157     virtual const LocatorType*
00158     getLocator() const;
00159 
00170     virtual bool
00171     isAttrOK(
00172             const XalanDOMChar*             attrName,
00173             const AttributeListType&        atts,
00174             int                             which,
00175             StylesheetConstructionContext&  constructionContext) const;
00176 
00186     bool
00187     processSpaceAttr(
00188             const XalanDOMChar*             aname,
00189             const AttributeListType&        atts,
00190             int                             which,
00191             StylesheetConstructionContext&  constructionContext);
00192 
00200     static bool
00201     isValidNCName(const XalanDOMString&     s);
00202 
00209     virtual void
00210     execute(StylesheetExecutionContext&     executionContext) const;
00211 
00217     virtual void
00218     executeChildren(StylesheetExecutionContext&     executionContext) const;
00219 
00226     virtual void
00227     executeChildren(
00228             StylesheetExecutionContext&     executionContext,
00229             XalanNode*                      sourceNode) const;
00230 
00242     const XalanDOMString&
00243     childrenToString(
00244             StylesheetExecutionContext&     executionContext,
00245             XalanDOMString&                 result) const;
00246 
00255     void
00256     childrenToResultAttribute(
00257             StylesheetExecutionContext&     executionContext,
00258             const XalanDOMString&           theName) const;
00259 
00267     void
00268     childrenToResultComment(StylesheetExecutionContext& executionContext) const;
00269 
00279     void
00280     childrenToResultPI(
00281             StylesheetExecutionContext&     executionContext,
00282             const XalanDOMString&           theTarget) const;
00283 
00291     int
00292     getXSLToken() const
00293     {
00294         return m_xslToken;
00295     }
00296 
00302     int
00303     getLineNumber() const
00304     {
00305         return m_lineNumber;
00306     }
00307 
00313     int
00314     getColumnNumber() const
00315     {
00316         return m_columnNumber;
00317     }
00318 
00324     virtual bool
00325     isWhitespace() const;
00326 
00333     virtual const XalanDOMString&
00334     getElementName() const = 0;
00335 
00342     virtual const XalanQName&
00343     getNameAttribute() const;
00344 
00353     virtual void
00354     addToStylesheet(
00355             StylesheetConstructionContext&  constructionContext,
00356             Stylesheet&                     theStylesheet);
00357 
00369     virtual void
00370     processSortElement(
00371             StylesheetConstructionContext&  constructionContext,
00372             Stylesheet&                     theStylesheet,
00373             const AttributeListType&        atts,
00374             const LocatorType*              locator = 0);
00375 
00381     virtual void
00382     setDefaultTemplate(bool     value);
00383 
00389     const NamespacesHandler&
00390     getNamespacesHandler() const
00391     {
00392         return m_namespacesHandler;
00393     }
00394 
00400     const Stylesheet&
00401     getStylesheet() const
00402     {
00403         return m_stylesheet;
00404     }
00405 
00411     void
00412     setFinishedConstruction(bool    fValue)
00413     {
00414         setFlag(eFinishedConstruction, fValue);
00415     }
00416 
00420     bool
00421     getFinishedConstruction() const
00422     {
00423         return getFlag(eFinishedConstruction);
00424     }
00425 
00429     virtual void
00430     postConstruction(
00431             StylesheetConstructionContext&  constructionContext,
00432             const NamespacesHandler&        theParentHandler);
00433 
00434     // Type-safe getters/setters...
00435 
00441     virtual ElemTemplateElement*
00442     getFirstChildElem() const;
00443 
00451     virtual void
00452     setFirstChildElem(ElemTemplateElement*  theChild);
00453 
00459     virtual ElemTemplateElement*
00460     getLastChildElem() const;
00461 
00467     virtual ElemTemplateElement*
00468     getNextSiblingElem() const;
00469 
00477     virtual void
00478     setNextSiblingElem(ElemTemplateElement*     theSibling);
00479 
00485     virtual ElemTemplateElement*
00486     getPreviousSiblingElem() const;
00487 
00495     virtual void
00496     setPreviousSiblingElem(ElemTemplateElement*     theSibling);
00497 
00503     virtual ElemTemplateElement*
00504     getParentNodeElem() const;
00505 
00513     virtual void
00514     setParentNodeElem(ElemTemplateElement*      theParent);
00515 
00523     virtual ElemTemplateElement*
00524     appendChildElem(ElemTemplateElement*    newChild);
00525 
00526 
00527     // These interfaces are inherited from XalanElement ...
00528 
00529     virtual const XalanDOMString&
00530     getNodeName() const;
00531 
00532     virtual const XalanDOMString&
00533     getNodeValue() const;
00534 
00535     virtual NodeType
00536     getNodeType() const;
00537 
00538     virtual XalanNode*
00539     getParentNode() const;
00540 
00541     virtual const XalanNodeList*
00542     getChildNodes() const;
00543 
00544     virtual XalanNode*
00545     getFirstChild() const;
00546 
00547     virtual XalanNode*
00548     getLastChild() const;
00549 
00550     virtual XalanNode*
00551     getPreviousSibling() const;
00552 
00553     virtual XalanNode*
00554     getNextSibling() const;
00555 
00556     virtual const XalanNamedNodeMap*
00557     getAttributes() const;
00558 
00559     virtual XalanDocument*
00560     getOwnerDocument() const;
00561 
00562 #if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
00563     virtual XalanNode*
00564 #else
00565     virtual ElemTemplateElement*
00566 #endif
00567     cloneNode(bool  deep) const;
00568 
00569     virtual XalanNode*
00570     insertBefore(
00571             XalanNode*  newChild,
00572             XalanNode*  refChild);
00573 
00574     virtual XalanNode*
00575     replaceChild(
00576             XalanNode*  newChild,
00577             XalanNode*  oldChild);
00578 
00579     virtual XalanNode*
00580     removeChild(XalanNode*  oldChild);
00581 
00588     virtual XalanNode*
00589     appendChild(XalanNode*  newChild);
00590 
00591     virtual bool
00592     hasChildNodes() const;
00593 
00594     virtual void
00595     setNodeValue(const XalanDOMString&  nodeValue);
00596 
00597     virtual void
00598     normalize();
00599 
00600     virtual bool
00601     isSupported(
00602             const XalanDOMString&   feature,
00603             const XalanDOMString&   version) const;
00604 
00605     virtual const XalanDOMString&
00606     getNamespaceURI() const;
00607 
00608     virtual const XalanDOMString&
00609     getPrefix() const;
00610 
00611     virtual const XalanDOMString&
00612     getLocalName() const;
00613 
00614     virtual void
00615     setPrefix(const XalanDOMString& prefix);
00616 
00617     virtual bool
00618     isIndexed() const;
00619 
00620     virtual IndexType
00621     getIndex() const;
00622 
00623     virtual const XalanDOMString&
00624     getTagName() const;
00625 
00626     virtual const XalanDOMString&
00627     getAttribute(const XalanDOMString&  name) const;
00628 
00629     virtual XalanAttr*
00630     getAttributeNode(const XalanDOMString&  name) const;
00631 
00632     virtual XalanNodeList*
00633     getElementsByTagName(const XalanDOMString&  name) const;
00634 
00635     virtual void
00636     setAttribute(
00637             const XalanDOMString&   name, 
00638             const XalanDOMString&   value);
00639 
00640     virtual XalanAttr*
00641     setAttributeNode(XalanAttr*     newAttr);
00642 
00643     virtual XalanAttr*
00644     removeAttributeNode(XalanAttr*  oldAttr);
00645 
00646     virtual void
00647     removeAttribute(const XalanDOMString&   name);
00648 
00649     virtual const XalanDOMString&
00650     getAttributeNS(
00651             const XalanDOMString&   namespaceURI,
00652             const XalanDOMString&   localName) const;
00653 
00654     virtual void
00655     setAttributeNS(
00656             const XalanDOMString&   namespaceURI,
00657             const XalanDOMString&   qualifiedName,
00658             const XalanDOMString&   value);
00659 
00660     virtual void
00661     removeAttributeNS(
00662             const XalanDOMString&   namespaceURI,
00663             const XalanDOMString&   localName);
00664 
00665     virtual XalanAttr*
00666     getAttributeNodeNS(
00667             const XalanDOMString&   namespaceURI,
00668             const XalanDOMString&   localName) const;
00669 
00670     virtual XalanAttr*
00671     setAttributeNodeNS(XalanAttr*   newAttr);
00672 
00673     virtual XalanNodeList*
00674     getElementsByTagNameNS(
00675             const XalanDOMString&   namespaceURI,
00676             const XalanDOMString&   localName) const;
00677 
00678 
00679     // These interfaces are inherited from PrefixResolver...
00680 
00681     virtual const XalanDOMString*
00682     getNamespaceForPrefix(const XalanDOMString& prefix) const;
00683 
00684     virtual const XalanDOMString&
00685     getURI() const;
00686 
00687     class LocatorProxy : public XalanLocator
00688     {
00689     public:
00690 
00691         LocatorProxy(const ElemTemplateElement&     theElement);
00692 
00693         virtual
00694         ~LocatorProxy();
00695 
00696         virtual const XMLCh*
00697         getPublicId() const;
00698 
00699         virtual const XMLCh*
00700         getSystemId() const;
00701 
00702         virtual size_type
00703         getLineNumber() const;
00704 
00705         virtual size_type
00706         getColumnNumber() const;
00707 
00708     private:
00709 
00710         // Not implemented...
00711         LocatorProxy(const LocatorProxy&);
00712 
00713         LocatorProxy&
00714         operator=(const LocatorProxy&);
00715 
00716         bool
00717         operator==(const LocatorProxy&) const;
00718 
00719         // data members...
00720         const ElemTemplateElement&  m_element;
00721     };
00722 
00723     bool
00724     hasParams() const
00725     {
00726         return getFlag(eHasParams);
00727     }
00728 
00729     bool
00730     hasVariables() const
00731     {
00732         return getFlag(eHasVariables);
00733     }
00734 
00735     bool
00736     hasSingleTextChild() const
00737     {
00738         return getFlag(eHasSingleTextChild);
00739     }
00740 
00741     bool
00742     hasChildren() const
00743     {
00744         return m_firstChild != 0 ? true : false;
00745     }
00746 
00747     bool
00748     hasDirectTemplate() const
00749     {
00750         return getFlag(eHasDirectTemplate);
00751     }
00752 
00753     bool
00754     canGenerateAttributes() const
00755     {
00756         return getFlag(eCanGenerateAttributes);
00757     }
00758 
00759     bool
00760     isDefaultTemplate() const
00761     {
00762         return getFlag(eDefaultTemplate);
00763     }
00764 
00765 protected:
00766 
00767     void
00768     canGenerateAttributes(bool  value)
00769     {
00770         setFlag(eCanGenerateAttributes, value);
00771     }
00772 
00773     void
00774     hasPrefix(bool  value)
00775     {
00776         setFlag(eHasPrefix, value);
00777     }
00778 
00779     bool
00780     hasPrefix() const
00781     {
00782         return getFlag(eHasPrefix);
00783     }
00784 
00785     void
00786     preserveSpace(bool  value)
00787     {
00788         setFlag(eSpacePreserve, value);
00789     }
00790 
00791     bool
00792     preserveSpace() const
00793     {
00794         return getFlag(eSpacePreserve);
00795     }
00796 
00797     void
00798     disableOutputEscaping(bool  value)
00799     {
00800         setFlag(eDisableOutputEscaping, value);
00801     }
00802 
00803     bool
00804     disableOutputEscaping() const
00805     {
00806         return getFlag(eDisableOutputEscaping);
00807     }
00808 
00818     bool
00819     processPrefixControl(
00820             StylesheetConstructionContext&  constructionContext,
00821             const Stylesheet&               stylesheetTree,
00822             const XalanDOMString&           localName,
00823             const XalanDOMChar*             attrValue);
00824 
00832     const XalanDOMString*
00833     getNamespaceForPrefixInternal(const XalanDOMString&     prefix) const;
00834 
00844     virtual void
00845     transformChild(
00846             StylesheetExecutionContext&     executionContext,
00847             const ElemTemplateElement&      xslInstruction,
00848             const ElemTemplateElement*      theTemplate,
00849             XalanNode*                      child) const;
00850 
00861     virtual void
00862     transformChild(
00863             StylesheetExecutionContext&     executionContext,
00864             const ElemTemplateElement&      xslInstruction,
00865             const ElemTemplateElement*      theTemplate,
00866             XalanNode*                      child,
00867             XalanNode::NodeType             nodeType) const;
00868 
00881     virtual bool
00882     childTypeAllowed(int    xslToken) const;
00883 
00890     virtual void
00891     namespacesPostConstruction(
00892             StylesheetConstructionContext&  constructionContext,
00893             const NamespacesHandler&        theParentHandler,
00894             NamespacesHandler&              theHandler);
00895 
00896     static const XalanDOMString     s_emptyString;
00897 
00898     const NamespacesHandler&
00899     getNamespaces() const
00900     {
00901         return m_namespacesHandler;
00902     }
00903 
00904 private:
00905 
00906     enum eFlags
00907     { 
00908         eHasParams = 1,
00909         eHasSingleTextChild = 2,
00910         eHasVariables = 4,
00911         eHasDirectTemplate = 8,
00912         eCanGenerateAttributes = 16,
00913         eDefaultTemplate = 32,
00914         eSpacePreserve = 64,
00915         eFinishedConstruction = 128,
00916         eHasPrefix = 256,
00917         eDisableOutputEscaping = 512
00918     };
00919 
00920     bool
00921     getFlag(eFlags  theFlag) const
00922     {
00923         return m_flags & theFlag ? true : false;
00924     }
00925 
00926     void
00927     setFlag(
00928             eFlags  theFlag,
00929             bool    theValue)
00930     {
00931         if (theValue == true)
00932         {
00933             m_flags |= theFlag;
00934         }
00935         else
00936         {
00937             m_flags &= ~theFlag;
00938         }
00939     }
00940 
00949     XalanDOMString&
00950     doChildrenToString(
00951             StylesheetExecutionContext&     executionContext, 
00952             XalanDOMString&                 result) const;
00953 
00954     Stylesheet&             m_stylesheet;
00955 
00956     /*
00957      * This object handles all result tree namespace processing.
00958      */
00959     NamespacesHandler       m_namespacesHandler;
00960 
00961     const int               m_lineNumber;
00962     const int               m_columnNumber;
00963 
00964     const int               m_xslToken;
00965 
00966     ElemTemplateElement*    m_parentNode;
00967     ElemTemplateElement*    m_nextSibling;
00968     ElemTemplateElement*    m_previousSibling;
00969 
00970     union
00971     {
00972         ElemTemplateElement*    m_firstChild;
00973         const ElemTemplate*     m_directTemplate;
00974         const ElemTextLiteral*  m_textLiteralChild;
00975     };
00976 
00977     const XalanDOMString&   m_baseIndentifier;
00978 
00979     LocatorProxy            m_locatorProxy;
00980 
00981     unsigned short          m_flags;
00982 
00983     static const XalanEmptyNamedNodeMap     s_fakeAttributes;
00984 
00985     static const XalanQNameByReference      s_emptyQName;
00986 
00987     // Not implemented...
00988     ElemTemplateElement(const ElemTemplateElement&);
00989 
00990     ElemTemplateElement&
00991     operator=(const ElemTemplateElement&);
00992 
00993     bool
00994     operator==(const ElemTemplateElement&) const;
00995 };
00996 
00997 
00998 
00999 XALAN_CPP_NAMESPACE_END
01000 
01001 
01002 
01003 #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.5
Copyright © 2000, 2001, 2002, 2003 The Apache Software Foundation. All Rights Reserved.