00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 1999-2004 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 * $ Id: $ 00058 * 00059 */ 00060 00061 #if !defined(XALAN_STYLESHEET_HEADER_GUARD) 00062 #define XALAN_STYLESHEET_HEADER_GUARD 00063 00064 00065 00066 // Base include file. Must be first. 00067 #include "XSLTDefinitions.hpp" 00068 00069 00070 00071 #include <deque> 00072 #include <map> 00073 #include <vector> 00074 00075 00076 00077 #include <xalanc/XalanDOM/XalanNode.hpp> 00078 00079 00080 #include <xalanc/PlatformSupport/PrefixResolver.hpp> 00081 00082 00083 00084 #include <xalanc/XPath/NameSpace.hpp> 00085 #include <xalanc/XPath/XalanQNameByReference.hpp> 00086 #include <xalanc/XPath/XPath.hpp> 00087 00088 00089 00090 #include <xalanc/XSLT/NamespacesHandler.hpp> 00091 #include <xalanc/XSLT/KeyDeclaration.hpp> 00092 #include <xalanc/XSLT/StylesheetExecutionContext.hpp> 00093 00094 00095 00096 XALAN_CPP_NAMESPACE_BEGIN 00097 00098 00099 00100 class ExtensionNSHandler; 00101 class XalanDecimalFormatSymbols; 00102 class ElemDecimalFormat; 00103 class ElemTemplate; 00104 class ElemTemplateElement; 00105 class ElemVariable; 00106 class KeyTable; 00107 class NodeRefListBase; 00108 class PrefixResolver; 00109 class StylesheetConstructionContext; 00110 class StylesheetRoot; 00111 class XalanQName; 00112 class XObject; 00113 class StylesheetExecutionContext; 00114 00115 00116 00121 class XALAN_XSLT_EXPORT Stylesheet : protected PrefixResolver 00122 { 00123 00124 public: 00125 00126 #if defined(XALAN_STRICT_ANSI_HEADERS) 00127 typedef std::size_t size_type; 00128 #else 00129 typedef size_t size_type; 00130 #endif 00131 00132 typedef StylesheetExecutionContext::ParamVectorType ParamVectorType; 00133 typedef XalanQName::NamespaceVectorType NamespaceVectorType; 00134 typedef XalanQName::NamespacesStackType NamespacesStackType; 00135 00136 #if defined(XALAN_NO_STD_NAMESPACE) 00137 typedef map<XalanDOMString, 00138 ExtensionNSHandler*, 00139 less<XalanDOMString> > ExtensionNamespacesMapType; 00140 typedef map<XalanQNameByReference, 00141 const ElemTemplate*, 00142 less<XalanQName> > ElemTemplateMapType; 00143 typedef vector<ElemVariable*> ElemVariableVectorType; 00144 typedef vector<KeyDeclaration> KeyDeclarationVectorType; 00145 typedef map<const XalanNode*, 00146 KeyTable*, 00147 less<const XalanNode*> > KeyTablesTableType; 00148 typedef vector<Stylesheet*> StylesheetVectorType; 00149 typedef vector<XalanDOMString> URLStackType; 00150 typedef vector<ElemDecimalFormat*> ElemDecimalFormatVectorType; 00151 #else 00152 typedef std::map<XalanDOMString, ExtensionNSHandler*> ExtensionNamespacesMapType; 00153 typedef std::map<XalanQNameByReference, 00154 const ElemTemplate*, 00155 std::less<XalanQName> > ElemTemplateMapType; 00156 typedef std::vector<ElemVariable*> ElemVariableVectorType; 00157 typedef std::vector<KeyDeclaration> KeyDeclarationVectorType; 00158 typedef std::map<const XalanNode*, KeyTable*> KeyTablesTableType; 00159 typedef std::vector<Stylesheet*> StylesheetVectorType; 00160 typedef std::vector<XalanDOMString> URLStackType; 00161 typedef std::vector<ElemDecimalFormat*> ElemDecimalFormatVectorType; 00162 #endif 00163 00169 Stylesheet( 00170 StylesheetRoot& root, 00171 const XalanDOMString& baseIdentifier, 00172 StylesheetConstructionContext& constructionContext); 00173 00174 virtual 00175 ~Stylesheet(); 00176 00182 double 00183 getXSLTVerDeclared() const 00184 { 00185 return m_XSLTVerDeclared; 00186 } 00187 00193 void 00194 setXSLTVerDeclared(double ver) 00195 { 00196 m_XSLTVerDeclared = ver; 00197 } 00198 00204 const StylesheetRoot& 00205 getStylesheetRoot() const 00206 { 00207 return m_stylesheetRoot; 00208 } 00209 00215 StylesheetRoot& 00216 getStylesheetRoot() 00217 { 00218 return m_stylesheetRoot; 00219 } 00220 00226 const NamespacesStackType& 00227 getNamespaces() const 00228 { 00229 return m_namespaces; 00230 } 00231 00237 NamespacesStackType& 00238 getNamespaces() 00239 { 00240 return m_namespaces; 00241 } 00242 00243 const NamespacesHandler& 00244 getNamespacesHandler() const 00245 { 00246 return m_namespacesHandler; 00247 } 00248 00249 NamespacesHandler& 00250 getNamespacesHandler() 00251 { 00252 return m_namespacesHandler; 00253 } 00254 00260 const NamespaceVectorType& 00261 getNamespaceDecls() const 00262 { 00263 return m_namespaceDecls; 00264 } 00265 00271 NamespaceVectorType& 00272 getNamespaceDecls() 00273 { 00274 return m_namespaceDecls; 00275 } 00276 00282 void 00283 setNamespaceDecls(const NamespaceVectorType& ns) 00284 { 00285 m_namespaceDecls = ns; 00286 } 00287 00294 void 00295 pushNamespaces(const AttributeListType& atts); 00296 00300 void 00301 popNamespaces() 00302 { 00303 assert(m_namespaces.empty() == false); 00304 00305 m_namespaces.pop_back(); 00306 } 00307 00311 virtual void 00312 postConstruction(StylesheetConstructionContext& constructionContext); 00313 00323 bool 00324 isAttrOK( 00325 const XalanDOMChar* attrName, 00326 const AttributeListType& atts, 00327 int which, 00328 StylesheetConstructionContext& constructionContext) const; 00329 00336 const XalanDOMString* 00337 getNamespaceFromStack(const XalanDOMString& nodeName) const 00338 { 00339 return getNamespaceFromStack(c_wstr(nodeName)); 00340 } 00341 00348 const XalanDOMString* 00349 getNamespaceFromStack(const XalanDOMChar* nodeName) const; 00350 00358 const XalanDOMString* 00359 getNamespaceForPrefixFromStack(const XalanDOMString& prefix) const 00360 { 00361 return XalanQName::getNamespaceForPrefix(m_namespaces, prefix); 00362 } 00363 00371 const XalanDOMString* 00372 getNamespaceForPrefixFromStack(const XalanDOMChar* prefix) const 00373 { 00374 assert(prefix != 0); 00375 00376 return XalanQName::getNamespaceForPrefix(m_namespaces, XalanDOMString(prefix)); 00377 } 00378 00386 const XalanDOMString* 00387 getNamespaceForPrefix( 00388 const XalanDOMString& prefix, 00389 StylesheetConstructionContext& constructionContext) const; 00390 00398 const XalanDOMString* 00399 getNamespaceForPrefix( 00400 const XalanDOMChar* prefix, 00401 StylesheetConstructionContext& constructionContext) const; 00402 00410 void 00411 processExcludeResultPrefixes( 00412 StylesheetConstructionContext& theConstructionContext, 00413 const XalanDOMChar* theValue) 00414 { 00415 m_namespacesHandler.processExcludeResultPrefixes( 00416 theConstructionContext, 00417 theValue, 00418 m_namespaces); 00419 } 00420 00427 void 00428 addTemplate( 00429 ElemTemplate* theTemplate, 00430 StylesheetConstructionContext& constructionContext); 00431 00440 bool 00441 getYesOrNo( 00442 const XalanDOMChar* aname, 00443 const XalanDOMChar* val, 00444 StylesheetConstructionContext& constructionContext) const; 00445 00451 const XalanDOMString& 00452 getBaseIdentifier() const 00453 { 00454 return m_baseIdent; 00455 } 00456 00465 const XalanDOMString& 00466 getCurrentIncludeBaseIdentifier() const 00467 { 00468 return m_includeStack.empty() == true ? getBaseIdentifier() : m_includeStack.back(); 00469 } 00470 00478 void 00479 processNSAliasElement( 00480 const XalanDOMChar* name, 00481 const AttributeListType& atts, 00482 StylesheetConstructionContext& constructionContext); 00483 00489 void 00490 processDecimalFormatElement( 00491 StylesheetConstructionContext& constructionContext, 00492 const AttributeListType& atts, 00493 const LocatorType* locator = 0); 00494 00502 const XalanDecimalFormatSymbols* 00503 getDecimalFormatSymbols(const XalanQName& theQName) const; 00504 00510 void 00511 addImport(Stylesheet* theStylesheet) 00512 { 00513 m_imports.insert(m_imports.begin(), theStylesheet); 00514 } 00515 00521 bool 00522 isWrapperless() const 00523 { 00524 return m_isWrapperless; 00525 } 00526 00527 ElemTemplateElement* 00528 initWrapperless( 00529 StylesheetConstructionContext& constructionContext, 00530 const LocatorType* locator); 00531 00537 URLStackType& 00538 getIncludeStack() 00539 { 00540 return m_includeStack; 00541 } 00542 00551 void 00552 processKeyElement( 00553 const PrefixResolver& nsContext, 00554 const AttributeListType& atts, 00555 const LocatorType* locator, 00556 StylesheetConstructionContext& constructionContext); 00557 00564 const ElemTemplate* 00565 findNamedTemplate(const XalanQName& qname) const; 00566 00575 const ElemTemplate* 00576 findTemplate( 00577 StylesheetExecutionContext& executionContext, 00578 XalanNode* targetNode) const 00579 { 00580 assert(targetNode != 0); 00581 00582 return findTemplate( 00583 executionContext, 00584 targetNode, 00585 targetNode->getNodeType(), 00586 s_emptyQName, 00587 false); 00588 } 00589 00601 const ElemTemplate* 00602 findTemplate( 00603 StylesheetExecutionContext& executionContext, 00604 XalanNode* targetNode, 00605 XalanNode::NodeType targetNodeType, 00606 const XalanQName& mode, 00607 bool onlyUseImports) const; 00608 00613 class MatchPattern2 00614 { 00615 public: 00616 00617 typedef XPath::eMatchScore eMatchScore; 00618 00629 MatchPattern2( 00630 const ElemTemplate& theTemplate, 00631 size_type posInStylesheet, 00632 const XalanDOMString& targetString, 00633 const XPath& matchPattern, 00634 const XalanDOMString& pattern, 00635 eMatchScore priority) : 00636 m_template(&theTemplate), 00637 m_posInStylesheet(posInStylesheet), 00638 m_targetString(targetString), 00639 m_matchPattern(&matchPattern), 00640 m_pattern(&pattern), 00641 m_priority(priority) 00642 { 00643 } 00644 00645 MatchPattern2() : 00646 m_template(0), 00647 m_posInStylesheet(0), 00648 m_targetString(), 00649 m_matchPattern(0), 00650 m_pattern(0), 00651 m_priority(XPath::eMatchScoreNone) 00652 { 00653 } 00654 00655 ~MatchPattern2() 00656 { 00657 } 00658 00664 const XalanDOMString& 00665 getTargetString() const 00666 { 00667 return m_targetString; 00668 } 00669 00675 const XPath* 00676 getExpression() const 00677 { 00678 return m_matchPattern; 00679 } 00680 00686 size_type 00687 getPositionInStylesheet() const 00688 { 00689 return m_posInStylesheet; 00690 } 00691 00697 const XalanDOMString* 00698 getPattern() const 00699 { 00700 return m_pattern; 00701 } 00702 00708 const ElemTemplate* 00709 getTemplate() const 00710 { 00711 return m_template; 00712 } 00713 00714 eMatchScore 00715 getDefaultPriority() const 00716 { 00717 return m_priority; 00718 } 00719 00720 double 00721 getPriorityOrDefault() const; 00722 00723 private: 00724 00725 const ElemTemplate* m_template; 00726 size_type m_posInStylesheet; 00727 XalanDOMString m_targetString; 00728 const XPath* m_matchPattern; 00729 const XalanDOMString* m_pattern; 00730 eMatchScore m_priority; 00731 }; 00732 00733 #if defined(XALAN_NO_STD_NAMESPACE) 00734 typedef vector<const MatchPattern2*> PatternTableVectorType; 00735 00736 typedef map<XalanDOMString, 00737 PatternTableVectorType, 00738 less<XalanDOMString> > PatternTableMapType; 00739 00740 typedef deque<MatchPattern2> MatchPattern2Container; 00741 #else 00742 typedef std::vector<const MatchPattern2*> PatternTableVectorType; 00743 00744 typedef std::map<XalanDOMString, 00745 PatternTableVectorType> PatternTableMapType; 00746 00747 typedef std::deque<MatchPattern2> MatchPattern2Container; 00748 #endif 00749 00756 static void 00757 addObjectIfNotFound( 00758 const MatchPattern2* thePattern, 00759 PatternTableVectorType& theVector); 00760 00770 static void 00771 addObjectIfNotFound( 00772 const MatchPattern2* thePattern, 00773 const MatchPattern2* theArray[], 00774 unsigned int& theArraySize); 00775 00783 const PatternTableVectorType* 00784 locateElementMatchPatternList2(const XalanDOMString& theName) const; 00785 00793 const PatternTableVectorType* 00794 locateAttributeMatchPatternList2(const XalanDOMString& theName) const; 00795 00802 const PatternTableVectorType* 00803 locateMatchPatternList2( 00804 const XalanNode& theNode, 00805 XalanNode::NodeType targetNodeType) const; 00806 00815 void 00816 processExtensionNamespace( 00817 StylesheetConstructionContext& theConstructionContext, 00818 const XalanDOMString& uri); 00819 00826 ExtensionNSHandler* 00827 lookupExtensionNSHandler(const XalanDOMString& uri) const 00828 { 00829 const ExtensionNamespacesMapType::const_iterator it = 00830 m_extensionNamespaces.find(uri); 00831 00832 return it == m_extensionNamespaces.end() ? 0 : (*it).second; 00833 } 00834 00841 void 00842 setTopLevelVariable(ElemVariable* var) 00843 { 00844 m_topLevelVariables.push_back(var); 00845 } 00846 00854 void 00855 pushTopLevelVariables( 00856 StylesheetExecutionContext& executionContext, 00857 const ParamVectorType& topLevelParams) const; 00858 00859 00860 // These interfaces are inherited from PrefixResolver... 00861 00862 virtual const XalanDOMString* 00863 getNamespaceForPrefix(const XalanDOMString& prefix) const; 00864 00865 virtual const XalanDOMString& 00866 getURI() const; 00867 00868 const XalanDOMString& 00869 getXSLTNamespaceURI() const 00870 { 00871 return m_XSLTNamespaceURI; 00872 } 00873 00874 void 00875 setXSLTNamespaceURI(const XalanDOMString& theURI) 00876 { 00877 m_XSLTNamespaceURI = theURI; 00878 } 00879 00880 const ElemTemplate* 00881 getFirstTemplate() const 00882 { 00883 return m_firstTemplate; 00884 } 00885 00886 protected: 00887 00891 StylesheetRoot& m_stylesheetRoot; 00892 00896 XalanDOMString m_baseIdent; 00897 00902 KeyDeclarationVectorType m_keyDeclarations; 00903 00904 static const XalanQNameByReference s_emptyQName; 00905 00906 private: 00907 00908 // Not defined... 00909 Stylesheet(const Stylesheet&); 00910 00911 Stylesheet& 00912 operator=(const Stylesheet&); 00913 00914 bool 00915 operator==(const Stylesheet&) const; 00916 00917 00928 const ElemTemplate* 00929 findTemplateInImports( 00930 StylesheetExecutionContext& executionContext, 00931 XalanNode* targetNode, 00932 XalanNode::NodeType targetNodeType, 00933 const XalanQName& mode) const; 00934 00939 XalanDOMString m_XSLTNamespaceURI; 00940 00944 StylesheetVectorType m_imports; 00945 00946 StylesheetVectorType::size_type m_importsSize; 00947 00951 NamespacesStackType m_namespaces; 00952 00957 NamespaceVectorType m_namespaceDecls; 00958 00963 bool m_isWrapperless; 00964 00968 ExtensionNamespacesMapType m_extensionNamespaces; 00969 00973 ElemTemplate* m_firstTemplate; 00974 00979 URLStackType m_includeStack; 00980 00986 ElemTemplateMapType m_namedTemplates; 00987 00991 ElemVariableVectorType m_topLevelVariables; 00992 00996 double m_XSLTVerDeclared; 00997 01003 PatternTableMapType m_elementPatternTable; 01004 01005 const PatternTableMapType::const_iterator m_elementPatternTableEnd; 01006 01007 PatternTableVectorType m_elementAnyPatternList; 01008 01014 PatternTableMapType m_attributePatternTable; 01015 01016 const PatternTableMapType::const_iterator m_attributePatternTableEnd; 01017 01018 PatternTableVectorType m_attributeAnyPatternList; 01019 01023 PatternTableVectorType m_textPatternList; 01024 01025 PatternTableVectorType m_commentPatternList; 01026 01027 PatternTableVectorType m_rootPatternList; 01028 01029 PatternTableVectorType m_piPatternList; 01030 01034 PatternTableVectorType m_nodePatternList; 01035 01040 MatchPattern2Container m_matchPattern2Container; 01041 01045 MatchPattern2Container::size_type m_patternCount; 01046 01047 ElemDecimalFormatVectorType m_elemDecimalFormats; 01048 01049 NamespacesHandler m_namespacesHandler; 01050 01051 static const XalanDOMString s_emptyString; 01052 }; 01053 01054 01055 01056 XALAN_CPP_NAMESPACE_END 01057 01058 01059 01060 #endif // XALAN_STYLESHEET_HEADER_GUARD
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
![]() |
Xalan-C++ XSLT Processor Version 1.7 |
|