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 class XALAN_XSLT_EXPORT ElemTemplateElement : public PrefixResolver 00069 { 00070 public: 00071 00082 ElemTemplateElement( 00083 StylesheetConstructionContext& constructionContext, 00084 Stylesheet& stylesheetTree, 00085 int lineNumber, 00086 int columnNumber, 00087 int xslToken); 00088 00101 ElemTemplateElement( 00102 StylesheetConstructionContext& constructionContext, 00103 Stylesheet& stylesheetTree, 00104 int xslToken, 00105 const XalanDOMString& baseURI = XalanDOMString(), 00106 int lineNumber = XalanLocator::getUnknownValue(), 00107 int columnNumber = XalanLocator::getUnknownValue()); 00108 00109 virtual 00110 ~ElemTemplateElement(); 00111 00117 virtual const LocatorType* 00118 getLocator() const; 00119 00130 virtual bool 00131 isAttrOK( 00132 const XalanDOMChar* attrName, 00133 const AttributeListType& atts, 00134 int which, 00135 StylesheetConstructionContext& constructionContext) const; 00136 00146 bool 00147 processSpaceAttr( 00148 const XalanDOMChar* aname, 00149 const AttributeListType& atts, 00150 int which, 00151 StylesheetConstructionContext& constructionContext); 00152 00160 static bool 00161 isValidNCName(const XalanDOMString& s); 00162 00169 virtual void 00170 execute(StylesheetExecutionContext& executionContext) const; 00171 00177 virtual void 00178 executeChildren(StylesheetExecutionContext& executionContext) const; 00179 00186 virtual void 00187 executeChildren( 00188 StylesheetExecutionContext& executionContext, 00189 XalanNode* sourceNode) const; 00190 00202 const XalanDOMString& 00203 childrenToString( 00204 StylesheetExecutionContext& executionContext, 00205 XalanDOMString& result) const; 00206 00215 void 00216 childrenToResultAttribute( 00217 StylesheetExecutionContext& executionContext, 00218 const XalanDOMString& theName) const; 00219 00227 void 00228 childrenToResultComment(StylesheetExecutionContext& executionContext) const; 00229 00239 void 00240 childrenToResultPI( 00241 StylesheetExecutionContext& executionContext, 00242 const XalanDOMString& theTarget) const; 00243 00251 int 00252 getXSLToken() const 00253 { 00254 return m_xslToken; 00255 } 00256 00262 int 00263 getLineNumber() const 00264 { 00265 return m_lineNumber; 00266 } 00267 00273 int 00274 getColumnNumber() const 00275 { 00276 return m_columnNumber; 00277 } 00278 00284 virtual bool 00285 isWhitespace() const; 00286 00293 virtual const XalanDOMString& 00294 getElementName() const = 0; 00295 00302 virtual const XalanQName& 00303 getNameAttribute() const; 00304 00313 virtual void 00314 addToStylesheet( 00315 StylesheetConstructionContext& constructionContext, 00316 Stylesheet& theStylesheet); 00317 00329 virtual void 00330 processSortElement( 00331 StylesheetConstructionContext& constructionContext, 00332 Stylesheet& theStylesheet, 00333 const AttributeListType& atts, 00334 const LocatorType* locator = 0); 00335 00341 virtual void 00342 setDefaultTemplate(bool value); 00343 00349 const NamespacesHandler& 00350 getNamespacesHandler() const 00351 { 00352 return m_namespacesHandler; 00353 } 00354 00360 const Stylesheet& 00361 getStylesheet() const 00362 { 00363 return m_stylesheet; 00364 } 00365 00371 void 00372 setFinishedConstruction(bool fValue) 00373 { 00374 setFlag(eFinishedConstruction, fValue); 00375 } 00376 00380 bool 00381 getFinishedConstruction() const 00382 { 00383 return getFlag(eFinishedConstruction); 00384 } 00385 00389 virtual void 00390 postConstruction( 00391 StylesheetConstructionContext& constructionContext, 00392 const NamespacesHandler& theParentHandler); 00393 00394 // Type-safe getters/setters... 00395 00401 virtual ElemTemplateElement* 00402 getFirstChildElem() const; 00403 00411 virtual void 00412 setFirstChildElem(ElemTemplateElement* theChild); 00413 00419 virtual ElemTemplateElement* 00420 getLastChildElem() const; 00421 00427 virtual ElemTemplateElement* 00428 getNextSiblingElem() const; 00429 00437 virtual void 00438 setNextSiblingElem(ElemTemplateElement* theSibling); 00439 00445 virtual ElemTemplateElement* 00446 getPreviousSiblingElem() const; 00447 00455 virtual void 00456 setPreviousSiblingElem(ElemTemplateElement* theSibling); 00457 00463 virtual ElemTemplateElement* 00464 getParentNodeElem() const; 00465 00473 virtual void 00474 setParentNodeElem(ElemTemplateElement* theParent); 00475 00483 virtual ElemTemplateElement* 00484 appendChildElem(ElemTemplateElement* newChild); 00485 00495 virtual const XPath* 00496 getXPath(unsigned int index = 0) const; 00497 00498 // These interfaces are inherited from PrefixResolver... 00499 00500 virtual const XalanDOMString* 00501 getNamespaceForPrefix(const XalanDOMString& prefix) const; 00502 00503 virtual const XalanDOMString& 00504 getURI() const; 00505 00506 class LocatorProxy : public XalanLocator 00507 { 00508 public: 00509 00510 LocatorProxy(const ElemTemplateElement& theElement); 00511 00512 virtual 00513 ~LocatorProxy(); 00514 00515 virtual const XMLCh* 00516 getPublicId() const; 00517 00518 virtual const XMLCh* 00519 getSystemId() const; 00520 00521 virtual size_type 00522 getLineNumber() const; 00523 00524 virtual size_type 00525 getColumnNumber() const; 00526 00527 private: 00528 00529 // Not implemented... 00530 LocatorProxy(const LocatorProxy&); 00531 00532 LocatorProxy& 00533 operator=(const LocatorProxy&); 00534 00535 bool 00536 operator==(const LocatorProxy&) const; 00537 00538 // data members... 00539 const ElemTemplateElement& m_element; 00540 }; 00541 00542 bool 00543 hasParams() const 00544 { 00545 return getFlag(eHasParams); 00546 } 00547 00548 bool 00549 hasVariables() const 00550 { 00551 return getFlag(eHasVariables); 00552 } 00553 00554 bool 00555 hasSingleTextChild() const 00556 { 00557 return getFlag(eHasSingleTextChild); 00558 } 00559 00560 bool 00561 hasChildren() const 00562 { 00563 return m_firstChild != 0 ? true : false; 00564 } 00565 00566 bool 00567 hasDirectTemplate() const 00568 { 00569 return getFlag(eHasDirectTemplate); 00570 } 00571 00572 bool 00573 canGenerateAttributes() const 00574 { 00575 return getFlag(eCanGenerateAttributes); 00576 } 00577 00578 bool 00579 isDefaultTemplate() const 00580 { 00581 return getFlag(eDefaultTemplate); 00582 } 00583 00584 protected: 00585 00586 void 00587 canGenerateAttributes(bool value) 00588 { 00589 setFlag(eCanGenerateAttributes, value); 00590 } 00591 00592 void 00593 hasPrefix(bool value) 00594 { 00595 setFlag(eHasPrefix, value); 00596 } 00597 00598 bool 00599 hasPrefix() const 00600 { 00601 return getFlag(eHasPrefix); 00602 } 00603 00604 void 00605 preserveSpace(bool value) 00606 { 00607 setFlag(eSpacePreserve, value); 00608 } 00609 00610 bool 00611 preserveSpace() const 00612 { 00613 return getFlag(eSpacePreserve); 00614 } 00615 00616 void 00617 disableOutputEscaping(bool value) 00618 { 00619 setFlag(eDisableOutputEscaping, value); 00620 } 00621 00622 bool 00623 disableOutputEscaping() const 00624 { 00625 return getFlag(eDisableOutputEscaping); 00626 } 00627 00637 bool 00638 processPrefixControl( 00639 StylesheetConstructionContext& constructionContext, 00640 const Stylesheet& stylesheetTree, 00641 const XalanDOMString& localName, 00642 const XalanDOMChar* attrValue); 00643 00651 const XalanDOMString* 00652 getNamespaceForPrefixInternal(const XalanDOMString& prefix) const; 00653 00663 virtual void 00664 transformChild( 00665 StylesheetExecutionContext& executionContext, 00666 const ElemTemplateElement& xslInstruction, 00667 const ElemTemplateElement* theTemplate, 00668 XalanNode* child) const; 00669 00680 virtual void 00681 transformChild( 00682 StylesheetExecutionContext& executionContext, 00683 const ElemTemplateElement& xslInstruction, 00684 const ElemTemplateElement* theTemplate, 00685 XalanNode* child, 00686 XalanNode::NodeType nodeType) const; 00687 00700 virtual bool 00701 childTypeAllowed(int xslToken) const; 00702 00709 virtual void 00710 namespacesPostConstruction( 00711 StylesheetConstructionContext& constructionContext, 00712 const NamespacesHandler& theParentHandler, 00713 NamespacesHandler& theHandler); 00714 00715 static const XalanDOMString s_emptyString; 00716 00717 const NamespacesHandler& 00718 getNamespaces() const 00719 { 00720 return m_namespacesHandler; 00721 } 00722 00723 private: 00724 00725 enum eFlags 00726 { 00727 eHasParams = 1, 00728 eHasSingleTextChild = 2, 00729 eHasVariables = 4, 00730 eHasDirectTemplate = 8, 00731 eCanGenerateAttributes = 16, 00732 eDefaultTemplate = 32, 00733 eSpacePreserve = 64, 00734 eFinishedConstruction = 128, 00735 eHasPrefix = 256, 00736 eDisableOutputEscaping = 512 00737 }; 00738 00739 bool 00740 getFlag(eFlags theFlag) const 00741 { 00742 return m_flags & theFlag ? true : false; 00743 } 00744 00745 void 00746 setFlag( 00747 eFlags theFlag, 00748 bool theValue) 00749 { 00750 if (theValue == true) 00751 { 00752 m_flags |= theFlag; 00753 } 00754 else 00755 { 00756 m_flags &= ~theFlag; 00757 } 00758 } 00759 00768 XalanDOMString& 00769 doChildrenToString( 00770 StylesheetExecutionContext& executionContext, 00771 XalanDOMString& result) const; 00772 00773 Stylesheet& m_stylesheet; 00774 00775 /* 00776 * This object handles all result tree namespace processing. 00777 */ 00778 NamespacesHandler m_namespacesHandler; 00779 00780 const int m_lineNumber; 00781 const int m_columnNumber; 00782 00783 const int m_xslToken; 00784 00785 ElemTemplateElement* m_parentNode; 00786 ElemTemplateElement* m_nextSibling; 00787 ElemTemplateElement* m_previousSibling; 00788 00789 union 00790 { 00791 ElemTemplateElement* m_firstChild; 00792 const ElemTemplate* m_directTemplate; 00793 const ElemTextLiteral* m_textLiteralChild; 00794 }; 00795 00796 const XalanDOMString& m_baseIndentifier; 00797 00798 LocatorProxy m_locatorProxy; 00799 00800 unsigned short m_flags; 00801 00802 static const XalanQNameByReference s_emptyQName; 00803 00804 // Not implemented... 00805 ElemTemplateElement(const ElemTemplateElement&); 00806 00807 ElemTemplateElement& 00808 operator=(const ElemTemplateElement&); 00809 00810 bool 00811 operator==(const ElemTemplateElement&) const; 00812 }; 00813 00814 00815 00816 XALAN_CPP_NAMESPACE_END 00817 00818 00819 00820 #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.8 |
|