00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one 00003 * or more contributor license agreements. See the NOTICE file 00004 * distributed with this work for additional information 00005 * regarding copyright ownership. The ASF licenses this file 00006 * to you under the Apache License, Version 2.0 (the "License"); 00007 * you may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 * See the License for the specific language governing permissions and 00016 * limitations under the License. 00017 */ 00018 #if !defined(XALAN_ELEMTEMPLATEELEMENT_HEADER_GUARD) 00019 #define XALAN_ELEMTEMPLATEELEMENT_HEADER_GUARD 00020 00021 00022 00023 // Base include file. Must be first. 00024 #include <xalanc/XSLT/XSLTDefinitions.hpp> 00025 00026 00027 00028 #include <xalanc/XalanDOM/XalanDOMString.hpp> 00029 #include <xalanc/XalanDOM/XalanNode.hpp> 00030 00031 00032 00033 #include <xalanc/PlatformSupport/DOMStringHelper.hpp> 00034 #include <xalanc/PlatformSupport/PrefixResolver.hpp> 00035 #include <xalanc/PlatformSupport/XalanLocator.hpp> 00036 00037 00038 00039 #include <xalanc/XPath/XalanQNameByReference.hpp> 00040 00041 00042 00043 #include <xalanc/XSLT/NamespacesHandler.hpp> 00044 00045 00046 00047 #include "LocalMsgIndex.hpp" 00048 00049 00050 00051 XALAN_DECLARE_XERCES_CLASS(AttributeList) 00052 XALAN_DECLARE_XERCES_CLASS(Locator) 00053 00054 00055 00056 XALAN_CPP_NAMESPACE_BEGIN 00057 00058 00059 00060 typedef XERCES_CPP_NAMESPACE_QUALIFIER AttributeList AttributeListType; 00061 typedef XERCES_CPP_NAMESPACE_QUALIFIER Locator LocatorType; 00062 00063 00064 XALAN_USING_XERCES(AttributeList) 00065 XALAN_USING_XERCES(Locator) 00066 class ElemTemplate; 00067 class ElemTextLiteral; 00068 class NamespacesHandler; 00069 class Stylesheet; 00070 class StylesheetConstructionContext; 00071 class StylesheetExecutionContext; 00072 class XPath; 00073 00074 00075 00076 class XALAN_XSLT_EXPORT ElemTemplateElement : public PrefixResolver 00077 { 00078 00079 public: 00080 00081 /** 00082 * Construct a template element instance. 00083 * 00084 * @param constructionContext context when object constructed 00085 * @param stylesheetTree owning stylesheet 00086 * @param lineNumber line in the XSLT file where the element occurs 00087 * @param columnNumber column index in the XSLT file where the 00088 * element occurs 00089 * @param xslToken an integer representing the type of instance. 00090 */ 00091 ElemTemplateElement( 00092 StylesheetConstructionContext& constructionContext, 00093 Stylesheet& stylesheetTree, 00094 XalanFileLoc lineNumber, 00095 XalanFileLoc columnNumber, 00096 int xslToken); 00097 00098 /** 00099 * Special constructor used by dummy elements which do not exist in the 00100 * final stylesheet. 00101 * 00102 * @param constructionContext context when object constructed 00103 * @param stylesheetTree owning stylesheet 00104 * @param baseURI The base URI of the XSLT file where the element occurs. 00105 * @param lineNumber line in the XSLT file where the element occurs 00106 * @param columnNumber column index in the XSLT file where the 00107 * element occurs 00108 * @param xslToken an integer representing the type of instance. 00109 */ 00110 ElemTemplateElement( 00111 StylesheetConstructionContext& constructionContext, 00112 Stylesheet& stylesheetTree, 00113 int xslToken, 00114 const XalanDOMString& baseURI = XalanDOMString(XalanMemMgrs::getDummyMemMgr()), 00115 XalanFileLoc lineNumber = XalanLocator::getUnknownValue(), 00116 XalanFileLoc columnNumber = XalanLocator::getUnknownValue()); 00117 00118 virtual 00119 ~ElemTemplateElement(); 00120 00121 /** 00122 * Get the Locator for the node. This may return 0. 00123 * 00124 * @return The Locator for the node. 00125 */ 00126 virtual const Locator* 00127 getLocator() const; 00128 00129 /** 00130 * See if this is a xmlns attribute or in a non-XSLT. 00131 * 00132 * @param attrName qualified name of attribute 00133 * @param atts attribute list where the element comes from (not used at 00134 * this time) 00135 * @param which index into the attribute list (not used at this time) 00136 * @param constructionContext The current construction context 00137 * @return true if this is a namespace name 00138 */ 00139 virtual bool 00140 isAttrOK( 00141 const XalanDOMChar* attrName, 00142 const AttributeListType& atts, 00143 XalanSize_t which, 00144 StylesheetConstructionContext& constructionContext) const; 00145 00146 /** 00147 * Tell whether or not this is a xml:space attribute and, if so, process it. 00148 * 00149 * @param elementName name of the element with the attribute 00150 * @param aname name of the attribute in question 00151 * @param atts attribute list that owns the attribute 00152 * @param which index of the attribute into the attribute list 00153 * @param constructionContext The current construction context 00154 * @return true if this is a xml:space attribute 00155 */ 00156 bool 00157 processSpaceAttr( 00158 const XalanDOMChar* elementName, 00159 const XalanDOMChar* aname, 00160 const AttributeListType& atts, 00161 XalanSize_t which, 00162 StylesheetConstructionContext& constructionContext); 00163 00164 /** 00165 * Validate that the string is an NCName. 00166 * 00167 * @param s name in question 00168 * @return true if the string is a valid NCName according to XML rules 00169 * @see http://www.w3.org/TR/REC-xml-names#NT-NCName 00170 */ 00171 static bool 00172 isValidNCName(const XalanDOMString& s); 00173 00174 #if !defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION) 00175 00176 /** 00177 * Completes "pre-processing" before any sub-elements are invoked 00178 * (i.e. children, attribute sets and templates). If there are 00179 * no sub-elements it executes the primary function of the element. 00180 * 00181 * @param executionContext context to execute this element 00182 */ 00183 virtual const ElemTemplateElement* 00184 startElement(StylesheetExecutionContext& executionContext) const; 00185 00186 /** 00187 * Completes "post-processing" afer any sub-elements are invoked 00188 * (i.e. children, attribute sets and templates). If there are 00189 * no sub-elements it does nothing 00190 * 00191 * @param executionContext context to execute this element 00192 */ 00193 virtual void 00194 endElement(StylesheetExecutionContext& executionContext) const; 00195 00196 /** 00197 * Execute the element. 00198 * 00199 * @param execute context to execute this element 00200 */ 00201 virtual void 00202 execute(StylesheetExecutionContext& executionContext) const; 00203 00204 /** 00205 * Execute the children of this element. 00206 * 00207 * @param execute context to execute this element 00208 */ 00209 virtual void 00210 executeChildren(StylesheetExecutionContext& executionContext) const; 00211 00212 /** 00213 * Returns the element that invoked this element. 00214 * @returns element that invoked this element. 00215 */ 00216 virtual const ElemTemplateElement* 00217 getInvoker(StylesheetExecutionContext& executionContext) const; 00218 00219 #else 00220 00221 /** 00222 * Execute the element's primary function. Subclasses of this function may 00223 * recursively execute down the element tree. 00224 * 00225 * @param executionContext The current execution context 00226 */ 00227 virtual void 00228 execute(StylesheetExecutionContext& executionContext) const; 00229 00230 /** 00231 * Process the children of a template. 00232 * 00233 * @param processor XSLT processor instance 00234 */ 00235 virtual void 00236 executeChildren(StylesheetExecutionContext& executionContext) const; 00237 00238 /** 00239 * Set the current node and process the children of a template. 00240 * 00241 * @param processor XSLT processor instance 00242 * @param sourceNode current node 00243 */ 00244 virtual void 00245 executeChildren( 00246 StylesheetExecutionContext& executionContext, 00247 XalanNode* sourceNode) const; 00248 00249 /** 00250 * Take the contents of a template element, process it, and 00251 * convert it to a string. Returns a const reference to 00252 * the resulting string value. Note that this may _not_ be 00253 * the XalanDOMString instance passed in, if an optimization 00254 * is available to return a pre-existing string. 00255 * 00256 * @param executionContext The current execution context 00257 * @param result result of executing the elements children 00258 * @result a reference to a string containing the result. 00259 */ 00260 const XalanDOMString& 00261 childrenToString( 00262 StylesheetExecutionContext& executionContext, 00263 XalanDOMString& result) const; 00264 00265 /** 00266 * Take the contents of a template element, process it, and 00267 * convert it to a string. Then, add an attribute to the 00268 * result tree using the provided name and the string value. 00269 * 00270 * @param executionContext The current execution context 00271 * @param theName The name for the result attribute 00272 */ 00273 void 00274 childrenToResultAttribute( 00275 StylesheetExecutionContext& executionContext, 00276 const XalanDOMString& theName) const; 00277 00278 /** 00279 * Take the contents of a template element, process it, and 00280 * convert it to a string. Then, add a comment to the 00281 * result tree using the string value. 00282 * 00283 * @param executionContext The current execution context 00284 */ 00285 void 00286 childrenToResultComment(StylesheetExecutionContext& executionContext) const; 00287 00288 /** 00289 * Take the contents of a template element, process it, and 00290 * convert it to a string. Then, add a processing instruction 00291 * to the result tree using the string value, and the provided 00292 * target. 00293 * 00294 * @param executionContext The current execution context 00295 * @param theName The name for the result attribute 00296 */ 00297 void 00298 childrenToResultPI( 00299 StylesheetExecutionContext& executionContext, 00300 const XalanDOMString& theTarget) const; 00301 00302 /** 00303 * Get an integer representation of the element type. 00304 * 00305 * @return integer representation of the element, defined in the Constants 00306 * class 00307 * @see class Constants 00308 */ 00309 #endif 00310 00311 int 00312 getXSLToken() const 00313 { 00314 return m_xslToken; 00315 } 00316 00317 /** 00318 * Tell if the element will generate text which is XML whitespace. 00319 * 00320 * @return true if the text is pure whitespace 00321 */ 00322 virtual bool 00323 isWhitespace() const; 00324 00325 /** 00326 * Get a string for the name of the element. Useful for debugging purposes, 00327 * and error reporting. 00328 * 00329 * @return A string containing the name of the element. 00330 */ 00331 virtual const XalanDOMString& 00332 getElementName() const = 0; 00333 00334 /** 00335 * Get the QName associated with any name attribute of this element. 00336 * If the element has no name attribute, this will be an empty QName. 00337 * 00338 * @return A string containing the name of the element. 00339 */ 00340 virtual const XalanQName& 00341 getNameAttribute() const; 00342 00343 /** 00344 * Called during compilation when an instance is not parented by 00345 * another element, and thus, is a child of the stylesheet.. 00346 * 00347 * @param constructionContext The current construction context 00348 * @param theStylesheet The owning stylesheet 00349 * @return nothing 00350 */ 00351 virtual void 00352 addToStylesheet( 00353 StylesheetConstructionContext& constructionContext, 00354 Stylesheet& theStylesheet); 00355 00356 /** 00357 * Called during compilation to process xsl:sort elements in 00358 * the stylesheet. 00359 * 00360 * @param constructionContext The current construction context 00361 * @param theStylesheet The owning stylesheet 00362 * @param atts The list of attributes for the sort element 00363 * @param locator A Locator instance for error reporting, if available. 00364 * 00365 * @return nothing 00366 */ 00367 virtual void 00368 processSortElement( 00369 StylesheetConstructionContext& constructionContext, 00370 Stylesheet& theStylesheet, 00371 const AttributeListType& atts, 00372 const Locator* locator = 0); 00373 00374 /** 00375 * Sets a flag indicating this is the default template 00376 * 00377 * @param value The value of flag. 00378 */ 00379 virtual void 00380 setDefaultTemplate(bool value); 00381 00382 /** 00383 * Get the namespaces handler for this element. 00384 * 00385 * @return The element's NamespacesHandler instance. 00386 */ 00387 const NamespacesHandler& 00388 getNamespacesHandler() const 00389 { 00390 return m_namespacesHandler; 00391 } 00392 00393 /** 00394 * Retrieve the stylesheet from which this element comes 00395 * 00396 * @return reference to source stylesheet 00397 */ 00398 const Stylesheet& 00399 getStylesheet() const 00400 { 00401 return m_stylesheet; 00402 } 00403 00404 /** 00405 * Set the flag indicating construction of the element is completed. 00406 * 00407 * @param fValue The value to set 00408 */ 00409 void 00410 setFinishedConstruction(bool fValue) 00411 { 00412 setFlag(eFinishedConstruction, fValue); 00413 } 00414 00415 /** 00416 * Get the flag indicating construction of the element is completed. 00417 */ 00418 bool 00419 getFinishedConstruction() const 00420 { 00421 return getFlag(eFinishedConstruction); 00422 } 00423 00424 /** 00425 * Called after construction is completed. 00426 */ 00427 virtual void 00428 postConstruction( 00429 StylesheetConstructionContext& constructionContext, 00430 const NamespacesHandler& theParentHandler); 00431 00432 // Type-safe getters/setters... 00433 00434 /** 00435 * Get the first child. 00436 * 00437 * @return first child node of this node 00438 */ 00439 virtual ElemTemplateElement* 00440 getFirstChildElem() const; 00441 00442 #if !defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION) 00443 /** 00444 * Method to initiate the execution of the element's children. 00445 * 00446 * @param executionContext context to execute this element 00447 * @returns the first child element to execute 00448 */ 00449 virtual const ElemTemplateElement* 00450 beginExecuteChildren( 00451 StylesheetExecutionContext& executionContext) const; 00452 00453 00454 /** 00455 * Method to indicate the execution of the element's children 00456 * is complete 00457 * 00458 * @param executionContext context to execute this element 00459 */ 00460 virtual void 00461 endExecuteChildren( 00462 StylesheetExecutionContext& executionContext) const; 00463 00464 /** 00465 * Method to initiate output from the children 00466 * to a string. 00467 * 00468 * @param executionContext context to execute this element 00469 * @param result string to contain the final result 00470 * @returns the first child element to execute 00471 */ 00472 const ElemTemplateElement* 00473 beginChildrenToString( 00474 StylesheetExecutionContext& executionContext, 00475 XalanDOMString& result) const; 00476 00477 00478 /** 00479 * Method to indicate string output from the children is 00480 * complete. 00481 * 00482 * @param executionContext context to execute this element 00483 */ 00484 void 00485 endChildrenToString( 00486 StylesheetExecutionContext& executionContext) const; 00487 #endif 00488 00489 00490 /** 00491 * Set the first child. 00492 * 00493 * theChild - the new value for the first child. 00494 * 00495 * @return nothing 00496 */ 00497 virtual void 00498 setFirstChildElem(ElemTemplateElement* theChild); 00499 00500 /** 00501 * Get the last child. 00502 * 00503 * @return last child node of this node 00504 */ 00505 virtual ElemTemplateElement* 00506 getLastChildElem() const; 00507 00508 /** 00509 * Get the next sibling. 00510 * 00511 * @return next sibling node of this node 00512 */ 00513 virtual ElemTemplateElement* 00514 getNextSiblingElem() const; 00515 00516 #if !defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION) 00517 00518 /** 00519 * Returns the next sub-element 00520 *(i.e. children, attribute-sets, templates) to execute. 00521 * 00522 * @param executionContext context to execute element 00523 * @param currentElem the last sub-element to be executed 00524 * @returns next sub-element to execute, 0 only if no more sub-elements to execute 00525 */ 00526 virtual const ElemTemplateElement* 00527 getNextChildElemToExecute( 00528 StylesheetExecutionContext& executionContext, 00529 const ElemTemplateElement* currentElem) const; 00530 00531 /** 00532 * Returns the first sub-element 00533 *(i.e. children, attribute-sets, templates) to execute. 00534 * 00535 * @param executionContext context to execute element 00536 * @returns first sub-element to execute, 0 only if no sub-elements to execute 00537 */ 00538 virtual const ElemTemplateElement* 00539 getFirstChildElemToExecute( 00540 StylesheetExecutionContext& executionContext) const; 00541 00542 /** 00543 * Filters sub-elements that should be executed 00544 * 00545 * @param executionContext context to execute element 00546 * @param element the element to be executed 00547 * @returns true if element should be executed, false otherwise 00548 */ 00549 virtual bool executeChildElement( 00550 StylesheetExecutionContext& executionContext, 00551 const ElemTemplateElement* element) const; 00552 #endif 00553 00554 /** 00555 * Set the next sibling. 00556 * 00557 * theSibling - the new value for the next sibling. 00558 * 00559 * @return nothing 00560 */ 00561 virtual void 00562 setNextSiblingElem(ElemTemplateElement* theSibling); 00563 00564 /** 00565 * Get the previous sibling. 00566 * 00567 * @return previous sibling node of this node 00568 */ 00569 virtual ElemTemplateElement* 00570 getPreviousSiblingElem() const; 00571 00572 /** 00573 * Set the previous sibling. 00574 * 00575 * theSibling - the new value for the previous sibling. 00576 * 00577 * @return nothing 00578 */ 00579 virtual void 00580 setPreviousSiblingElem(ElemTemplateElement* theSibling); 00581 00582 /** 00583 * Get the parent node. 00584 * 00585 * @return parent node of this node 00586 */ 00587 virtual ElemTemplateElement* 00588 getParentNodeElem() const; 00589 00590 /** 00591 * Set the parent node. 00592 * 00593 * theParent - the new value for the parent. 00594 * 00595 * @return nothing 00596 */ 00597 virtual void 00598 setParentNodeElem(ElemTemplateElement* theParent); 00599 00600 /** 00601 * Append a child. 00602 * 00603 * theParent - the new value for the parent. 00604 * 00605 * @return nothing 00606 */ 00607 virtual ElemTemplateElement* 00608 appendChildElem(ElemTemplateElement* newChild); 00609 00610 /** 00611 * Get XPath pattern/expression of one of the element atribute 00612 * 00613 * @index number of the attribute. If an attribute has more 00614 * then one attribute with pattern/expression,the order of 00615 * the returned expressions are undefined 00616 * 00617 * @return pointer or null 00618 */ 00619 virtual const XPath* 00620 getXPath(XalanSize_t index) const; 00621 00622 // These interfaces are inherited from PrefixResolver... 00623 00624 virtual const XalanDOMString* 00625 getNamespaceForPrefix(const XalanDOMString& prefix) const; 00626 00627 virtual const XalanDOMString& 00628 getURI() const; 00629 00630 // A class that implements the XalanLocator 00631 // abstract base class. ElemTemplateElement 00632 // uses this class to provide locator information. 00633 class LocatorProxy : public XalanLocator 00634 { 00635 public: 00636 00637 LocatorProxy( 00638 XalanFileLoc theLineNumber, 00639 XalanFileLoc theColumnNumber, 00640 const XalanDOMString& theURI); 00641 00642 virtual 00643 ~LocatorProxy(); 00644 00645 virtual const XMLCh* 00646 getPublicId() const; 00647 00648 virtual const XMLCh* 00649 getSystemId() const; 00650 00651 virtual XalanFileLoc 00652 getLineNumber() const; 00653 00654 virtual XalanFileLoc 00655 getColumnNumber() const; 00656 00657 const XalanDOMString& 00658 getURI() const 00659 { 00660 return m_uri; 00661 } 00662 00663 private: 00664 00665 // Not implemented... 00666 LocatorProxy(const LocatorProxy&); 00667 00668 LocatorProxy& 00669 operator=(const LocatorProxy&); 00670 00671 bool 00672 operator==(const LocatorProxy&) const; 00673 00674 // data members... 00675 const XalanFileLoc m_lineNumber; 00676 00677 const XalanFileLoc m_columnNumber; 00678 00679 const XalanDOMString& m_uri; 00680 }; 00681 00682 00683 XalanFileLoc 00684 getLineNumber() const 00685 { 00686 return m_locatorProxy.getLineNumber(); 00687 } 00688 00689 XalanFileLoc 00690 getColumnNumber() const 00691 { 00692 return m_locatorProxy.getColumnNumber(); 00693 } 00694 00695 bool 00696 hasParams() const 00697 { 00698 return getFlag(eHasParams); 00699 } 00700 00701 bool 00702 hasVariables() const 00703 { 00704 return getFlag(eHasVariables); 00705 } 00706 00707 bool 00708 hasSingleTextChild() const 00709 { 00710 return getFlag(eHasSingleTextChild); 00711 } 00712 00713 bool 00714 hasChildren() const 00715 { 00716 return m_firstChild != 0 ? true : false; 00717 } 00718 00719 bool 00720 hasDirectTemplate() const 00721 { 00722 return getFlag(eHasDirectTemplate); 00723 } 00724 00725 bool 00726 canGenerateAttributes() const 00727 { 00728 return getFlag(eCanGenerateAttributes); 00729 } 00730 00731 bool 00732 isDefaultTemplate() const 00733 { 00734 return getFlag(eDefaultTemplate); 00735 } 00736 00737 protected: 00738 00739 void 00740 canGenerateAttributes(bool value) 00741 { 00742 setFlag(eCanGenerateAttributes, value); 00743 } 00744 00745 void 00746 hasPrefix(bool value) 00747 { 00748 setFlag(eHasPrefix, value); 00749 } 00750 00751 bool 00752 hasPrefix() const 00753 { 00754 return getFlag(eHasPrefix); 00755 } 00756 00757 void 00758 preserveSpace(bool value) 00759 { 00760 setFlag(eSpacePreserve, value); 00761 } 00762 00763 bool 00764 preserveSpace() const 00765 { 00766 return getFlag(eSpacePreserve); 00767 } 00768 00769 void 00770 disableOutputEscaping(bool value) 00771 { 00772 setFlag(eDisableOutputEscaping, value); 00773 } 00774 00775 bool 00776 disableOutputEscaping() const 00777 { 00778 return getFlag(eDisableOutputEscaping); 00779 } 00780 00781 /** 00782 * Process the exclude-result-prefixes or the extension-element-prefixes 00783 * attributes, for the purpose of prefix exclusion. 00784 * 00785 * @param constructionContext context when object consructed 00786 * @param stylesheetTree The current Stylesheet object. 00787 * @param localName The local name of the attribute. 00788 * @param attrValue The value of the attribute. 00789 */ 00790 bool 00791 processPrefixControl( 00792 StylesheetConstructionContext& constructionContext, 00793 const Stylesheet& stylesheetTree, 00794 const XalanDOMString& localName, 00795 const XalanDOMChar* attrValue); 00796 00797 /** 00798 * Get the namespace for a given prefix. 00799 * 00800 * @param prefix The prefix to search for 00801 * @param fExists If not null, set to true if the namespace was defined. 00802 * @return The namespace string. 00803 */ 00804 const XalanDOMString* 00805 getNamespaceForPrefixInternal(const XalanDOMString& prefix) const; 00806 00807 #if !defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION) 00808 /** 00809 * Given an element, find the corresponding 00810 * template. 00811 * 00812 * @param executionContext The current execution context 00813 * @param xslInstruction The calling element 00814 * @param template The template to use if xsl:for-each, or null. 00815 * @param child The source context node. 00816 * @returns matching template if any. Returns 0 if no matching template or corresponds to a default rule. 00817 */ 00818 virtual const ElemTemplateElement* 00819 findTemplateToTransformChild( 00820 StylesheetExecutionContext& executionContext, 00821 const ElemTemplateElement& xslInstruction, 00822 const ElemTemplateElement* theTemplate, 00823 XalanNode* child) const; 00824 00825 /** 00826 * Given an element, find the corresponding 00827 * template. 00828 * 00829 * @param executionContext The current execution context 00830 * @param xslInstruction The calling element 00831 * @param template The template to use if xsl:for-each, or null. 00832 * @param child The source context node. 00833 * @param nodeType The type of child. 00834 * @returns matching template if any. Returns 0 if no matching template or corresponds to a default rule. 00835 */ 00836 virtual const ElemTemplateElement* 00837 findTemplateToTransformChild( 00838 StylesheetExecutionContext& executionContext, 00839 const ElemTemplateElement& xslInstruction, 00840 const ElemTemplateElement* theTemplate, 00841 XalanNode* child, 00842 XalanNode::NodeType nodeType) const; 00843 #else 00844 /** 00845 * Given an element, find the corresponding 00846 * template and process the contents. 00847 * 00848 * @param executionContext The current execution context 00849 * @param xslInstruction The calling element 00850 * @param template The template to use if xsl:for-each, or null. 00851 * @param child The source context node. 00852 */ 00853 virtual void 00854 transformChild( 00855 StylesheetExecutionContext& executionContext, 00856 const ElemTemplateElement& xslInstruction, 00857 const ElemTemplateElement* theTemplate, 00858 XalanNode* child) const; 00859 00860 /** 00861 * Given an element, find the corresponding 00862 * template and process the contents. 00863 * 00864 * @param executionContext The current execution context 00865 * @param xslInstruction The calling element 00866 * @param template The template to use if xsl:for-each, or null. 00867 * @param child The source context node. 00868 * @param nodeType The type of child. 00869 */ 00870 virtual void 00871 transformChild( 00872 StylesheetExecutionContext& executionContext, 00873 const ElemTemplateElement& xslInstruction, 00874 const ElemTemplateElement* theTemplate, 00875 XalanNode* child, 00876 XalanNode::NodeType nodeType) const; 00877 #endif 00878 00879 /** 00880 * Given an xsl token type, determine whether or not a child 00881 * of that type is allowed. This is so derived types can 00882 * determine whether a particular type of child is allowed for 00883 * the instance. It is called from appendChildElem(). 00884 * 00885 * The default is to allow no types (no children) 00886 * 00887 * @param xslToken The xsl token value of the child. 00888 * 00889 * @return true if the child is allowed, or false if not. 00890 */ 00891 virtual bool 00892 childTypeAllowed(int xslToken) const; 00893 00894 /** 00895 * Called after construction is completed. This is a hook for 00896 * deriving classes to handle post-construction with the 00897 * instances HamespaceHandler instance, which is otherwise only 00898 * available through a const accessor. 00899 */ 00900 virtual void 00901 namespacesPostConstruction( 00902 StylesheetConstructionContext& constructionContext, 00903 const NamespacesHandler& theParentHandler, 00904 NamespacesHandler& theHandler); 00905 00906 const NamespacesHandler& 00907 getNamespaces() const 00908 { 00909 return m_namespacesHandler; 00910 } 00911 00912 /** 00913 * A convenience function for loading a message 00914 * and reporting an error through the provided 00915 * StylesheetExecutionContext instance. 00916 * 00917 * @param theContext The StylesheetExecutionContext to use 00918 * @param theCode The code of the message 00919 */ 00920 void 00921 error( 00922 StylesheetExecutionContext& theContext, 00923 XalanMessages::Codes theCode) const; 00924 00925 /** 00926 * A convenience function for loading a message 00927 * and reporting an error through the provided 00928 * StylesheetExecutionContext instance. 00929 * 00930 * @param theContext The StylesheetExecutionContext to use 00931 * @param theCode The code of the message 00932 * @param theToken The substitution token for the message 00933 */ 00934 void 00935 error( 00936 StylesheetExecutionContext& theContext, 00937 XalanMessages::Codes theCode, 00938 const XalanDOMString& theToken) const; 00939 00940 /** 00941 * A convenience function for loading a message 00942 * and reporting an error through the provided 00943 * StylesheetExecutionContext instance. 00944 * 00945 * @param theContext The StylesheetExecutionContext to use 00946 * @param theCode The code of the message 00947 * @param theLocator The Locator instance to use, if any 00948 */ 00949 void 00950 error( 00951 StylesheetExecutionContext& theContext, 00952 XalanMessages::Codes theCode, 00953 const Locator* theLocator) const; 00954 00955 /** 00956 * A convenience function for loading a message 00957 * and reporting a warning through the provided 00958 * StylesheetExecutionContext instance. 00959 * 00960 * @param theContext The StylesheetExecutionContext to use 00961 * @param theCode The code of the message 00962 */ 00963 void 00964 warn( 00965 StylesheetExecutionContext& theContext, 00966 XalanMessages::Codes theCode) const; 00967 00968 /** 00969 * A convenience function for loading a message 00970 * and reporting a warning through the provided 00971 * StylesheetExecutionContext instance. 00972 * 00973 * @param theContext The StylesheetExecutionContext to use 00974 * @param theCode The code of the message 00975 * @param theToken The substitution token for the message 00976 */ 00977 void 00978 warn( 00979 StylesheetExecutionContext& theContext, 00980 XalanMessages::Codes theCode, 00981 const XalanDOMString& theToken) const; 00982 00983 /** 00984 * A convenience function for loading a message 00985 * and reporting a warning through the provided 00986 * StylesheetExecutionContext instance. 00987 * 00988 * @param theContext The StylesheetExecutionContext to use 00989 * @param theCode The code of the message 00990 * @param theLocator The Locator instance to use, if any 00991 */ 00992 void 00993 warn( 00994 StylesheetExecutionContext& theContext, 00995 XalanMessages::Codes theCode, 00996 const Locator* theLocator) const; 00997 00998 /** 00999 * A convenience function for loading a message 01000 * and reporting an error through the provided 01001 * StylesheetConstructionContext instance. 01002 * 01003 * @param theContext The StylesheetConstructionContext to use 01004 * @param theCode The code of the message 01005 */ 01006 void 01007 error( 01008 StylesheetConstructionContext& theContext, 01009 XalanMessages::Codes theCode); 01010 01011 /** 01012 * A convenience function for loading a message 01013 * and reporting an error through the provided 01014 * StylesheetConstructionContext instance. 01015 * 01016 * @param theContext The StylesheetConstructionContext to use 01017 * @param theCode The code of the message 01018 * @param theToken The substitution token for the message 01019 * @param theLocator The Locator instance to use, if any 01020 */ 01021 void 01022 error( 01023 StylesheetConstructionContext& theContext, 01024 XalanMessages::Codes theCode, 01025 const XalanDOMString& theToken); 01026 01027 /** 01028 * A convenience function for loading a message 01029 * and reporting an error through the provided 01030 * StylesheetConstructionContext instance. 01031 * 01032 * @param theContext The StylesheetConstructionContext to use 01033 * @param theCode The code of the message 01034 * @param theToken The substitution token for the message 01035 * @param theLocator The Locator instance to use, if any 01036 */ 01037 void 01038 error( 01039 StylesheetConstructionContext& theContext, 01040 XalanMessages::Codes theCode, 01041 const XalanDOMString& theToken, 01042 const Locator* theLocator); 01043 01044 /** 01045 * A convenience function for loading a message 01046 * and reporting an error through the provided 01047 * StylesheetConstructionContext instance. 01048 * 01049 * @param theContext The StylesheetConstructionContext to use 01050 * @param theCode The code of the message 01051 * @param theToken1 The first substitution token for the message 01052 * @param theToken2 The second substitution token for the message 01053 */ 01054 void 01055 error( 01056 StylesheetConstructionContext& theContext, 01057 XalanMessages::Codes theCode, 01058 const XalanDOMString& theToken1, 01059 const XalanDOMString& theToken2); 01060 01061 /** 01062 * A convenience function for loading a message 01063 * and reporting an error through the provided 01064 * StylesheetConstructionContext instance. 01065 * 01066 * @param theContext The StylesheetConstructionContext to use 01067 * @param theCode The code of the message 01068 * @param theToken1 The first substitution token for the message 01069 * @param theToken2 The second substitution token for the message 01070 */ 01071 void 01072 error( 01073 StylesheetConstructionContext& theContext, 01074 XalanMessages::Codes theCode, 01075 const XalanDOMChar* theToken1, 01076 const XalanDOMChar* theToken2); 01077 01078 /** 01079 * A convenience function for loading a message 01080 * and reporting an error through the provided 01081 * StylesheetConstructionContext instance. 01082 * 01083 * @param theContext The StylesheetConstructionContext to use 01084 * @param theCode The code of the message 01085 * @param theToken1 The first substitution token for the message 01086 * @param theToken2 The second substitution token for the message 01087 * @param theToken3 The third substitution token for the message 01088 */ 01089 void 01090 error( 01091 StylesheetConstructionContext& theContext, 01092 XalanMessages::Codes theCode, 01093 const XalanDOMChar* theToken1, 01094 const XalanDOMChar* theToken2, 01095 const XalanDOMChar* theToken3); 01096 01097 /** 01098 * A convenience function for loading a message 01099 * and reporting a warning through the provided 01100 * StylesheetConstructionContext instance. 01101 * 01102 * @param theContext The StylesheetConstructionContext to use 01103 * @param theCode The code of the message 01104 * @param theToken1 The first substitution token for the message 01105 * @param theToken2 The second substitution token for the message 01106 * @param theToken3 The third substitution token for the message 01107 */ 01108 void 01109 warn( 01110 StylesheetConstructionContext& theContext, 01111 XalanMessages::Codes theCode, 01112 const XalanDOMChar* theToken1, 01113 const XalanDOMChar* theToken2, 01114 const XalanDOMChar* theToken3); 01115 01116 // A handy empty XalanDOMString instance for 01117 // derived classes to use. 01118 static const XalanDOMString s_emptyString; 01119 01120 private: 01121 01122 enum eFlags 01123 { 01124 eHasParams = 1, 01125 eHasSingleTextChild = 2, 01126 eHasVariables = 4, 01127 eHasDirectTemplate = 8, 01128 eCanGenerateAttributes = 16, 01129 eDefaultTemplate = 32, 01130 eSpacePreserve = 64, 01131 eFinishedConstruction = 128, 01132 eHasPrefix = 256, 01133 eDisableOutputEscaping = 512 01134 }; 01135 01136 bool 01137 getFlag(eFlags theFlag) const 01138 { 01139 return m_flags & theFlag ? true : false; 01140 } 01141 01142 void 01143 setFlag( 01144 eFlags theFlag, 01145 bool theValue) 01146 { 01147 if (theValue == true) 01148 { 01149 m_flags |= theFlag; 01150 } 01151 else 01152 { 01153 m_flags &= ~theFlag; 01154 } 01155 } 01156 01157 01158 #if defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION) 01159 /** 01160 * Take the contents of a template element, process it, and 01161 * convert it to a string. 01162 * 01163 * @param executionContext The current execution context 01164 * @param result result of executing the elements children 01165 * @result a reference to a string containing the result. 01166 */ 01167 XalanDOMString& 01168 doChildrenToString( 01169 StylesheetExecutionContext& executionContext, 01170 XalanDOMString& result) const; 01171 #endif 01172 01173 Stylesheet& m_stylesheet; 01174 01175 /* 01176 * This object handles all result tree namespace processing. 01177 */ 01178 NamespacesHandler m_namespacesHandler; 01179 01180 const int m_xslToken; 01181 01182 ElemTemplateElement* m_parentNode; 01183 ElemTemplateElement* m_nextSibling; 01184 ElemTemplateElement* m_previousSibling; 01185 01186 union 01187 { 01188 ElemTemplateElement* m_firstChild; 01189 const ElemTemplate* m_directTemplate; 01190 const ElemTextLiteral* m_textLiteralChild; 01191 }; 01192 01193 LocatorProxy m_locatorProxy; 01194 01195 unsigned short m_flags; 01196 01197 static const XalanQNameByReference s_emptyQName; 01198 01199 // Not implemented... 01200 ElemTemplateElement(const ElemTemplateElement&); 01201 01202 ElemTemplateElement& 01203 operator=(const ElemTemplateElement&); 01204 01205 bool 01206 operator==(const ElemTemplateElement&) const; 01207 }; 01208 01209 01210 01211 XALAN_CPP_NAMESPACE_END 01212 01213 01214 01215 #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.11 |
|