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 * $ 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 ElemAttributeSet; 00103 class ElemDecimalFormat; 00104 class ElemTemplate; 00105 class ElemTemplateElement; 00106 class ElemVariable; 00107 class KeyTable; 00108 class NodeRefListBase; 00109 class PrefixResolver; 00110 class StylesheetConstructionContext; 00111 class StylesheetRoot; 00112 class XalanQName; 00113 class XObject; 00114 class StylesheetExecutionContext; 00115 00116 00117 00122 class XALAN_XSLT_EXPORT Stylesheet : protected PrefixResolver 00123 { 00124 00125 public: 00126 00127 #if defined(XALAN_STRICT_ANSI_HEADERS) 00128 typedef std::size_t size_type; 00129 #else 00130 typedef size_t size_type; 00131 #endif 00132 00133 typedef StylesheetExecutionContext::ParamVectorType ParamVectorType; 00134 typedef XalanQName::NamespaceVectorType NamespaceVectorType; 00135 typedef XalanQName::NamespacesStackType NamespacesStackType; 00136 00137 #if defined(XALAN_NO_STD_NAMESPACE) 00138 typedef map<XalanDOMString, 00139 ExtensionNSHandler*, 00140 less<XalanDOMString> > ExtensionNamespacesMapType; 00141 typedef map<XalanQNameByReference, 00142 const ElemTemplate*, 00143 less<XalanQName> > ElemTemplateMapType; 00144 typedef vector<ElemAttributeSet*> AttributeSetVectorType; 00145 typedef vector<ElemVariable*> ElemVariableVectorType; 00146 typedef vector<KeyDeclaration> KeyDeclarationVectorType; 00147 typedef map<const XalanNode*, 00148 KeyTable*, 00149 less<const XalanNode*> > KeyTablesTableType; 00150 typedef vector<Stylesheet*> StylesheetVectorType; 00151 typedef vector<XalanDOMString> URLStackType; 00152 typedef vector<ElemDecimalFormat*> ElemDecimalFormatVectorType; 00153 #else 00154 typedef std::map<XalanDOMString, ExtensionNSHandler*> ExtensionNamespacesMapType; 00155 typedef std::map<XalanQNameByReference, 00156 const ElemTemplate*, 00157 std::less<XalanQName> > ElemTemplateMapType; 00158 typedef std::vector<ElemAttributeSet*> AttributeSetVectorType; 00159 typedef std::vector<ElemVariable*> ElemVariableVectorType; 00160 typedef std::vector<KeyDeclaration> KeyDeclarationVectorType; 00161 typedef std::map<const XalanNode*, KeyTable*> KeyTablesTableType; 00162 typedef std::vector<Stylesheet*> StylesheetVectorType; 00163 typedef std::vector<XalanDOMString> URLStackType; 00164 typedef std::vector<ElemDecimalFormat*> ElemDecimalFormatVectorType; 00165 #endif 00166 00172 Stylesheet( 00173 StylesheetRoot& root, 00174 const XalanDOMString& baseIdentifier, 00175 StylesheetConstructionContext& constructionContext); 00176 00177 virtual 00178 ~Stylesheet(); 00179 00185 double 00186 getXSLTVerDeclared() const 00187 { 00188 return m_XSLTVerDeclared; 00189 } 00190 00196 void 00197 setXSLTVerDeclared(double ver) 00198 { 00199 m_XSLTVerDeclared = ver; 00200 } 00201 00207 const StylesheetRoot& 00208 getStylesheetRoot() const 00209 { 00210 return m_stylesheetRoot; 00211 } 00212 00218 StylesheetRoot& 00219 getStylesheetRoot() 00220 { 00221 return m_stylesheetRoot; 00222 } 00223 00229 const NamespacesStackType& 00230 getNamespaces() const 00231 { 00232 return m_namespaces; 00233 } 00234 00240 NamespacesStackType& 00241 getNamespaces() 00242 { 00243 return m_namespaces; 00244 } 00245 00246 const NamespacesHandler& 00247 getNamespacesHandler() const 00248 { 00249 return m_namespacesHandler; 00250 } 00251 00252 NamespacesHandler& 00253 getNamespacesHandler() 00254 { 00255 return m_namespacesHandler; 00256 } 00257 00263 const NamespaceVectorType& 00264 getNamespaceDecls() const 00265 { 00266 return m_namespaceDecls; 00267 } 00268 00274 NamespaceVectorType& 00275 getNamespaceDecls() 00276 { 00277 return m_namespaceDecls; 00278 } 00279 00285 void 00286 setNamespaceDecls(const NamespaceVectorType& ns) 00287 { 00288 m_namespaceDecls = ns; 00289 } 00290 00297 void 00298 pushNamespaces(const AttributeListType& atts); 00299 00303 void 00304 popNamespaces() 00305 { 00306 assert(m_namespaces.empty() == false); 00307 00308 m_namespaces.pop_back(); 00309 } 00310 00314 virtual void 00315 postConstruction(StylesheetConstructionContext& constructionContext); 00316 00326 bool 00327 isAttrOK( 00328 const XalanDOMChar* attrName, 00329 const AttributeListType& atts, 00330 int which, 00331 StylesheetConstructionContext& constructionContext) const; 00332 00339 const XalanDOMString* 00340 getNamespaceFromStack(const XalanDOMString& nodeName) const 00341 { 00342 return getNamespaceFromStack(c_wstr(nodeName)); 00343 } 00344 00351 const XalanDOMString* 00352 getNamespaceFromStack(const XalanDOMChar* nodeName) const; 00353 00361 const XalanDOMString* 00362 getNamespaceForPrefixFromStack(const XalanDOMString& prefix) const 00363 { 00364 return XalanQName::getNamespaceForPrefix(m_namespaces, prefix); 00365 } 00366 00374 const XalanDOMString* 00375 getNamespaceForPrefixFromStack(const XalanDOMChar* prefix) const 00376 { 00377 assert(prefix != 0); 00378 00379 return XalanQName::getNamespaceForPrefix(m_namespaces, XalanDOMString(prefix)); 00380 } 00381 00389 void 00390 processExcludeResultPrefixes( 00391 StylesheetConstructionContext& theConstructionContext, 00392 const XalanDOMChar* theValue) 00393 { 00394 m_namespacesHandler.processExcludeResultPrefixes( 00395 theConstructionContext, 00396 theValue, 00397 m_namespaces); 00398 } 00399 00406 void 00407 addTemplate( 00408 ElemTemplate* theTemplate, 00409 StylesheetConstructionContext& constructionContext); 00410 00419 bool 00420 getYesOrNo( 00421 const XalanDOMChar* aname, 00422 const XalanDOMChar* val, 00423 StylesheetConstructionContext& constructionContext) const; 00424 00430 const XalanDOMString& 00431 getBaseIdentifier() const 00432 { 00433 return m_baseIdent; 00434 } 00435 00441 void 00442 setBaseIdentifier(const XalanDOMString& str) 00443 { 00444 m_baseIdent = str; 00445 } 00446 00455 const XalanDOMString& 00456 getCurrentIncludeBaseIdentifier() const 00457 { 00458 return m_includeStack.empty() == true ? getBaseIdentifier() : m_includeStack.back(); 00459 } 00460 00468 void 00469 processNSAliasElement( 00470 const XalanDOMChar* name, 00471 const AttributeListType& atts, 00472 StylesheetConstructionContext& constructionContext); 00473 00479 void 00480 processDecimalFormatElement( 00481 StylesheetConstructionContext& constructionContext, 00482 const AttributeListType& atts, 00483 const LocatorType* locator = 0); 00484 00492 const XalanDecimalFormatSymbols* 00493 getDecimalFormatSymbols(const XalanQName& theQName) const; 00494 00500 void 00501 addAttributeSet(ElemAttributeSet* attrSet) 00502 { 00503 assert(attrSet != 0); 00504 00505 m_attributeSets.push_back(attrSet); 00506 } 00507 00517 void 00518 applyAttrSets( 00519 const XalanQName** attributeSetsNames, 00520 size_type attributeSetsNamesCount, 00521 StylesheetExecutionContext& executionContext, 00522 XalanNode* sourceNode) const; 00523 00529 void 00530 addImport(Stylesheet* theStylesheet) 00531 { 00532 m_imports.insert(m_imports.begin(), theStylesheet); 00533 } 00534 00540 bool 00541 isWrapperless() const 00542 { 00543 return m_isWrapperless; 00544 } 00545 00546 ElemTemplateElement* 00547 initWrapperless( 00548 StylesheetConstructionContext& constructionContext, 00549 const LocatorType* locator); 00550 00556 URLStackType& 00557 getIncludeStack() 00558 { 00559 return m_includeStack; 00560 } 00561 00570 void 00571 processKeyElement( 00572 const PrefixResolver& nsContext, 00573 const AttributeListType& atts, 00574 const LocatorType* locator, 00575 StylesheetConstructionContext& constructionContext); 00576 00583 const ElemTemplate* 00584 findNamedTemplate(const XalanQName& qname) const; 00585 00594 const ElemTemplate* 00595 findTemplate( 00596 StylesheetExecutionContext& executionContext, 00597 XalanNode* targetNode) const 00598 { 00599 assert(targetNode != 0); 00600 00601 return findTemplate( 00602 executionContext, 00603 targetNode, 00604 targetNode->getNodeType(), 00605 s_emptyQName, 00606 false); 00607 } 00608 00620 const ElemTemplate* 00621 findTemplate( 00622 StylesheetExecutionContext& executionContext, 00623 XalanNode* targetNode, 00624 XalanNode::NodeType targetNodeType, 00625 const XalanQName& mode, 00626 bool onlyUseImports) const; 00627 00632 class MatchPattern2 00633 { 00634 public: 00635 00636 typedef XPath::eMatchScore eMatchScore; 00637 00648 MatchPattern2( 00649 const ElemTemplate& theTemplate, 00650 size_type posInStylesheet, 00651 const XalanDOMString& targetString, 00652 const XPath& matchPattern, 00653 const XalanDOMString& pattern, 00654 eMatchScore priority) : 00655 m_template(&theTemplate), 00656 m_posInStylesheet(posInStylesheet), 00657 m_targetString(targetString), 00658 m_matchPattern(&matchPattern), 00659 m_pattern(&pattern), 00660 m_priority(priority) 00661 { 00662 } 00663 00664 MatchPattern2() : 00665 m_template(0), 00666 m_posInStylesheet(0), 00667 m_targetString(), 00668 m_matchPattern(0), 00669 m_pattern(0), 00670 m_priority(XPath::eMatchScoreNone) 00671 { 00672 } 00673 00674 ~MatchPattern2() 00675 { 00676 } 00677 00683 const XalanDOMString& 00684 getTargetString() const 00685 { 00686 return m_targetString; 00687 } 00688 00694 const XPath* 00695 getExpression() const 00696 { 00697 return m_matchPattern; 00698 } 00699 00705 size_type 00706 getPositionInStylesheet() const 00707 { 00708 return m_posInStylesheet; 00709 } 00710 00716 const XalanDOMString* 00717 getPattern() const 00718 { 00719 return m_pattern; 00720 } 00721 00727 const ElemTemplate* 00728 getTemplate() const 00729 { 00730 return m_template; 00731 } 00732 00733 eMatchScore 00734 getDefaultPriority() const 00735 { 00736 return m_priority; 00737 } 00738 00739 double 00740 getPriorityOrDefault() const; 00741 00742 private: 00743 00744 const ElemTemplate* m_template; 00745 size_type m_posInStylesheet; 00746 XalanDOMString m_targetString; 00747 const XPath* m_matchPattern; 00748 const XalanDOMString* m_pattern; 00749 eMatchScore m_priority; 00750 }; 00751 00752 #if defined(XALAN_NO_STD_NAMESPACE) 00753 typedef vector<const MatchPattern2*> PatternTableVectorType; 00754 00755 typedef map<XalanDOMString, 00756 PatternTableVectorType, 00757 less<XalanDOMString> > PatternTableMapType; 00758 00759 typedef deque<MatchPattern2> MatchPattern2Container; 00760 #else 00761 typedef std::vector<const MatchPattern2*> PatternTableVectorType; 00762 00763 typedef std::map<XalanDOMString, 00764 PatternTableVectorType> PatternTableMapType; 00765 00766 typedef std::deque<MatchPattern2> MatchPattern2Container; 00767 #endif 00768 00775 static void 00776 addObjectIfNotFound( 00777 const MatchPattern2* thePattern, 00778 PatternTableVectorType& theVector); 00779 00789 static void 00790 addObjectIfNotFound( 00791 const MatchPattern2* thePattern, 00792 const MatchPattern2* theArray[], 00793 unsigned int& theArraySize); 00794 00802 const PatternTableVectorType* 00803 locateElementMatchPatternList2(const XalanDOMString& theName) const; 00804 00812 const PatternTableVectorType* 00813 locateAttributeMatchPatternList2(const XalanDOMString& theName) const; 00814 00821 const PatternTableVectorType* 00822 locateMatchPatternList2( 00823 const XalanNode& theNode, 00824 XalanNode::NodeType targetNodeType) const; 00825 00834 void 00835 processExtensionNamespace( 00836 StylesheetConstructionContext& theConstructionContext, 00837 const XalanDOMString& uri); 00838 00845 ExtensionNSHandler* 00846 lookupExtensionNSHandler(const XalanDOMString& uri) const 00847 { 00848 const ExtensionNamespacesMapType::const_iterator it = 00849 m_extensionNamespaces.find(uri); 00850 00851 return it == m_extensionNamespaces.end() ? 0 : (*it).second; 00852 } 00853 00860 void 00861 setTopLevelVariable(ElemVariable* var) 00862 { 00863 m_topLevelVariables.push_back(var); 00864 } 00865 00873 void 00874 pushTopLevelVariables( 00875 StylesheetExecutionContext& executionContext, 00876 const ParamVectorType& topLevelParams) const; 00877 00878 00879 // These interfaces are inherited from PrefixResolver... 00880 00881 virtual const XalanDOMString* 00882 getNamespaceForPrefix(const XalanDOMString& prefix) const; 00883 00884 virtual const XalanDOMString& 00885 getURI() const; 00886 00887 const XalanDOMString& 00888 getXSLTNamespaceURI() const 00889 { 00890 return m_XSLTNamespaceURI; 00891 } 00892 00893 void 00894 setXSLTNamespaceURI(const XalanDOMString& theURI) 00895 { 00896 m_XSLTNamespaceURI = theURI; 00897 } 00898 00899 protected: 00900 00904 StylesheetRoot& m_stylesheetRoot; 00905 00909 XalanDOMString m_baseIdent; 00910 00915 KeyDeclarationVectorType m_keyDeclarations; 00916 00917 static const XalanQNameByReference s_emptyQName; 00918 00919 private: 00920 00921 // Not defined... 00922 Stylesheet(const Stylesheet&); 00923 00924 Stylesheet& 00925 operator=(const Stylesheet&); 00926 00927 bool 00928 operator==(const Stylesheet&) const; 00929 00930 00941 const ElemTemplate* 00942 findTemplateInImports( 00943 StylesheetExecutionContext& executionContext, 00944 XalanNode* targetNode, 00945 XalanNode::NodeType targetNodeType, 00946 const XalanQName& mode) const; 00947 00952 XalanDOMString m_XSLTNamespaceURI; 00953 00957 StylesheetVectorType m_imports; 00958 00959 StylesheetVectorType::size_type m_importsSize; 00960 00964 NamespacesStackType m_namespaces; 00965 00970 NamespaceVectorType m_namespaceDecls; 00971 00976 bool m_isWrapperless; 00977 00981 ExtensionNamespacesMapType m_extensionNamespaces; 00982 00986 ElemTemplate* m_firstTemplate; 00987 00992 URLStackType m_includeStack; 00993 00999 ElemTemplateMapType m_namedTemplates; 01000 01004 ElemVariableVectorType m_topLevelVariables; 01005 01009 double m_XSLTVerDeclared; 01010 01016 PatternTableMapType m_elementPatternTable; 01017 01018 const PatternTableMapType::const_iterator m_elementPatternTableEnd; 01019 01020 PatternTableVectorType m_elementAnyPatternList; 01021 01027 PatternTableMapType m_attributePatternTable; 01028 01029 const PatternTableMapType::const_iterator m_attributePatternTableEnd; 01030 01031 PatternTableVectorType m_attributeAnyPatternList; 01032 01036 PatternTableVectorType m_textPatternList; 01037 01038 PatternTableVectorType m_commentPatternList; 01039 01040 PatternTableVectorType m_rootPatternList; 01041 01042 PatternTableVectorType m_piPatternList; 01043 01047 PatternTableVectorType m_nodePatternList; 01048 01053 MatchPattern2Container m_matchPattern2Container; 01054 01058 MatchPattern2Container::size_type m_patternCount; 01059 01060 AttributeSetVectorType m_attributeSets; 01061 01065 AttributeSetVectorType::size_type m_attributeSetsSize; 01066 01067 ElemDecimalFormatVectorType m_elemDecimalFormats; 01068 01069 NamespacesHandler m_namespacesHandler; 01070 01071 static const XalanDOMString s_emptyString; 01072 }; 01073 01074 01075 01076 XALAN_CPP_NAMESPACE_END 01077 01078 01079 01080 #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.6 |
|