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 <vector> 00068 #include <map> 00069 00070 00071 00072 #include <XalanDOM/XalanDOMString.hpp> 00073 #include <XalanDOM/XalanElement.hpp> 00074 #include <XalanDOM/XalanEmptyNamedNodeMap.hpp> 00075 #include <XalanDOM/XalanNodeListSurrogate.hpp> 00076 00077 00078 00079 #include <PlatformSupport/DOMStringHelper.hpp> 00080 #include <PlatformSupport/PrefixResolver.hpp> 00081 #include <PlatformSupport/XalanLocator.hpp> 00082 00083 00084 00085 #include <XSLT/NamespacesHandler.hpp> 00086 00087 00088 00089 class AttributeList; 00090 class ElemTemplate; 00091 class NamespacesHandler; 00092 class Stylesheet; 00093 class StylesheetConstructionContext; 00094 class StylesheetExecutionContext; 00095 00096 00097 00098 class XALAN_XSLT_EXPORT ElemTemplateElement : public XalanElement, public PrefixResolver 00099 { 00100 public: 00101 00112 ElemTemplateElement( 00113 StylesheetConstructionContext& constructionContext, 00114 Stylesheet& stylesheetTree, 00115 int lineNumber, 00116 int columnNumber, 00117 int xslToken); 00118 00119 virtual 00120 ~ElemTemplateElement(); 00121 00127 virtual const Locator* 00128 getLocator() const; 00129 00140 virtual bool 00141 isAttrOK( 00142 const XalanDOMChar* attrName, 00143 const AttributeList& atts, 00144 int which, 00145 StylesheetConstructionContext& constructionContext) const; 00146 00155 void 00156 processSpaceAttr( 00157 const AttributeList& atts, 00158 int which, 00159 StylesheetConstructionContext& constructionContext); 00160 00170 bool 00171 processSpaceAttr( 00172 const XalanDOMChar* aname, 00173 const AttributeList& atts, 00174 int which, 00175 StylesheetConstructionContext& constructionContext); 00176 00184 static bool 00185 isValidNCName(const XalanDOMString& s); 00186 00193 virtual void 00194 execute(StylesheetExecutionContext& executionContext) const; 00195 00201 virtual void 00202 executeChildren(StylesheetExecutionContext& executionContext) const; 00203 00210 virtual void 00211 executeChildren( 00212 StylesheetExecutionContext& executionContext, 00213 XalanNode* sourceNode) const; 00214 00226 const XalanDOMString& 00227 childrenToString( 00228 StylesheetExecutionContext& executionContext, 00229 XalanDOMString& result) const; 00230 00239 void 00240 childrenToResultAttribute( 00241 StylesheetExecutionContext& executionContext, 00242 const XalanDOMString& theName) const; 00243 00251 void 00252 childrenToResultComment(StylesheetExecutionContext& executionContext) const; 00253 00263 void 00264 childrenToResultPI( 00265 StylesheetExecutionContext& executionContext, 00266 const XalanDOMString& theTarget) const; 00267 00275 int 00276 getXSLToken() const 00277 { 00278 return m_xslToken; 00279 } 00280 00287 int 00288 getLineNumber() const 00289 { 00290 return m_lineNumber; 00291 } 00292 00299 int 00300 getColumnNumber() const 00301 { 00302 return m_columnNumber; 00303 } 00304 00310 virtual bool 00311 isWhitespace() const; 00312 00313 virtual const XalanDOMString& 00314 getElementName() const = 0; 00315 00316 #if defined(XALAN_NO_NAMESPACES) 00317 typedef map<XalanDOMString, 00318 XalanDOMString, 00319 less<XalanDOMString> > StringToStringMapType; 00320 #else 00321 typedef std::map<XalanDOMString, 00322 XalanDOMString> StringToStringMapType; 00323 #endif 00324 00330 const NamespacesHandler& 00331 getNamespacesHandler() const 00332 { 00333 return m_namespacesHandler; 00334 } 00335 00341 const Stylesheet& 00342 getStylesheet() const 00343 { 00344 return m_stylesheet; 00345 } 00346 00350 void 00351 finishedConstruction() 00352 { 00353 m_finishedConstruction = true; 00354 } 00355 00359 virtual void 00360 postConstruction( 00361 StylesheetConstructionContext& constructionContext, 00362 const NamespacesHandler& theParentHandler); 00363 00364 // Type-safe getters/setters... 00365 00371 virtual ElemTemplateElement* 00372 getFirstChildElem() const; 00373 00381 virtual void 00382 setFirstChildElem(ElemTemplateElement* theChild); 00383 00389 virtual ElemTemplateElement* 00390 getLastChildElem() const; 00391 00397 virtual ElemTemplateElement* 00398 getNextSiblingElem() const; 00399 00407 virtual void 00408 setNextSiblingElem(ElemTemplateElement* theSibling); 00409 00415 virtual ElemTemplateElement* 00416 getPreviousSiblingElem() const; 00417 00425 virtual void 00426 setPreviousSiblingElem(ElemTemplateElement* theSibling); 00427 00433 virtual ElemTemplateElement* 00434 getParentNodeElem() const; 00435 00443 virtual void 00444 setParentNodeElem(ElemTemplateElement* theParent); 00445 00453 virtual ElemTemplateElement* 00454 appendChildElem(ElemTemplateElement* newChild); 00455 00456 // Type-safe getters... 00457 00466 virtual ElemTemplateElement* 00467 insertBeforeElem( 00468 ElemTemplateElement* newChild, 00469 ElemTemplateElement* refChild); 00470 00479 virtual ElemTemplateElement* 00480 replaceChildElem( 00481 ElemTemplateElement* newChild, 00482 ElemTemplateElement* oldChild); 00483 00484 // These interfaces are inherited from XalanElement ... 00485 00486 virtual const XalanDOMString& 00487 getNodeName() const; 00488 00489 virtual const XalanDOMString& 00490 getNodeValue() const; 00491 00492 virtual NodeType 00493 getNodeType() const; 00494 00495 virtual XalanNode* 00496 getParentNode() const; 00497 00498 virtual const XalanNodeList* 00499 getChildNodes() const; 00500 00501 virtual XalanNode* 00502 getFirstChild() const; 00503 00504 virtual XalanNode* 00505 getLastChild() const; 00506 00507 virtual XalanNode* 00508 getPreviousSibling() const; 00509 00510 virtual XalanNode* 00511 getNextSibling() const; 00512 00513 virtual const XalanNamedNodeMap* 00514 getAttributes() const; 00515 00516 virtual XalanDocument* 00517 getOwnerDocument() const; 00518 00519 #if defined(XALAN_NO_COVARIANT_RETURN_TYPE) 00520 virtual XalanNode* 00521 #else 00522 virtual ElemTemplateElement* 00523 #endif 00524 cloneNode(bool deep) const; 00525 00526 virtual XalanNode* 00527 insertBefore( 00528 XalanNode* newChild, 00529 XalanNode* refChild); 00530 00531 virtual XalanNode* 00532 replaceChild( 00533 XalanNode* newChild, 00534 XalanNode* oldChild); 00535 00536 virtual XalanNode* 00537 removeChild(XalanNode* oldChild); 00538 00545 virtual XalanNode* 00546 appendChild(XalanNode* newChild); 00547 00548 virtual bool 00549 hasChildNodes() const; 00550 00551 virtual void 00552 setNodeValue(const XalanDOMString& nodeValue); 00553 00554 virtual void 00555 normalize(); 00556 00557 virtual bool 00558 isSupported( 00559 const XalanDOMString& feature, 00560 const XalanDOMString& version) const; 00561 00562 virtual const XalanDOMString& 00563 getNamespaceURI() const; 00564 00565 virtual const XalanDOMString& 00566 getPrefix() const; 00567 00568 virtual const XalanDOMString& 00569 getLocalName() const; 00570 00571 virtual void 00572 setPrefix(const XalanDOMString& prefix); 00573 00574 virtual bool 00575 isIndexed() const; 00576 00577 virtual unsigned long 00578 getIndex() const; 00579 00580 virtual const XalanDOMString& 00581 getTagName() const; 00582 00583 virtual const XalanDOMString& 00584 getAttribute(const XalanDOMString& name) const; 00585 00586 virtual XalanAttr* 00587 getAttributeNode(const XalanDOMString& name) const; 00588 00589 virtual XalanNodeList* 00590 getElementsByTagName(const XalanDOMString& name) const; 00591 00592 virtual void 00593 setAttribute( 00594 const XalanDOMString& name, 00595 const XalanDOMString& value); 00596 00597 virtual XalanAttr* 00598 setAttributeNode(XalanAttr* newAttr); 00599 00600 virtual XalanAttr* 00601 removeAttributeNode(XalanAttr* oldAttr); 00602 00603 virtual void 00604 removeAttribute(const XalanDOMString& name); 00605 00606 virtual const XalanDOMString& 00607 getAttributeNS( 00608 const XalanDOMString& namespaceURI, 00609 const XalanDOMString& localName) const; 00610 00611 virtual void 00612 setAttributeNS( 00613 const XalanDOMString& namespaceURI, 00614 const XalanDOMString& qualifiedName, 00615 const XalanDOMString& value); 00616 00617 virtual void 00618 removeAttributeNS( 00619 const XalanDOMString& namespaceURI, 00620 const XalanDOMString& localName); 00621 00622 virtual XalanAttr* 00623 getAttributeNodeNS( 00624 const XalanDOMString& namespaceURI, 00625 const XalanDOMString& localName) const; 00626 00627 virtual XalanAttr* 00628 setAttributeNodeNS(XalanAttr* newAttr); 00629 00630 virtual XalanNodeList* 00631 getElementsByTagNameNS( 00632 const XalanDOMString& namespaceURI, 00633 const XalanDOMString& localName) const; 00634 00635 00636 // These interfaces are inherited from PrefixResolver... 00637 00638 virtual const XalanDOMString* 00639 getNamespaceForPrefix(const XalanDOMString& prefix) const; 00640 00641 virtual const XalanDOMString& 00642 getURI() const; 00643 00644 00645 // These optimization interfaces are new to ElemTemplateElement... 00646 bool 00647 hasParams() const 00648 { 00649 return m_optimizationFlags & eHasParams ? true : false; 00650 } 00651 00652 bool 00653 hasVariables() const 00654 { 00655 return m_optimizationFlags & eHasVariables ? true : false; 00656 } 00657 00658 bool 00659 hasSingleTextChild() const 00660 { 00661 return m_optimizationFlags & eHasSingleTextChild ? true : false; 00662 } 00663 00664 bool 00665 hasChildren() const 00666 { 00667 return m_firstChild != 0 ? true : false; 00668 } 00669 00670 bool 00671 hasDirectTemplate() const 00672 { 00673 return m_optimizationFlags & eHasDirectTemplate ? true : false; 00674 } 00675 00680 bool 00681 canGenerateAttributes() const 00682 { 00683 return m_optimizationFlags & eCanGenerateAttributes ? true : false; 00684 } 00685 00686 class LocatorProxy : public XalanLocator 00687 { 00688 public: 00689 00690 LocatorProxy(const ElemTemplateElement& theElement); 00691 00692 virtual 00693 ~LocatorProxy(); 00694 00695 virtual const XMLCh* 00696 getPublicId() const; 00697 00698 virtual const XMLCh* 00699 getSystemId() const; 00700 00701 virtual size_type 00702 getLineNumber() const; 00703 00704 virtual size_type 00705 getColumnNumber() const; 00706 00707 private: 00708 00709 // Not implemented... 00710 LocatorProxy(const LocatorProxy&); 00711 00712 LocatorProxy& 00713 operator=(const LocatorProxy&); 00714 00715 bool 00716 operator==(const LocatorProxy&) const; 00717 00718 // data members... 00719 const ElemTemplateElement& m_element; 00720 }; 00721 00722 protected: 00723 00724 void 00725 canGenerateAttributes(bool value) 00726 { 00727 if (value == true) 00728 { 00729 m_optimizationFlags |= eCanGenerateAttributes; 00730 } 00731 else 00732 { 00733 m_optimizationFlags &= ~eCanGenerateAttributes; 00734 } 00735 } 00736 00744 const XalanDOMString* 00745 getNamespaceForPrefixInternal(const XalanDOMString& prefix) const; 00746 00758 bool 00759 transformChild( 00760 StylesheetExecutionContext& executionContext, 00761 const ElemTemplateElement& xslInstruction, 00762 const ElemTemplateElement* theTemplate, 00763 XalanNode* child) const; 00764 00777 virtual bool 00778 childTypeAllowed(int xslToken) const; 00779 00780 bool m_finishedConstruction; 00781 00782 /* 00783 * This object handles all result tree namespace processing. 00784 */ 00785 NamespacesHandler m_namespacesHandler; 00786 00787 static const XalanDOMString s_emptyString; 00788 00789 private: 00790 00799 XalanDOMString& 00800 doChildrenToString( 00801 StylesheetExecutionContext& executionContext, 00802 XalanDOMString& result) const; 00803 00804 Stylesheet& m_stylesheet; 00805 00806 const int m_lineNumber; 00807 const int m_columnNumber; 00808 00809 bool m_defaultSpace; 00810 00811 const int m_xslToken; 00812 00813 ElemTemplateElement* m_parentNode; 00814 ElemTemplateElement* m_nextSibling; 00815 ElemTemplateElement* m_previousSibling; 00816 00817 union 00818 { 00819 ElemTemplateElement* m_firstChild; 00820 const ElemTemplate* m_directTemplate; 00821 }; 00822 00823 XalanNodeListSurrogate m_surrogateChildren; 00824 00825 const XalanDOMString m_baseIndentifier; 00826 00827 enum { eHasParams = 1, 00828 eHasSingleTextChild = 2, 00829 eHasVariables = 4, 00830 eHasDirectTemplate = 8, 00831 eCanGenerateAttributes = 16 }; 00832 00833 unsigned m_optimizationFlags; 00834 00835 LocatorProxy m_locatorProxy; 00836 00837 static const XalanEmptyNamedNodeMap s_fakeAttributes; 00838 00839 // Not implemented... 00840 ElemTemplateElement(const ElemTemplateElement&); 00841 00842 ElemTemplateElement& 00843 operator=(const ElemTemplateElement&); 00844 00845 bool 00846 operator==(const ElemTemplateElement&) const; 00847 }; 00848 00849 00850 00851 #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.4 |
|