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 #include "LocalMsgIndex.hpp" 00046 00047 00048 00049 XALAN_DECLARE_XERCES_CLASS(AttributeList) 00050 XALAN_DECLARE_XERCES_CLASS(Locator) 00051 00052 00053 00054 XALAN_CPP_NAMESPACE_BEGIN 00055 00056 00057 00058 typedef XERCES_CPP_NAMESPACE_QUALIFIER AttributeList AttributeListType; 00059 typedef XERCES_CPP_NAMESPACE_QUALIFIER Locator LocatorType; 00060 00061 00062 XALAN_USING_XERCES(AttributeList) 00063 XALAN_USING_XERCES(Locator) 00064 class ElemTemplate; 00065 class ElemTextLiteral; 00066 class NamespacesHandler; 00067 class Stylesheet; 00068 class StylesheetConstructionContext; 00069 class StylesheetExecutionContext; 00070 class XPath; 00071 00072 00073 00074 class XALAN_XSLT_EXPORT ElemTemplateElement : public PrefixResolver 00075 { 00076 00077 public: 00078 00089 ElemTemplateElement( 00090 StylesheetConstructionContext& constructionContext, 00091 Stylesheet& stylesheetTree, 00092 int lineNumber, 00093 int columnNumber, 00094 int xslToken); 00095 00108 ElemTemplateElement( 00109 StylesheetConstructionContext& constructionContext, 00110 Stylesheet& stylesheetTree, 00111 int xslToken, 00112 const XalanDOMString& baseURI = XalanDOMString(XalanMemMgrs::getDummyMemMgr()), 00113 int lineNumber = XalanLocator::getUnknownValue(), 00114 int columnNumber = XalanLocator::getUnknownValue()); 00115 00116 virtual 00117 ~ElemTemplateElement(); 00118 00124 virtual const LocatorType* 00125 getLocator() const; 00126 00137 virtual bool 00138 isAttrOK( 00139 const XalanDOMChar* attrName, 00140 const AttributeListType& atts, 00141 int which, 00142 StylesheetConstructionContext& constructionContext) const; 00143 00154 bool 00155 processSpaceAttr( 00156 const XalanDOMChar* elementName, 00157 const XalanDOMChar* aname, 00158 const AttributeListType& atts, 00159 int which, 00160 StylesheetConstructionContext& constructionContext); 00161 00169 static bool 00170 isValidNCName(const XalanDOMString& s); 00171 00172 #if !defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION) 00173 00181 virtual const ElemTemplateElement* 00182 startElement(StylesheetExecutionContext& executionContext) const; 00183 00191 virtual void 00192 endElement(StylesheetExecutionContext& executionContext) const; 00193 00199 virtual void 00200 execute(StylesheetExecutionContext& executionContext) const; 00201 00207 virtual void 00208 executeChildren(StylesheetExecutionContext& executionContext) const; 00209 00214 virtual const ElemTemplateElement* 00215 getInvoker(StylesheetExecutionContext& executionContext) const; 00216 00217 #else 00218 00225 virtual void 00226 execute(StylesheetExecutionContext& executionContext) const; 00227 00233 virtual void 00234 executeChildren(StylesheetExecutionContext& executionContext) const; 00235 00242 virtual void 00243 executeChildren( 00244 StylesheetExecutionContext& executionContext, 00245 XalanNode* sourceNode) const; 00246 00258 const XalanDOMString& 00259 childrenToString( 00260 StylesheetExecutionContext& executionContext, 00261 XalanDOMString& result) const; 00262 00271 void 00272 childrenToResultAttribute( 00273 StylesheetExecutionContext& executionContext, 00274 const XalanDOMString& theName) const; 00275 00283 void 00284 childrenToResultComment(StylesheetExecutionContext& executionContext) const; 00285 00295 void 00296 childrenToResultPI( 00297 StylesheetExecutionContext& executionContext, 00298 const XalanDOMString& theTarget) const; 00299 00307 #endif 00308 00309 int 00310 getXSLToken() const 00311 { 00312 return m_xslToken; 00313 } 00314 00320 virtual bool 00321 isWhitespace() const; 00322 00329 virtual const XalanDOMString& 00330 getElementName() const = 0; 00331 00338 virtual const XalanQName& 00339 getNameAttribute() const; 00340 00349 virtual void 00350 addToStylesheet( 00351 StylesheetConstructionContext& constructionContext, 00352 Stylesheet& theStylesheet); 00353 00365 virtual void 00366 processSortElement( 00367 StylesheetConstructionContext& constructionContext, 00368 Stylesheet& theStylesheet, 00369 const AttributeListType& atts, 00370 const LocatorType* locator = 0); 00371 00377 virtual void 00378 setDefaultTemplate(bool value); 00379 00385 const NamespacesHandler& 00386 getNamespacesHandler() const 00387 { 00388 return m_namespacesHandler; 00389 } 00390 00396 const Stylesheet& 00397 getStylesheet() const 00398 { 00399 return m_stylesheet; 00400 } 00401 00407 void 00408 setFinishedConstruction(bool fValue) 00409 { 00410 setFlag(eFinishedConstruction, fValue); 00411 } 00412 00416 bool 00417 getFinishedConstruction() const 00418 { 00419 return getFlag(eFinishedConstruction); 00420 } 00421 00425 virtual void 00426 postConstruction( 00427 StylesheetConstructionContext& constructionContext, 00428 const NamespacesHandler& theParentHandler); 00429 00430 // Type-safe getters/setters... 00431 00437 virtual ElemTemplateElement* 00438 getFirstChildElem() const; 00439 00440 #if !defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION) 00441 00447 virtual const ElemTemplateElement* 00448 beginExecuteChildren( 00449 StylesheetExecutionContext& executionContext) const; 00450 00451 00458 virtual void 00459 endExecuteChildren( 00460 StylesheetExecutionContext& executionContext) const; 00461 00470 const ElemTemplateElement* 00471 beginChildrenToString( 00472 StylesheetExecutionContext& executionContext, 00473 XalanDOMString& result) const; 00474 00475 00482 void 00483 endChildrenToString( 00484 StylesheetExecutionContext& executionContext) const; 00485 #endif 00486 00487 00495 virtual void 00496 setFirstChildElem(ElemTemplateElement* theChild); 00497 00503 virtual ElemTemplateElement* 00504 getLastChildElem() const; 00505 00511 virtual ElemTemplateElement* 00512 getNextSiblingElem() const; 00513 00514 #if !defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION) 00515 00524 virtual const ElemTemplateElement* 00525 getNextChildElemToExecute( 00526 StylesheetExecutionContext& executionContext, 00527 const ElemTemplateElement* currentElem) const; 00528 00536 virtual const ElemTemplateElement* 00537 getFirstChildElemToExecute( 00538 StylesheetExecutionContext& executionContext) const; 00539 00547 virtual bool executeChildElement( 00548 StylesheetExecutionContext& executionContext, 00549 const ElemTemplateElement* element) const; 00550 #endif 00551 00559 virtual void 00560 setNextSiblingElem(ElemTemplateElement* theSibling); 00561 00567 virtual ElemTemplateElement* 00568 getPreviousSiblingElem() const; 00569 00577 virtual void 00578 setPreviousSiblingElem(ElemTemplateElement* theSibling); 00579 00585 virtual ElemTemplateElement* 00586 getParentNodeElem() const; 00587 00595 virtual void 00596 setParentNodeElem(ElemTemplateElement* theParent); 00597 00605 virtual ElemTemplateElement* 00606 appendChildElem(ElemTemplateElement* newChild); 00607 00617 virtual const XPath* 00618 getXPath(unsigned int index = 0) const; 00619 00620 // These interfaces are inherited from PrefixResolver... 00621 00622 virtual const XalanDOMString* 00623 getNamespaceForPrefix(const XalanDOMString& prefix) const; 00624 00625 virtual const XalanDOMString& 00626 getURI() const; 00627 00628 // A class that implements the XalanLocator 00629 // abstract base class. ElemTemplateElement 00630 // uses this class to provide locator information. 00631 class LocatorProxy : public XalanLocator 00632 { 00633 public: 00634 00635 LocatorProxy( 00636 size_type theLineNumber, 00637 size_type theColumnNumber, 00638 const XalanDOMString& theURI); 00639 00640 virtual 00641 ~LocatorProxy(); 00642 00643 virtual const XMLCh* 00644 getPublicId() const; 00645 00646 virtual const XMLCh* 00647 getSystemId() const; 00648 00649 virtual size_type 00650 getLineNumber() const; 00651 00652 virtual size_type 00653 getColumnNumber() const; 00654 00655 const XalanDOMString& 00656 getURI() const 00657 { 00658 return m_uri; 00659 } 00660 00661 private: 00662 00663 // Not implemented... 00664 LocatorProxy(const LocatorProxy&); 00665 00666 LocatorProxy& 00667 operator=(const LocatorProxy&); 00668 00669 bool 00670 operator==(const LocatorProxy&) const; 00671 00672 // data members... 00673 const size_type m_lineNumber; 00674 00675 const size_type m_columnNumber; 00676 00677 const XalanDOMString& m_uri; 00678 }; 00679 00680 00681 LocatorProxy::size_type 00682 getLineNumber() const 00683 { 00684 return m_locatorProxy.getLineNumber(); 00685 } 00686 00687 LocatorProxy::size_type 00688 getColumnNumber() const 00689 { 00690 return m_locatorProxy.getColumnNumber(); 00691 } 00692 00693 bool 00694 hasParams() const 00695 { 00696 return getFlag(eHasParams); 00697 } 00698 00699 bool 00700 hasVariables() const 00701 { 00702 return getFlag(eHasVariables); 00703 } 00704 00705 bool 00706 hasSingleTextChild() const 00707 { 00708 return getFlag(eHasSingleTextChild); 00709 } 00710 00711 bool 00712 hasChildren() const 00713 { 00714 return m_firstChild != 0 ? true : false; 00715 } 00716 00717 bool 00718 hasDirectTemplate() const 00719 { 00720 return getFlag(eHasDirectTemplate); 00721 } 00722 00723 bool 00724 canGenerateAttributes() const 00725 { 00726 return getFlag(eCanGenerateAttributes); 00727 } 00728 00729 bool 00730 isDefaultTemplate() const 00731 { 00732 return getFlag(eDefaultTemplate); 00733 } 00734 00735 protected: 00736 00737 void 00738 canGenerateAttributes(bool value) 00739 { 00740 setFlag(eCanGenerateAttributes, value); 00741 } 00742 00743 void 00744 hasPrefix(bool value) 00745 { 00746 setFlag(eHasPrefix, value); 00747 } 00748 00749 bool 00750 hasPrefix() const 00751 { 00752 return getFlag(eHasPrefix); 00753 } 00754 00755 void 00756 preserveSpace(bool value) 00757 { 00758 setFlag(eSpacePreserve, value); 00759 } 00760 00761 bool 00762 preserveSpace() const 00763 { 00764 return getFlag(eSpacePreserve); 00765 } 00766 00767 void 00768 disableOutputEscaping(bool value) 00769 { 00770 setFlag(eDisableOutputEscaping, value); 00771 } 00772 00773 bool 00774 disableOutputEscaping() const 00775 { 00776 return getFlag(eDisableOutputEscaping); 00777 } 00778 00788 bool 00789 processPrefixControl( 00790 StylesheetConstructionContext& constructionContext, 00791 const Stylesheet& stylesheetTree, 00792 const XalanDOMString& localName, 00793 const XalanDOMChar* attrValue); 00794 00802 const XalanDOMString* 00803 getNamespaceForPrefixInternal(const XalanDOMString& prefix) const; 00804 00805 #if !defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION) 00806 00816 virtual const ElemTemplateElement* 00817 findTemplateToTransformChild( 00818 StylesheetExecutionContext& executionContext, 00819 const ElemTemplateElement& xslInstruction, 00820 const ElemTemplateElement* theTemplate, 00821 XalanNode* child) const; 00822 00834 virtual const ElemTemplateElement* 00835 findTemplateToTransformChild( 00836 StylesheetExecutionContext& executionContext, 00837 const ElemTemplateElement& xslInstruction, 00838 const ElemTemplateElement* theTemplate, 00839 XalanNode* child, 00840 XalanNode::NodeType nodeType) const; 00841 #else 00842 00851 virtual void 00852 transformChild( 00853 StylesheetExecutionContext& executionContext, 00854 const ElemTemplateElement& xslInstruction, 00855 const ElemTemplateElement* theTemplate, 00856 XalanNode* child) const; 00857 00868 virtual void 00869 transformChild( 00870 StylesheetExecutionContext& executionContext, 00871 const ElemTemplateElement& xslInstruction, 00872 const ElemTemplateElement* theTemplate, 00873 XalanNode* child, 00874 XalanNode::NodeType nodeType) const; 00875 #endif 00876 00889 virtual bool 00890 childTypeAllowed(int xslToken) const; 00891 00898 virtual void 00899 namespacesPostConstruction( 00900 StylesheetConstructionContext& constructionContext, 00901 const NamespacesHandler& theParentHandler, 00902 NamespacesHandler& theHandler); 00903 00904 const NamespacesHandler& 00905 getNamespaces() const 00906 { 00907 return m_namespacesHandler; 00908 } 00909 00918 void 00919 error( 00920 StylesheetExecutionContext& theContext, 00921 XalanMessages::Codes theCode) const; 00922 00932 void 00933 error( 00934 StylesheetExecutionContext& theContext, 00935 XalanMessages::Codes theCode, 00936 const XalanDOMString& theToken) const; 00937 00947 void 00948 error( 00949 StylesheetExecutionContext& theContext, 00950 XalanMessages::Codes theCode, 00951 const Locator* theLocator) const; 00952 00961 void 00962 warn( 00963 StylesheetExecutionContext& theContext, 00964 XalanMessages::Codes theCode) const; 00965 00975 void 00976 warn( 00977 StylesheetExecutionContext& theContext, 00978 XalanMessages::Codes theCode, 00979 const XalanDOMString& theToken) const; 00980 00990 void 00991 warn( 00992 StylesheetExecutionContext& theContext, 00993 XalanMessages::Codes theCode, 00994 const Locator* theLocator) const; 00995 01004 void 01005 error( 01006 StylesheetConstructionContext& theContext, 01007 XalanMessages::Codes theCode); 01008 01019 void 01020 error( 01021 StylesheetConstructionContext& theContext, 01022 XalanMessages::Codes theCode, 01023 const XalanDOMString& theToken); 01024 01035 void 01036 error( 01037 StylesheetConstructionContext& theContext, 01038 XalanMessages::Codes theCode, 01039 const XalanDOMString& theToken, 01040 const Locator* theLocator); 01041 01052 void 01053 error( 01054 StylesheetConstructionContext& theContext, 01055 XalanMessages::Codes theCode, 01056 const XalanDOMString& theToken1, 01057 const XalanDOMString& theToken2); 01058 01069 void 01070 error( 01071 StylesheetConstructionContext& theContext, 01072 XalanMessages::Codes theCode, 01073 const XalanDOMChar* theToken1, 01074 const XalanDOMChar* theToken2); 01075 01087 void 01088 error( 01089 StylesheetConstructionContext& theContext, 01090 XalanMessages::Codes theCode, 01091 const XalanDOMChar* theToken1, 01092 const XalanDOMChar* theToken2, 01093 const XalanDOMChar* theToken3); 01094 01106 void 01107 warn( 01108 StylesheetConstructionContext& theContext, 01109 XalanMessages::Codes theCode, 01110 const XalanDOMChar* theToken1, 01111 const XalanDOMChar* theToken2, 01112 const XalanDOMChar* theToken3); 01113 01114 // A handy empty XalanDOMString instance for 01115 // derived classes to use. 01116 static const XalanDOMString s_emptyString; 01117 01118 private: 01119 01120 enum eFlags 01121 { 01122 eHasParams = 1, 01123 eHasSingleTextChild = 2, 01124 eHasVariables = 4, 01125 eHasDirectTemplate = 8, 01126 eCanGenerateAttributes = 16, 01127 eDefaultTemplate = 32, 01128 eSpacePreserve = 64, 01129 eFinishedConstruction = 128, 01130 eHasPrefix = 256, 01131 eDisableOutputEscaping = 512 01132 }; 01133 01134 bool 01135 getFlag(eFlags theFlag) const 01136 { 01137 return m_flags & theFlag ? true : false; 01138 } 01139 01140 void 01141 setFlag( 01142 eFlags theFlag, 01143 bool theValue) 01144 { 01145 if (theValue == true) 01146 { 01147 m_flags |= theFlag; 01148 } 01149 else 01150 { 01151 m_flags &= ~theFlag; 01152 } 01153 } 01154 01155 01156 #if defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION) 01157 01165 XalanDOMString& 01166 doChildrenToString( 01167 StylesheetExecutionContext& executionContext, 01168 XalanDOMString& result) const; 01169 #endif 01170 01171 Stylesheet& m_stylesheet; 01172 01173 /* 01174 * This object handles all result tree namespace processing. 01175 */ 01176 NamespacesHandler m_namespacesHandler; 01177 01178 const int m_xslToken; 01179 01180 ElemTemplateElement* m_parentNode; 01181 ElemTemplateElement* m_nextSibling; 01182 ElemTemplateElement* m_previousSibling; 01183 01184 union 01185 { 01186 ElemTemplateElement* m_firstChild; 01187 const ElemTemplate* m_directTemplate; 01188 const ElemTextLiteral* m_textLiteralChild; 01189 }; 01190 01191 LocatorProxy m_locatorProxy; 01192 01193 unsigned short m_flags; 01194 01195 static const XalanQNameByReference s_emptyQName; 01196 01197 // Not implemented... 01198 ElemTemplateElement(const ElemTemplateElement&); 01199 01200 ElemTemplateElement& 01201 operator=(const ElemTemplateElement&); 01202 01203 bool 01204 operator==(const ElemTemplateElement&) const; 01205 }; 01206 01207 01208 01209 XALAN_CPP_NAMESPACE_END 01210 01211 01212 01213 #endif // XALAN_ELEMTEMPLATEELEMENT_HEADER_GUARD
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
Xalan-C++ XSLT Processor Version 1.10 |
|