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_XSLTENGINEIMPL_HEADER_GUARD) 00058 #define XALAN_XSLTENGINEIMPL_HEADER_GUARD 00059 00060 00061 00062 // Base include file. Must be first. 00063 #include "XSLTDefinitions.hpp" 00064 00065 00066 00067 // Base class 00068 #include "XSLTProcessor.hpp" 00069 00070 00071 00072 00073 // Standard library headers 00074 #include <cassert> 00075 #include <ctime> 00076 #include <map> 00077 #include <set> 00078 00079 00080 00081 #include <XalanDOM/XalanDOMString.hpp> 00082 00083 00084 00085 #if defined(XALAN_AUTO_PTR_REQUIRES_DEFINITION) 00086 #include <XPath/XPathProcessor.hpp> 00087 #endif 00088 00089 00090 00091 #include <Include/XalanAutoPtr.hpp> 00092 00093 00094 00095 #include <PlatformSupport/AttributeListImpl.hpp> 00096 #include <PlatformSupport/DOMStringHelper.hpp> 00097 #include <PlatformSupport/PrefixResolver.hpp> 00098 00099 00100 00101 #include <XPath/Function.hpp> 00102 #include <XPath/NameSpace.hpp> 00103 00104 00105 00106 #include "KeyDeclaration.hpp" 00107 #include "OutputContextStack.hpp" 00108 #include "ProblemListenerDefault.hpp" 00109 #include "ResultNamespacesStack.hpp" 00110 #include "StylesheetExecutionContext.hpp" 00111 #include "XSLTProcessorException.hpp" 00112 00113 00114 00115 // Forward declarations... 00116 class DocumentHandler; 00117 class DOMSupport; 00118 class GenerateEvent; 00119 class InputSource; 00120 class PrintWriter; 00121 class ResultTreeFragBase; 00122 class StylesheetConstructionContext; 00123 class StylesheetExecutionContext; 00124 class StylesheetRoot; 00125 class XalanAttr; 00126 class XalanSourceTreeDocument; 00127 class XalanText; 00128 class XLocator; 00129 class XMLParserLiaison; 00130 class XMLURL; 00131 class XObject; 00132 class XPathEnvSupport; 00133 class XPathFactory; 00134 class XPathProcessor; 00135 class XSLTResultTarget; 00136 00137 00138 00150 00151 class XALAN_XSLT_EXPORT XSLTEngineImpl : public XSLTProcessor, public PrefixResolver 00152 { 00153 public: 00154 00155 #if defined(XALAN_STRICT_ANSI_HEADERS) 00156 typedef std::clock_t ClockType; 00157 #else 00158 typedef clock_t ClockType; 00159 #endif 00160 00161 struct LessXalanDOMStringPointers 00162 { 00163 bool 00164 operator()( 00165 const XalanDOMString* theLHS, 00166 const XalanDOMString* theRHS) const 00167 { 00168 if (theLHS == 0 && theRHS != 0) 00169 { 00170 return true; 00171 } 00172 else if (theRHS == 0) 00173 { 00174 return false; 00175 } 00176 else 00177 { 00178 return theLHS->compare(*theRHS) < 0 ? true : false; 00179 } 00180 } 00181 }; 00182 00183 #if defined(XALAN_NO_NAMESPACES) 00184 typedef map<XalanDOMString, 00185 int, 00186 less<XalanDOMString> > ElementKeysMapType; 00187 typedef map<const void*, 00188 ClockType, 00189 less<const void*> > DurationsTableMapType; 00190 typedef vector<const Locator*> LocatorStack; 00191 typedef vector<TraceListener*> TraceListenerVectorType; 00192 typedef vector<bool> BoolVectorType; 00193 typedef set<const XalanDOMString*, 00194 LessXalanDOMStringPointers> XalanDOMStringPointerSetType; 00195 #else 00196 typedef std::map<XalanDOMString, int> ElementKeysMapType; 00197 typedef std::map<const void*, ClockType> DurationsTableMapType; 00198 typedef std::vector<const Locator*> LocatorStack; 00199 typedef std::vector<TraceListener*> TraceListenerVectorType; 00200 typedef std::vector<bool> BoolVectorType; 00201 typedef std::set<const XalanDOMString*, 00202 LessXalanDOMStringPointers> XalanDOMStringPointerSetType; 00203 #endif 00204 00205 typedef XalanAutoPtr<XPathProcessor> XPathProcessorPtrType; 00206 typedef Function::XObjectArgVectorType XObjectArgVectorType; 00207 typedef StylesheetExecutionContext::ParamVectorType ParamVectorType; 00208 00209 // Public members 00210 //--------------------------------------------------------------------- 00211 00224 XSLTEngineImpl( 00225 XMLParserLiaison& parserLiaison, 00226 XPathEnvSupport& xpathEnvSupport, 00227 DOMSupport& domSupport, 00228 XObjectFactory& xobjectFactory, 00229 XPathFactory& xpathFactory); 00230 00231 virtual 00232 ~XSLTEngineImpl(); 00233 00238 static void 00239 initialize(); 00240 00244 static void 00245 terminate(); 00246 00247 // These methods are inherited from XSLTProcessor ... 00248 00249 virtual void 00250 process( 00251 const XSLTInputSource& inputSource, 00252 const XSLTInputSource& stylesheetSource, 00253 XSLTResultTarget& outputTarget, 00254 StylesheetConstructionContext& constructionContext, 00255 StylesheetExecutionContext& executionContext); 00256 00257 virtual void 00258 process( 00259 const XSLTInputSource& inputSource, 00260 XSLTResultTarget& outputTarget, 00261 StylesheetExecutionContext& executionContext); 00262 00263 virtual StylesheetRoot* 00264 processStylesheet( 00265 const XSLTInputSource& stylesheetSource, 00266 StylesheetConstructionContext& constructionContext); 00267 00268 virtual StylesheetRoot* 00269 processStylesheet( 00270 const XalanDOMString& xsldocURLString, 00271 StylesheetConstructionContext& constructionContext); 00272 00273 virtual XalanNode* 00274 getSourceTreeFromInput(const XSLTInputSource& inputSource); 00275 00276 virtual void 00277 resolveTopLevelParams(StylesheetExecutionContext& executionContext); 00278 00279 virtual XMLParserLiaison& 00280 getXMLParserLiaison() const; 00281 00282 virtual const XalanDOMString 00283 getUniqueNamespaceValue(); 00284 00285 virtual void 00286 getUniqueNamespaceValue(XalanDOMString& theValue); 00287 00288 virtual void 00289 setStylesheetParam( 00290 const XalanDOMString& key, 00291 const XalanDOMString& expression); 00292 00293 virtual void 00294 setStylesheetParam( 00295 const XalanDOMString& key, 00296 XObjectPtr value); 00297 00298 virtual bool 00299 shouldStripSourceNode( 00300 XPathExecutionContext& executionContext, 00301 const XalanNode& node) const; 00302 00303 virtual FormatterListener* 00304 getFormatterListener() const; 00305 00306 virtual void 00307 setFormatterListener(FormatterListener* flistener); 00308 00309 // Trace-related functions... 00310 00311 virtual size_type 00312 getTraceListeners() const; 00313 00314 virtual void 00315 addTraceListener(TraceListener* tl); 00316 00317 virtual void 00318 removeTraceListener(TraceListener* tl); 00319 00320 virtual void 00321 fireGenerateEvent(const GenerateEvent& ge); 00322 00323 virtual void 00324 fireTraceEvent(const TracerEvent& te); 00325 00326 virtual void 00327 fireSelectEvent(const SelectionEvent& se); 00328 00329 virtual bool 00330 getTraceSelects() const; 00331 00332 virtual void 00333 setTraceSelects(bool b); 00334 00335 void 00336 traceSelect( 00337 StylesheetExecutionContext& executionContext, 00338 const ElemTemplateElement& theTemplate, 00339 const NodeRefListBase& nl, 00340 const XPath* xpath) const; 00341 00342 virtual void 00343 setQuietConflictWarnings(bool b); 00344 00345 virtual void 00346 setDiagnosticsOutput(PrintWriter* pw); 00347 00348 00349 // Inherited from PrefixResolver... 00350 00359 virtual const XalanDOMString* 00360 getNamespaceForPrefix(const XalanDOMString& prefix) const; 00361 00367 virtual const XalanDOMString& 00368 getURI() const; 00369 00381 XalanDocument* 00382 parseXML( 00383 const XalanDOMString& urlString, 00384 DocumentHandler* docHandler, 00385 XalanDocument* docToRegister); 00386 00398 XalanDocument* 00399 parseXML( 00400 const InputSource& inputSource, 00401 DocumentHandler* docHandler, 00402 XalanDocument* docToRegister); 00403 00416 Stylesheet* 00417 getStylesheetFromPIURL( 00418 const XalanDOMString& xslURLString, 00419 XalanNode& fragBase, 00420 const XalanDOMString& xmlBaseIdent, 00421 bool isRoot, 00422 StylesheetConstructionContext& constructionContext); 00423 00427 void 00428 flushPending(); 00429 00436 void 00437 addResultNamespaceDecl( 00438 const XalanDOMString& prefix, 00439 const XalanDOMString& namespaceVal); 00440 00449 void 00450 addResultAttribute( 00451 AttributeListImpl& attList, 00452 const XalanDOMString& aname, 00453 const XalanDOMString& value); 00454 00462 void 00463 addResultAttribute( 00464 const XalanDOMString& aname, 00465 const XalanDOMString& value) 00466 { 00467 assert(m_outputContextStack.empty() == false); 00468 00469 addResultAttribute(getPendingAttributesImpl(), 00470 aname, 00471 value); 00472 } 00473 00474 void 00475 setDocumentLocator(const Locator* locator); 00476 00477 void 00478 startDocument(); 00479 00480 void 00481 endDocument(); 00482 00483 void 00484 startElement( 00485 const XalanDOMChar* name, 00486 AttributeList& atts); 00487 00488 void 00489 endElement(const XalanDOMChar* name); 00490 00491 void 00492 characters ( 00493 const XalanDOMChar* ch, 00494 XalanDOMString::size_type length); 00495 00496 void 00497 ignorableWhitespace( 00498 const XalanDOMChar* ch, 00499 XalanDOMString::size_type length); 00500 00501 void 00502 processingInstruction( 00503 const XalanDOMChar* target, 00504 const XalanDOMChar* data); 00505 00506 void 00507 resetDocument(); 00508 00516 void 00517 characters( 00518 const XalanDOMChar* ch, 00519 XalanDOMString::size_type start, 00520 XalanDOMString::size_type length); 00521 00527 void 00528 characters(const XalanNode& node); 00529 00535 void 00536 characters(const XObjectPtr& xobject); 00537 00544 void 00545 startElement(const XalanDOMChar* name); 00546 00556 void 00557 charactersRaw( 00558 const XalanDOMChar* ch, 00559 XalanDOMString::size_type start, 00560 XalanDOMString::size_type length); 00561 00567 void 00568 charactersRaw(const XalanNode& node); 00569 00575 void 00576 charactersRaw(const XObjectPtr& xobject); 00577 00583 void 00584 comment(const XalanDOMChar* data); 00585 00592 void 00593 entityReference(const XalanDOMChar* data); 00594 00602 void 00603 cdata( 00604 const XalanDOMChar* ch, 00605 XalanDOMString::size_type start, 00606 XalanDOMString::size_type length); 00607 00615 void 00616 cloneToResultTree( 00617 const XalanNode& node, 00618 bool cloneTextNodesOnly, 00619 const ElemTemplateElement* styleNode); 00620 00632 void 00633 cloneToResultTree( 00634 const XalanNode& node, 00635 XalanNode::NodeType nodeType, 00636 bool isLiteral, 00637 bool overrideStrip, 00638 bool shouldCloneAttributes, 00639 bool cloneTextNodesOnly, 00640 const ElemTemplateElement* styleNode); 00641 00648 void 00649 outputToResultTree( 00650 const XObject& value, 00651 bool outputTextNodesOnly, 00652 const ElemTemplateElement* styleNode); 00653 00662 void 00663 outputResultTreeFragment( 00664 const XObject& theTree, 00665 bool outputTextNodesOnly, 00666 const ElemTemplateElement* styleNode); 00667 00673 virtual const StylesheetRoot* 00674 getStylesheetRoot() const; 00675 00681 virtual void 00682 setStylesheetRoot(const StylesheetRoot* theStylesheet); 00683 00689 virtual void 00690 setExecutionContext(StylesheetExecutionContext* theExecutionContext); 00691 00698 static const XalanDOMString& 00699 getXSLNameSpaceURL() 00700 { 00701 return s_XSLNameSpaceURL; 00702 } 00703 00709 static const XalanDOMString& 00710 getXalanXSLNameSpaceURL() 00711 { 00712 return s_XalanNamespaceURL; 00713 } 00714 00720 static double 00721 getXSLTVerSupported(); 00722 00731 static int 00732 getElementToken(const XalanDOMString& name) 00733 { 00734 ElementKeysMapType::const_iterator iter= 00735 s_elementKeys.find(name); 00736 00737 return iter == s_elementKeys.end() ? -2 : (*iter).second; 00738 } 00739 00749 int 00750 getXSLToken(const XalanNode& node) const; 00751 00757 bool 00758 getQuietConflictWarnings() const 00759 { 00760 return m_quietConflictWarnings; 00761 } 00762 00763 virtual void 00764 message( 00765 const XalanDOMString& msg, 00766 const XalanNode* sourceNode = 0, 00767 const XalanNode* styleNode = 0) const; 00768 00769 virtual void 00770 message( 00771 const XalanDOMString& msg, 00772 const XalanNode* sourceNode, 00773 const ElemTemplateElement* styleNode) const; 00774 00782 virtual void 00783 message( 00784 const char* msg, 00785 const XalanNode* sourceNode = 0, 00786 const XalanNode* styleNode = 0) const; 00787 00788 virtual void 00789 message( 00790 const XalanDOMString& msg, 00791 const Locator& locator, 00792 const XalanNode* sourceNode = 0) const; 00793 00794 virtual void 00795 warn( 00796 const XalanDOMString& msg, 00797 const XalanNode* sourceNode = 0, 00798 const XalanNode* styleNode = 0) const; 00799 00800 virtual void 00801 warn( 00802 const XalanDOMString& msg, 00803 const XalanNode* sourceNode, 00804 const ElemTemplateElement* styleNode) const; 00805 00806 virtual void 00807 warn( 00808 const char* msg, 00809 const XalanNode* sourceNode, 00810 const ElemTemplateElement* styleNode) const; 00811 00812 virtual void 00813 warn( 00814 const char* msg, 00815 const XalanNode* sourceNode = 0, 00816 const XalanNode* styleNode = 0) const; 00817 00818 virtual void 00819 warn( 00820 const XalanDOMString& msg, 00821 const Locator& locator, 00822 const XalanNode* sourceNode = 0) const; 00823 00824 virtual void 00825 error( 00826 const XalanDOMString& msg, 00827 const XalanNode* sourceNode = 0, 00828 const XalanNode* styleNode = 0) const; 00829 00830 virtual void 00831 error( 00832 const XalanDOMString& msg, 00833 const XalanNode* sourceNode, 00834 const ElemTemplateElement* styleNode) const; 00835 00836 virtual void 00837 error( 00838 const XalanDOMString& msg, 00839 const Locator& locator, 00840 const XalanNode* sourceNode = 0) const; 00841 00849 virtual void 00850 error( 00851 const char* msg, 00852 const XalanNode* sourceNode = 0, 00853 const XalanNode* styleNode = 0) const; 00854 00861 void 00862 pushTime(const void* key); 00863 00870 ClockType 00871 popDuration(const void* key); 00872 00880 void 00881 displayDuration( 00882 const XalanDOMString& info, 00883 const void* key); 00884 00885 00891 bool doDiagnosticsOutput() 00892 { 00893 return 0 != m_diagnosticsPrintWriter ? true : false; 00894 } 00895 00901 void 00902 diag(const XalanDOMString& s) const; 00903 00909 void 00910 diag(const char* s) const; 00911 00918 const XalanDOMString* 00919 getResultNamespaceForPrefix(const XalanDOMString& prefix) const; 00920 00927 const XalanDOMString* 00928 getResultPrefixForNamespace(const XalanDOMString& theNamespace) const; 00929 00938 bool 00939 isPendingResultPrefix(const XalanDOMString& thePrefix) const; 00940 00949 double 00950 evalMatchPatternStr( 00951 const XalanDOMString& str, 00952 XalanNode* context, 00953 XPathExecutionContext& executionContext); 00954 00962 const XPath* 00963 createMatchPattern( 00964 const XalanDOMString& str, 00965 const PrefixResolver& resolver); 00966 00973 void 00974 returnXPath(const XPath* xpath); 00975 00981 void 00982 copyNamespaceAttributes(const XalanNode& src); 00983 00991 const XObjectPtr 00992 evalXPathStr( 00993 const XalanDOMString& str, 00994 XPathExecutionContext& executionContext); 00995 01005 const XObjectPtr 01006 evalXPathStr( 01007 const XalanDOMString& str, 01008 XalanNode* contextNode, 01009 const PrefixResolver& prefixResolver, 01010 XPathExecutionContext& executionContext); 01011 01021 const XObjectPtr 01022 evalXPathStr( 01023 const XalanDOMString& str, 01024 XalanNode* contextNode, 01025 const XalanElement& prefixResolver, 01026 XPathExecutionContext& executionContext); 01027 01035 void 01036 copyAttributeToTarget( 01037 const XalanDOMString& attrName, 01038 const XalanDOMString& attrValue, 01039 AttributeListImpl& attrList); 01040 01046 XPathFactory& 01047 getXPathFactory() 01048 { 01049 return m_xpathFactory; 01050 } 01051 01057 XPathProcessor& 01058 getXPathProcessor() 01059 { 01060 return *m_xpathProcessor.get(); 01061 } 01062 01067 virtual void 01068 reset(); 01069 01074 virtual XalanDocument* 01075 getDOMFactory() const; 01076 01082 XPathEnvSupport& 01083 getXPathEnvSupport() 01084 { 01085 return m_xpathEnvSupport; 01086 } 01087 01096 void 01097 setProblemListener(ProblemListener* l) 01098 { 01099 m_problemListener = l; 01100 } 01101 01110 ProblemListener* 01111 getProblemListener() const 01112 { 01113 return m_problemListener; 01114 } 01115 01116 /* 01117 * Push a new output context using the provided FormatterListener. 01118 * 01119 * @param A pointer to the FormatterListener instance for the new context. 01120 */ 01121 void 01122 pushOutputContext(FormatterListener* theListener) 01123 { 01124 m_outputContextStack.pushContext(theListener); 01125 } 01126 01127 /* 01128 * Pop the current output context. 01129 */ 01130 void 01131 popOutputContext() 01132 { 01133 m_outputContextStack.popContext(); 01134 } 01135 01136 /* 01137 * See if there is a pending start document event waiting. 01138 * @return true if there is a start document event waiting. 01139 */ 01140 bool 01141 getHasPendingStartDocument() const 01142 { 01143 return getHasPendingStartDocumentImpl(); 01144 } 01145 01146 /* 01147 * Set the pending start document event state. 01148 * @param the new value 01149 */ 01150 void 01151 setHasPendingStartDocument(bool b) 01152 { 01153 setHasPendingStartDocumentImpl(b); 01154 } 01155 01156 /* 01157 * See if a pending start document event must be flushed. 01158 * @return true if the event must be flushed. 01159 */ 01160 bool 01161 getMustFlushPendingStartDocument() const 01162 { 01163 return getMustFlushPendingStartDocumentImpl(); 01164 } 01165 01166 /* 01167 * Set the pending start document event flush state. 01168 * @param the new value 01169 */ 01170 void 01171 setMustFlushPendingStartDocument(bool b) 01172 { 01173 setMustFlushPendingStartDocumentImpl(b); 01174 } 01175 01181 const AttributeList& 01182 getPendingAttributes() const 01183 { 01184 return getPendingAttributesImpl(); 01185 } 01186 01192 void 01193 setPendingAttributes(const AttributeList& pendingAttributes) 01194 { 01195 getPendingAttributesImpl() = pendingAttributes; 01196 } 01197 01205 void 01206 replacePendingAttribute( 01207 const XalanDOMChar* theName, 01208 const XalanDOMChar* theNewType, 01209 const XalanDOMChar* theNewValue) 01210 { 01211 // Remove the old attribute, then add the new one. AttributeListImpl::addAttribute() 01212 // does this for us. 01213 getPendingAttributesImpl().addAttribute(theName, theNewType, theNewValue); 01214 } 01215 01216 bool 01217 isElementPending() const 01218 { 01219 return length(getPendingElementNameImpl()) != 0 ? true : false; 01220 } 01221 01227 const XalanDOMString& 01228 getPendingElementName() const 01229 { 01230 return getPendingElementNameImpl(); 01231 } 01232 01238 void 01239 setPendingElementName(const XalanDOMString& elementName) 01240 { 01241 setPendingElementNameImpl(elementName); 01242 } 01243 01244 void 01245 setPendingElementName(const XalanDOMChar* elementName) 01246 { 01247 setPendingElementNameImpl(elementName); 01248 } 01249 01255 const Locator* 01256 getLocatorFromStack() const 01257 { 01258 return m_stylesheetLocatorStack.empty() == true ? 0 : m_stylesheetLocatorStack.back(); 01259 } 01260 01266 void 01267 pushLocatorOnStack(const Locator* locator) 01268 { 01269 m_stylesheetLocatorStack.push_back(locator); 01270 } 01271 01275 void 01276 popLocatorStack() 01277 { 01278 if (m_stylesheetLocatorStack.empty() == false) 01279 { 01280 m_stylesheetLocatorStack.pop_back(); 01281 } 01282 } 01283 01284 protected: 01285 01291 const AttributeListImpl& 01292 getPendingAttributesImpl() const 01293 { 01294 return m_outputContextStack.getPendingAttributes(); 01295 } 01296 01302 AttributeListImpl& 01303 getPendingAttributesImpl() 01304 { 01305 return m_outputContextStack.getPendingAttributes(); 01306 } 01307 01313 void 01314 setPendingAttributesImpl(const AttributeList& pendingAttributes) 01315 { 01316 getPendingAttributesImpl() = pendingAttributes; 01317 } 01318 01324 const XalanDOMString& 01325 getPendingElementNameImpl() const 01326 { 01327 return m_outputContextStack.getPendingElementName(); 01328 } 01329 01335 XalanDOMString& 01336 getPendingElementNameImpl() 01337 { 01338 return m_outputContextStack.getPendingElementName(); 01339 } 01340 01346 void 01347 setPendingElementNameImpl(const XalanDOMString& elementName) 01348 { 01349 m_outputContextStack.getPendingElementName() = elementName; 01350 } 01351 01357 void 01358 setPendingElementNameImpl(const XalanDOMChar* elementName) 01359 { 01360 assert(elementName != 0); 01361 01362 m_outputContextStack.getPendingElementName() = elementName; 01363 } 01364 01365 /* 01366 * See if there is a pending start document event waiting. 01367 * @return true if there is a start document event waiting. 01368 */ 01369 bool 01370 getHasPendingStartDocumentImpl() const 01371 { 01372 return m_outputContextStack.getHasPendingStartDocument(); 01373 } 01374 01375 /* 01376 * Set the pending start document event state. 01377 * @param the new value 01378 */ 01379 void 01380 setHasPendingStartDocumentImpl(bool b) 01381 { 01382 m_outputContextStack.getHasPendingStartDocument() = b; 01383 } 01384 01385 /* 01386 * See if a pending start document event must be flushed. 01387 * @return true if the event must be flushed. 01388 */ 01389 bool 01390 getMustFlushPendingStartDocumentImpl() const 01391 { 01392 return m_outputContextStack.getMustFlushPendingStartDocument(); 01393 } 01394 01395 /* 01396 * Set the pending start document event flush state. 01397 * @param the new value 01398 */ 01399 void 01400 setMustFlushPendingStartDocumentImpl(bool b) 01401 { 01402 m_outputContextStack.getMustFlushPendingStartDocument() = b; 01403 } 01404 01405 FormatterListener* 01406 getFormatterListenerImpl() const 01407 { 01408 return m_outputContextStack.getFormatterListener(); 01409 } 01410 01411 void 01412 setFormatterListenerImpl(FormatterListener* flistener) 01413 { 01414 m_outputContextStack.getFormatterListener() = flistener; 01415 } 01416 01420 bool m_useDOMResultTreeFactory; 01421 01425 mutable XalanDocument* m_domResultTreeFactory; 01426 01433 XalanDOMString m_resultNameSpacePrefix; 01434 01438 XalanDOMString m_resultNameSpaceURL; 01439 01440 01445 void 01446 copyAttributesToAttList( 01447 const XalanNode& node, 01448 AttributeListImpl& attList); 01449 01450 // Factory for creating xpaths. 01451 XPathFactory& m_xpathFactory; 01452 01453 // Factory for creating xobjects 01454 XObjectFactory& m_xobjectFactory; 01455 01456 // The query/pattern-matcher object. 01457 const XPathProcessorPtrType m_xpathProcessor; 01458 01463 BoolVectorType m_cdataStack; 01464 01465 private: 01466 01473 void 01474 warnCopyTextNodesOnly( 01475 const XalanNode* sourceNode, 01476 const ElemTemplateElement* styleNode) const; 01477 01485 void 01486 cloneToResultTree( 01487 const XalanText& node, 01488 bool isLiteral, 01489 bool overrideStrip); 01490 01495 bool 01496 pendingAttributesHasDefaultNS() const; 01497 01498 void 01499 addResultNamespace( 01500 const XalanDOMString& thePrefix, 01501 const XalanDOMString& theName, 01502 const XalanNode& theNode, 01503 AttributeListImpl& thePendingAttributes, 01504 bool fOnlyIfPrefixNotPresent); 01505 01506 void 01507 addResultNamespace( 01508 const XalanNode& theNode, 01509 AttributeListImpl& thePendingAttributes, 01510 bool fOnlyIfPrefixNotPresent = false); 01511 01516 LocatorStack m_stylesheetLocatorStack; 01517 01524 ProblemListenerDefault m_defaultProblemListener; 01525 01526 ProblemListener* m_problemListener; 01527 01531 const StylesheetRoot* m_stylesheetRoot; 01532 01536 static const XalanDOMString& s_XSLNameSpaceURL; //"http://www.w3.org/1999/XSL/Transform" 01537 01541 static const double s_XSLTVerSupported; // 1.0 01542 01546 static const XalanDOMString& s_XalanNamespaceURL; // "http://xml.apache.org/xalan" 01547 01551 static const XalanDOMString& s_uniqueNamespacePrefix; 01552 01556 static const ElementKeysMapType& s_elementKeys; 01557 01561 bool m_traceSelects; 01562 01567 bool m_quietConflictWarnings; 01568 01569 /* 01570 * A stream to print diagnostics to. 01571 */ 01572 PrintWriter* m_diagnosticsPrintWriter; 01573 01574 /* For diagnostics */ 01575 DurationsTableMapType m_durationsTable; 01576 01581 TraceListenerVectorType m_traceListeners; 01582 01583 // Common processing for errors and warnings 01584 void 01585 problem( 01586 const XalanDOMString& msg, 01587 ProblemListener::eClassification classification, 01588 const XalanNode* sourceNode, 01589 const XalanNode* styleNode) const; 01590 01591 void 01592 problem( 01593 const XalanDOMString& msg, 01594 ProblemListener::eClassification classification, 01595 const XalanNode* sourceNode, 01596 const ElemTemplateElement* styleNode) const; 01597 01598 void 01599 problem( 01600 const XalanDOMString& msg, 01601 ProblemListener::eClassification classification, 01602 const Locator& locator, 01603 const XalanNode* sourceNode) const; 01604 01605 //========================================================== 01606 // SECTION: Function to do with attribute handling 01607 //========================================================== 01608 01612 unsigned long m_uniqueNSValue; 01613 01614 ParamVectorType m_topLevelParams; 01615 01616 public: 01617 01621 void 01622 clearTopLevelParams() 01623 { 01624 m_topLevelParams.clear(); 01625 } 01626 01627 private: 01628 01629 bool 01630 generateCDATASection() const 01631 { 01632 if (m_hasCDATASectionElements == false) 01633 { 01634 return false; 01635 } 01636 else 01637 { 01638 assert(m_cdataStack.empty() == false); 01639 01640 return m_cdataStack.back(); 01641 } 01642 } 01643 01644 void 01645 doFlushPending() 01646 { 01647 setMustFlushPendingStartDocument(true); 01648 01649 flushPending(); 01650 } 01651 01659 bool 01660 isCDataResultElem(const XalanDOMString& elementName) const; 01661 01662 void 01663 fireCharacterGenerateEvent( 01664 const XalanNode& theNode, 01665 bool isCDATA); 01666 01667 void 01668 fireCharacterGenerateEvent( 01669 const XObjectPtr& theXObject, 01670 bool isCDATA); 01671 01672 void 01673 fireCharacterGenerateEvent( 01674 const XalanDOMString& theString, 01675 bool isCDATA); 01676 01677 void 01678 fireCharacterGenerateEvent( 01679 const XalanDOMChar* ch, 01680 XalanDOMString::size_type start, 01681 XalanDOMString::size_type length, 01682 bool isCDATA); 01683 01684 void 01685 checkDefaultNamespace( 01686 const XalanDOMString& theElementName, 01687 const XalanDOMString& theElementNamespaceURI); 01688 01689 XMLParserLiaison& m_parserLiaison; 01690 01691 XPathEnvSupport& m_xpathEnvSupport; 01692 01693 DOMSupport& m_domSupport; 01694 01698 StylesheetExecutionContext* m_executionContext; 01699 01700 /* 01701 * Stack of current output contexts... 01702 */ 01703 OutputContextStack m_outputContextStack; 01704 01705 /* 01706 * Stack of current result namespaces... 01707 */ 01708 ResultNamespacesStack m_resultNamespacesStack; 01709 01710 /* 01711 * Dummy AttributeListImpl 01712 */ 01713 AttributeListImpl m_dummyAttributesList; 01714 01715 XalanDOMString m_scratchString; 01716 01717 XalanDOMStringPointerSetType m_attributeNamesVisited; 01718 01719 const XalanDOMStringPointerSetType::iterator m_attributeNamesVisitedEnd; 01720 01721 bool m_hasStripOrPreserveSpace; 01722 01723 bool m_hasCDATASectionElements; 01724 01725 static void 01726 installFunctions(); 01727 01728 static void 01729 uninstallFunctions(); 01730 01731 static void 01732 initializeElementKeysTable(ElementKeysMapType& theElementKeys); 01733 01734 static const XalanDOMString s_emptyString; 01735 01736 static const XalanDOMString& s_stylesheetNodeName; 01737 static const XalanDOMString& s_typeString; 01738 static const XalanDOMString& s_hrefString; 01739 static const XalanDOMString& s_piTokenizerString; 01740 static const XalanDOMString& s_typeValueString1; 01741 static const XalanDOMString& s_typeValueString2; 01742 static const XalanDOMString& s_typeValueString3; 01743 static const XalanDOMString& s_typeValueString4; 01744 01745 // Not implemented... 01746 XSLTEngineImpl(const XSLTEngineImpl&); 01747 01748 XSLTEngineImpl& 01749 operator=(const XSLTEngineImpl&); 01750 01751 bool 01752 operator==(const XSLTEngineImpl&) const; 01753 }; 01754 01755 01756 01757 #endif // XALAN_XSLTENGINEIMPL_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 |
|