00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 1999-2003 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 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 00140 ElemTemplateElement( 00141 Stylesheet& stylesheetTree, 00142 int xslToken, 00143 int lineNumber = XalanLocator::getUnknownValue(), 00144 int columnNumber = XalanLocator::getUnknownValue()); 00145 00146 virtual 00147 ~ElemTemplateElement(); 00148 00154 virtual const LocatorType* 00155 getLocator() const; 00156 00167 virtual bool 00168 isAttrOK( 00169 const XalanDOMChar* attrName, 00170 const AttributeListType& atts, 00171 int which, 00172 StylesheetConstructionContext& constructionContext) const; 00173 00183 bool 00184 processSpaceAttr( 00185 const XalanDOMChar* aname, 00186 const AttributeListType& atts, 00187 int which, 00188 StylesheetConstructionContext& constructionContext); 00189 00197 static bool 00198 isValidNCName(const XalanDOMString& s); 00199 00206 virtual void 00207 execute(StylesheetExecutionContext& executionContext) const; 00208 00214 virtual void 00215 executeChildren(StylesheetExecutionContext& executionContext) const; 00216 00223 virtual void 00224 executeChildren( 00225 StylesheetExecutionContext& executionContext, 00226 XalanNode* sourceNode) const; 00227 00239 const XalanDOMString& 00240 childrenToString( 00241 StylesheetExecutionContext& executionContext, 00242 XalanDOMString& result) const; 00243 00252 void 00253 childrenToResultAttribute( 00254 StylesheetExecutionContext& executionContext, 00255 const XalanDOMString& theName) const; 00256 00264 void 00265 childrenToResultComment(StylesheetExecutionContext& executionContext) const; 00266 00276 void 00277 childrenToResultPI( 00278 StylesheetExecutionContext& executionContext, 00279 const XalanDOMString& theTarget) const; 00280 00288 int 00289 getXSLToken() const 00290 { 00291 return m_xslToken; 00292 } 00293 00299 int 00300 getLineNumber() const 00301 { 00302 return m_lineNumber; 00303 } 00304 00310 int 00311 getColumnNumber() const 00312 { 00313 return m_columnNumber; 00314 } 00315 00321 virtual bool 00322 isWhitespace() const; 00323 00330 virtual const XalanDOMString& 00331 getElementName() const = 0; 00332 00339 virtual const XalanQName& 00340 getNameAttribute() const; 00341 00350 virtual void 00351 addToStylesheet( 00352 StylesheetConstructionContext& constructionContext, 00353 Stylesheet& theStylesheet); 00354 00366 virtual void 00367 processSortElement( 00368 StylesheetConstructionContext& constructionContext, 00369 Stylesheet& theStylesheet, 00370 const AttributeListType& atts, 00371 const LocatorType* locator = 0); 00372 00378 virtual void 00379 setDefaultTemplate(bool value); 00380 00386 const NamespacesHandler& 00387 getNamespacesHandler() const 00388 { 00389 return m_namespacesHandler; 00390 } 00391 00397 const Stylesheet& 00398 getStylesheet() const 00399 { 00400 return m_stylesheet; 00401 } 00402 00408 void 00409 setFinishedConstruction(bool fValue) 00410 { 00411 setFlag(eFinishedConstruction, fValue); 00412 } 00413 00417 bool 00418 getFinishedConstruction() const 00419 { 00420 return getFlag(eFinishedConstruction); 00421 } 00422 00426 virtual void 00427 postConstruction( 00428 StylesheetConstructionContext& constructionContext, 00429 const NamespacesHandler& theParentHandler); 00430 00431 // Type-safe getters/setters... 00432 00438 virtual ElemTemplateElement* 00439 getFirstChildElem() const; 00440 00448 virtual void 00449 setFirstChildElem(ElemTemplateElement* theChild); 00450 00456 virtual ElemTemplateElement* 00457 getLastChildElem() const; 00458 00464 virtual ElemTemplateElement* 00465 getNextSiblingElem() const; 00466 00474 virtual void 00475 setNextSiblingElem(ElemTemplateElement* theSibling); 00476 00482 virtual ElemTemplateElement* 00483 getPreviousSiblingElem() const; 00484 00492 virtual void 00493 setPreviousSiblingElem(ElemTemplateElement* theSibling); 00494 00500 virtual ElemTemplateElement* 00501 getParentNodeElem() const; 00502 00510 virtual void 00511 setParentNodeElem(ElemTemplateElement* theParent); 00512 00520 virtual ElemTemplateElement* 00521 appendChildElem(ElemTemplateElement* newChild); 00522 00523 00524 // These interfaces are inherited from PrefixResolver... 00525 00526 virtual const XalanDOMString* 00527 getNamespaceForPrefix(const XalanDOMString& prefix) const; 00528 00529 virtual const XalanDOMString& 00530 getURI() const; 00531 00532 class LocatorProxy : public XalanLocator 00533 { 00534 public: 00535 00536 LocatorProxy(const ElemTemplateElement& theElement); 00537 00538 virtual 00539 ~LocatorProxy(); 00540 00541 virtual const XMLCh* 00542 getPublicId() const; 00543 00544 virtual const XMLCh* 00545 getSystemId() const; 00546 00547 virtual size_type 00548 getLineNumber() const; 00549 00550 virtual size_type 00551 getColumnNumber() const; 00552 00553 private: 00554 00555 // Not implemented... 00556 LocatorProxy(const LocatorProxy&); 00557 00558 LocatorProxy& 00559 operator=(const LocatorProxy&); 00560 00561 bool 00562 operator==(const LocatorProxy&) const; 00563 00564 // data members... 00565 const ElemTemplateElement& m_element; 00566 }; 00567 00568 bool 00569 hasParams() const 00570 { 00571 return getFlag(eHasParams); 00572 } 00573 00574 bool 00575 hasVariables() const 00576 { 00577 return getFlag(eHasVariables); 00578 } 00579 00580 bool 00581 hasSingleTextChild() const 00582 { 00583 return getFlag(eHasSingleTextChild); 00584 } 00585 00586 bool 00587 hasChildren() const 00588 { 00589 return m_firstChild != 0 ? true : false; 00590 } 00591 00592 bool 00593 hasDirectTemplate() const 00594 { 00595 return getFlag(eHasDirectTemplate); 00596 } 00597 00598 bool 00599 canGenerateAttributes() const 00600 { 00601 return getFlag(eCanGenerateAttributes); 00602 } 00603 00604 bool 00605 isDefaultTemplate() const 00606 { 00607 return getFlag(eDefaultTemplate); 00608 } 00609 00610 protected: 00611 00612 void 00613 canGenerateAttributes(bool value) 00614 { 00615 setFlag(eCanGenerateAttributes, value); 00616 } 00617 00618 void 00619 hasPrefix(bool value) 00620 { 00621 setFlag(eHasPrefix, value); 00622 } 00623 00624 bool 00625 hasPrefix() const 00626 { 00627 return getFlag(eHasPrefix); 00628 } 00629 00630 void 00631 preserveSpace(bool value) 00632 { 00633 setFlag(eSpacePreserve, value); 00634 } 00635 00636 bool 00637 preserveSpace() const 00638 { 00639 return getFlag(eSpacePreserve); 00640 } 00641 00642 void 00643 disableOutputEscaping(bool value) 00644 { 00645 setFlag(eDisableOutputEscaping, value); 00646 } 00647 00648 bool 00649 disableOutputEscaping() const 00650 { 00651 return getFlag(eDisableOutputEscaping); 00652 } 00653 00663 bool 00664 processPrefixControl( 00665 StylesheetConstructionContext& constructionContext, 00666 const Stylesheet& stylesheetTree, 00667 const XalanDOMString& localName, 00668 const XalanDOMChar* attrValue); 00669 00677 const XalanDOMString* 00678 getNamespaceForPrefixInternal(const XalanDOMString& prefix) const; 00679 00689 virtual void 00690 transformChild( 00691 StylesheetExecutionContext& executionContext, 00692 const ElemTemplateElement& xslInstruction, 00693 const ElemTemplateElement* theTemplate, 00694 XalanNode* child) const; 00695 00706 virtual void 00707 transformChild( 00708 StylesheetExecutionContext& executionContext, 00709 const ElemTemplateElement& xslInstruction, 00710 const ElemTemplateElement* theTemplate, 00711 XalanNode* child, 00712 XalanNode::NodeType nodeType) const; 00713 00726 virtual bool 00727 childTypeAllowed(int xslToken) const; 00728 00735 virtual void 00736 namespacesPostConstruction( 00737 StylesheetConstructionContext& constructionContext, 00738 const NamespacesHandler& theParentHandler, 00739 NamespacesHandler& theHandler); 00740 00741 static const XalanDOMString s_emptyString; 00742 00743 const NamespacesHandler& 00744 getNamespaces() const 00745 { 00746 return m_namespacesHandler; 00747 } 00748 00749 private: 00750 00751 enum eFlags 00752 { 00753 eHasParams = 1, 00754 eHasSingleTextChild = 2, 00755 eHasVariables = 4, 00756 eHasDirectTemplate = 8, 00757 eCanGenerateAttributes = 16, 00758 eDefaultTemplate = 32, 00759 eSpacePreserve = 64, 00760 eFinishedConstruction = 128, 00761 eHasPrefix = 256, 00762 eDisableOutputEscaping = 512 00763 }; 00764 00765 bool 00766 getFlag(eFlags theFlag) const 00767 { 00768 return m_flags & theFlag ? true : false; 00769 } 00770 00771 void 00772 setFlag( 00773 eFlags theFlag, 00774 bool theValue) 00775 { 00776 if (theValue == true) 00777 { 00778 m_flags |= theFlag; 00779 } 00780 else 00781 { 00782 m_flags &= ~theFlag; 00783 } 00784 } 00785 00794 XalanDOMString& 00795 doChildrenToString( 00796 StylesheetExecutionContext& executionContext, 00797 XalanDOMString& result) const; 00798 00799 Stylesheet& m_stylesheet; 00800 00801 /* 00802 * This object handles all result tree namespace processing. 00803 */ 00804 NamespacesHandler m_namespacesHandler; 00805 00806 const int m_lineNumber; 00807 const int m_columnNumber; 00808 00809 const int m_xslToken; 00810 00811 ElemTemplateElement* m_parentNode; 00812 ElemTemplateElement* m_nextSibling; 00813 ElemTemplateElement* m_previousSibling; 00814 00815 union 00816 { 00817 ElemTemplateElement* m_firstChild; 00818 const ElemTemplate* m_directTemplate; 00819 const ElemTextLiteral* m_textLiteralChild; 00820 }; 00821 00822 const XalanDOMString& m_baseIndentifier; 00823 00824 LocatorProxy m_locatorProxy; 00825 00826 unsigned short m_flags; 00827 00828 static const XalanQNameByReference s_emptyQName; 00829 00830 // Not implemented... 00831 ElemTemplateElement(const ElemTemplateElement&); 00832 00833 ElemTemplateElement& 00834 operator=(const ElemTemplateElement&); 00835 00836 bool 00837 operator==(const ElemTemplateElement&) const; 00838 }; 00839 00840 00841 00842 XALAN_CPP_NAMESPACE_END 00843 00844 00845 00846 #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.6 |
|