Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.8

Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

Stylesheet.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 1999-2004 The Apache Software Foundation.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #if !defined(XALAN_STYLESHEET_HEADER_GUARD)
00018 #define XALAN_STYLESHEET_HEADER_GUARD
00019 
00020 
00021 
00022 // Base include file.  Must be first.
00023 #include "XSLTDefinitions.hpp"
00024 
00025 
00026 
00027 #include <deque>
00028 #include <map>
00029 #include <vector>
00030 
00031 
00032 
00033 #include <xalanc/XalanDOM/XalanNode.hpp>
00034 
00035 
00036 #include <xalanc/PlatformSupport/PrefixResolver.hpp>
00037 
00038 
00039 
00040 #include <xalanc/XPath/NameSpace.hpp>
00041 #include <xalanc/XPath/XalanQNameByReference.hpp>
00042 #include <xalanc/XPath/XPath.hpp>
00043 
00044 
00045 
00046 #include <xalanc/XSLT/NamespacesHandler.hpp>
00047 #include <xalanc/XSLT/KeyDeclaration.hpp>
00048 #include <xalanc/XSLT/StylesheetExecutionContext.hpp>
00049 #include <xalanc/XSLT/XalanSpaceNodeTester.hpp>
00050 
00051 
00052 
00053 XALAN_CPP_NAMESPACE_BEGIN
00054 
00055 
00056 
00057 class ExtensionNSHandler;
00058 class XalanDecimalFormatSymbols;
00059 class ElemDecimalFormat;
00060 class ElemTemplate;
00061 class ElemTemplateElement;
00062 class ElemVariable;
00063 class KeyTable;
00064 class NodeRefListBase;
00065 class PrefixResolver;
00066 class StylesheetConstructionContext;
00067 class StylesheetRoot;
00068 class XalanQName;
00069 class XObject;
00070 class StylesheetExecutionContext;
00071 
00072 
00073 
00078 class XALAN_XSLT_EXPORT Stylesheet : protected PrefixResolver
00079 {   
00080 
00081 public:
00082 
00083 #if defined(XALAN_STRICT_ANSI_HEADERS)
00084     typedef std::size_t     size_type;
00085 #else
00086     typedef size_t          size_type;
00087 #endif
00088 
00089     typedef StylesheetExecutionContext::ParamVectorType     ParamVectorType;
00090     typedef XalanQName::NamespaceVectorType                 NamespaceVectorType;
00091     typedef XalanQName::NamespacesStackType                 NamespacesStackType;
00092 
00093 #if defined(XALAN_NO_STD_NAMESPACE)
00094     typedef map<XalanDOMString,
00095                 ExtensionNSHandler*,
00096                 less<XalanDOMString> >              ExtensionNamespacesMapType;
00097     typedef map<XalanQNameByReference,
00098                 const ElemTemplate*,
00099                 less<XalanQName> >                  ElemTemplateMapType;
00100     typedef vector<ElemVariable*>                   ElemVariableVectorType;
00101     typedef vector<KeyDeclaration>                  KeyDeclarationVectorType;
00102     typedef map<const XalanNode*,
00103                 KeyTable*,
00104                 less<const XalanNode*> >            KeyTablesTableType;
00105     typedef vector<Stylesheet*>                     StylesheetVectorType;
00106     typedef vector<XalanDOMString>                  URLStackType;
00107     typedef vector<ElemDecimalFormat*>              ElemDecimalFormatVectorType;
00108     typedef vector<XalanSpaceNodeTester>            WhitespaceElementsVectorType;
00109 #else
00110     typedef std::map<XalanDOMString, ExtensionNSHandler*>   ExtensionNamespacesMapType;
00111     typedef std::map<XalanQNameByReference,
00112                      const ElemTemplate*,
00113                      std::less<XalanQName> >                ElemTemplateMapType;
00114     typedef std::vector<ElemVariable*>                      ElemVariableVectorType;
00115     typedef std::vector<KeyDeclaration>                     KeyDeclarationVectorType;
00116     typedef std::map<const XalanNode*, KeyTable*>           KeyTablesTableType;
00117     typedef std::vector<Stylesheet*>                        StylesheetVectorType;
00118     typedef std::vector<XalanDOMString>                     URLStackType;
00119     typedef std::vector<ElemDecimalFormat*>                 ElemDecimalFormatVectorType;
00120     typedef std::vector<XalanSpaceNodeTester>               WhitespaceElementsVectorType;
00121 #endif
00122 
00128     Stylesheet(
00129             StylesheetRoot&                 root,
00130             const XalanDOMString&           baseIdentifier,
00131             StylesheetConstructionContext&  constructionContext);
00132 
00133     virtual
00134     ~Stylesheet();
00135 
00141     double
00142     getXSLTVerDeclared() const
00143     {
00144         return m_XSLTVerDeclared;
00145     }
00146 
00152     void
00153     setXSLTVerDeclared(double ver)
00154     {
00155         m_XSLTVerDeclared = ver;
00156     }
00157 
00163     const StylesheetRoot&
00164     getStylesheetRoot() const
00165     {
00166         return m_stylesheetRoot;
00167     }
00168 
00174     StylesheetRoot&
00175     getStylesheetRoot()
00176     {
00177         return m_stylesheetRoot;
00178     }
00179 
00185     const NamespacesStackType&
00186     getNamespaces() const
00187     { 
00188         return m_namespaces;
00189     }
00190 
00196     NamespacesStackType&
00197     getNamespaces()
00198     { 
00199         return m_namespaces;
00200     }
00201 
00202     const NamespacesHandler&
00203     getNamespacesHandler() const
00204     {
00205         return m_namespacesHandler;
00206     }
00207 
00208     NamespacesHandler&
00209     getNamespacesHandler()
00210     {
00211         return m_namespacesHandler;
00212     }
00213 
00219     const NamespaceVectorType&
00220     getNamespaceDecls() const
00221     {
00222         return m_namespaceDecls;
00223     }
00224 
00230     NamespaceVectorType&
00231     getNamespaceDecls()
00232     {
00233         return m_namespaceDecls;
00234     }
00235 
00241     void
00242     setNamespaceDecls(const NamespaceVectorType& ns)
00243     {
00244         m_namespaceDecls = ns;
00245     }
00246 
00253     void
00254     pushNamespaces(const AttributeListType&     atts);
00255 
00259     void
00260     popNamespaces()
00261     {
00262         assert(m_namespaces.empty() == false);
00263 
00264         m_namespaces.pop_back(); 
00265     }
00266 
00267     void
00268     addWhitespaceElement(const XalanSpaceNodeTester&    theTester);
00269 
00273     virtual void
00274     postConstruction(StylesheetConstructionContext&     constructionContext);
00275 
00285     bool
00286     isAttrOK(
00287             const XalanDOMChar*             attrName,
00288             const AttributeListType&        atts,
00289             int                             which,
00290             StylesheetConstructionContext&  constructionContext) const;
00291 
00298     const XalanDOMString*
00299     getNamespaceFromStack(const XalanDOMString&     nodeName) const
00300     {
00301         return getNamespaceFromStack(c_wstr(nodeName));
00302     }
00303 
00310     const XalanDOMString*
00311     getNamespaceFromStack(const XalanDOMChar*   nodeName) const;
00312 
00320     const XalanDOMString*
00321     getNamespaceForPrefixFromStack(const XalanDOMString&    prefix) const
00322     {
00323         return XalanQName::getNamespaceForPrefix(m_namespaces, prefix);
00324     }
00325 
00333     const XalanDOMString*
00334     getNamespaceForPrefixFromStack(const XalanDOMChar*  prefix) const
00335     {
00336         assert(prefix != 0);
00337 
00338         return XalanQName::getNamespaceForPrefix(m_namespaces, XalanDOMString(prefix));
00339     }
00340 
00348     const XalanDOMString*
00349     getNamespaceForPrefix(
00350             const XalanDOMString&           prefix,
00351             StylesheetConstructionContext&  constructionContext) const;
00352 
00360     const XalanDOMString*
00361     getNamespaceForPrefix(
00362             const XalanDOMChar*             prefix,
00363             StylesheetConstructionContext&  constructionContext) const;
00364 
00372     void
00373     processExcludeResultPrefixes(
00374         StylesheetConstructionContext&  theConstructionContext,
00375         const XalanDOMChar*             theValue)
00376     {
00377         m_namespacesHandler.processExcludeResultPrefixes(
00378                 theConstructionContext,
00379                 theValue,
00380                 m_namespaces);
00381     }
00382 
00389     void
00390     addTemplate(
00391             ElemTemplate*                   theTemplate,
00392             StylesheetConstructionContext&  constructionContext);
00393 
00402     bool
00403     getYesOrNo(
00404             const XalanDOMChar*             aname,
00405             const XalanDOMChar*             val,
00406             StylesheetConstructionContext&  constructionContext) const;
00407 
00413     const XalanDOMString&
00414     getBaseIdentifier() const
00415     {
00416         return m_baseIdent;
00417     }
00418 
00427     const XalanDOMString&
00428     getCurrentIncludeBaseIdentifier() const
00429     {
00430         return m_includeStack.empty() == true ? getBaseIdentifier() : m_includeStack.back();
00431     }
00432 
00440     void
00441     processNSAliasElement(
00442             const XalanDOMChar*             name,
00443             const AttributeListType&        atts,
00444             StylesheetConstructionContext&  constructionContext);
00445 
00451     void
00452     processDecimalFormatElement(
00453             StylesheetConstructionContext&  constructionContext,
00454             const AttributeListType&        atts,
00455             const LocatorType*              locator = 0);
00456 
00464     const XalanDecimalFormatSymbols*
00465     getDecimalFormatSymbols(const XalanQName&   theQName) const;
00466 
00472     void
00473     addImport(Stylesheet*   theStylesheet)
00474     {
00475         m_imports.insert(m_imports.begin(), theStylesheet);
00476     }
00477 
00483     bool
00484     isWrapperless() const
00485     {
00486         return m_isWrapperless;
00487     }
00488 
00489     ElemTemplateElement*
00490     initWrapperless(
00491             StylesheetConstructionContext&  constructionContext,
00492             const LocatorType*              locator);
00493 
00499     URLStackType&
00500     getIncludeStack()
00501     {
00502         return m_includeStack;
00503     }
00504 
00513     void
00514     processKeyElement(
00515             const PrefixResolver&           nsContext,
00516             const AttributeListType&        atts,
00517             const LocatorType*              locator,
00518             StylesheetConstructionContext&  constructionContext);
00519 
00526     const ElemTemplate*
00527     findNamedTemplate(const XalanQName&     qname) const;
00528 
00537     const ElemTemplate*
00538     findTemplate(
00539             StylesheetExecutionContext&     executionContext,
00540             XalanNode*                      targetNode) const
00541     {
00542         assert(targetNode != 0);
00543 
00544         return findTemplate(
00545                 executionContext,
00546                 targetNode,
00547                 targetNode->getNodeType(),
00548                 s_emptyQName,
00549                 false);
00550     }
00551 
00563     const ElemTemplate*
00564     findTemplate(
00565             StylesheetExecutionContext&     executionContext,
00566             XalanNode*                      targetNode,
00567             XalanNode::NodeType             targetNodeType,
00568             const XalanQName&               mode,
00569             bool                            onlyUseImports) const;
00570 
00575     class MatchPattern2
00576     {
00577     public:
00578 
00579         typedef XPath::eMatchScore  eMatchScore;
00580 
00591         MatchPattern2(
00592                 const ElemTemplate&     theTemplate,
00593                 size_type               posInStylesheet,
00594                 const XalanDOMString&   targetString,
00595                 const XPath&            matchPattern,
00596                 const XalanDOMString&   pattern,
00597                 eMatchScore             priority) :
00598             m_template(&theTemplate),
00599             m_posInStylesheet(posInStylesheet),
00600             m_targetString(targetString),
00601             m_matchPattern(&matchPattern),
00602             m_pattern(&pattern),
00603             m_priority(priority)
00604         {
00605         }
00606 
00607         MatchPattern2() :
00608             m_template(0),
00609             m_posInStylesheet(0),
00610             m_targetString(),
00611             m_matchPattern(0),
00612             m_pattern(0),
00613             m_priority(XPath::eMatchScoreNone)
00614         {
00615         }
00616 
00617         ~MatchPattern2()
00618         {
00619         }
00620 
00626         const XalanDOMString&
00627         getTargetString() const
00628         {
00629             return m_targetString;
00630         }
00631 
00637         const XPath*
00638         getExpression() const
00639         {
00640             return m_matchPattern;
00641         }
00642 
00648         size_type
00649         getPositionInStylesheet() const
00650         {
00651             return m_posInStylesheet;
00652         }
00653 
00659         const XalanDOMString*
00660         getPattern() const
00661         {
00662             return m_pattern;
00663         }
00664 
00670         const ElemTemplate*
00671         getTemplate() const
00672         {
00673             return m_template;
00674         }
00675 
00676         eMatchScore
00677         getDefaultPriority() const
00678         {
00679             return m_priority;
00680         }
00681 
00682         double
00683         getPriorityOrDefault() const;
00684 
00685     private:
00686 
00687         const ElemTemplate*     m_template;
00688         size_type               m_posInStylesheet;
00689         XalanDOMString          m_targetString;
00690         const XPath*            m_matchPattern;
00691         const XalanDOMString*   m_pattern;
00692         eMatchScore             m_priority;
00693     };
00694 
00695 #if defined(XALAN_NO_STD_NAMESPACE)
00696     typedef vector<const MatchPattern2*>        PatternTableVectorType;
00697 
00698     typedef map<XalanDOMString,
00699                 PatternTableVectorType,
00700                 less<XalanDOMString> >          PatternTableMapType;
00701 
00702     typedef deque<MatchPattern2>                MatchPattern2Container;
00703 #else
00704     typedef std::vector<const MatchPattern2*>   PatternTableVectorType;
00705 
00706     typedef std::map<XalanDOMString,
00707                      PatternTableVectorType>    PatternTableMapType;
00708 
00709     typedef std::deque<MatchPattern2>           MatchPattern2Container;
00710 #endif
00711 
00718     static void
00719     addObjectIfNotFound(
00720             const MatchPattern2*        thePattern,
00721             PatternTableVectorType&     theVector);
00722 
00732     static void
00733     addObjectIfNotFound(
00734             const MatchPattern2*    thePattern,
00735             const MatchPattern2*    theArray[],
00736             unsigned int&           theArraySize);
00737 
00745     const PatternTableVectorType*
00746     locateElementMatchPatternList2(const XalanDOMString&    theName) const;
00747 
00755     const PatternTableVectorType*
00756     locateAttributeMatchPatternList2(const XalanDOMString&  theName) const;
00757 
00764     const PatternTableVectorType*
00765     locateMatchPatternList2(
00766             const XalanNode&        theNode,
00767             XalanNode::NodeType     targetNodeType) const;
00768 
00777     void
00778     processExtensionNamespace(
00779             StylesheetConstructionContext&  theConstructionContext,
00780             const XalanDOMString&           uri);
00781 
00788     ExtensionNSHandler*
00789     lookupExtensionNSHandler(const XalanDOMString&  uri) const
00790     {
00791         const ExtensionNamespacesMapType::const_iterator    it = 
00792           m_extensionNamespaces.find(uri);
00793 
00794         return it == m_extensionNamespaces.end() ? 0 : (*it).second;
00795     }
00796 
00803     void
00804     setTopLevelVariable(ElemVariable*   var)
00805     {
00806         m_topLevelVariables.push_back(var);
00807     }
00808 
00816     void
00817     pushTopLevelVariables(
00818             StylesheetExecutionContext&     executionContext,
00819             const ParamVectorType&          topLevelParams) const;
00820 
00821 
00822     // These interfaces are inherited from PrefixResolver...
00823 
00824     virtual const XalanDOMString*
00825     getNamespaceForPrefix(const XalanDOMString&     prefix) const;
00826 
00827     virtual const XalanDOMString&
00828     getURI() const;
00829 
00830     const XalanDOMString&
00831     getXSLTNamespaceURI() const
00832     {
00833         return m_XSLTNamespaceURI;
00834     }
00835 
00836     void
00837     setXSLTNamespaceURI(const XalanDOMString&   theURI)
00838     {
00839         m_XSLTNamespaceURI = theURI;
00840     }
00841 
00842     const ElemTemplate* 
00843     getFirstTemplate() const    
00844     {
00845         return m_firstTemplate;
00846     }
00847     
00848 protected:
00849 
00853     StylesheetRoot&                     m_stylesheetRoot;
00854 
00858     XalanDOMString                      m_baseIdent;
00859 
00864     KeyDeclarationVectorType            m_keyDeclarations;
00865 
00866     WhitespaceElementsVectorType        m_whitespaceElements;
00867 
00868     static const XalanQNameByReference  s_emptyQName;
00869 
00870 private:    
00871 
00872     // Not defined...
00873     Stylesheet(const Stylesheet&);
00874 
00875     Stylesheet&
00876     operator=(const Stylesheet&);
00877 
00878     bool
00879     operator==(const Stylesheet&) const;
00880 
00881 
00892     const ElemTemplate*
00893     findTemplateInImports(
00894             StylesheetExecutionContext&     executionContext,
00895             XalanNode*                      targetNode,
00896             XalanNode::NodeType             targetNodeType,
00897             const XalanQName&               mode) const;
00898 
00903     XalanDOMString                          m_XSLTNamespaceURI;
00904 
00908     StylesheetVectorType                    m_imports;
00909 
00910     StylesheetVectorType::size_type         m_importsSize;
00911 
00915     NamespacesStackType                     m_namespaces;
00916 
00921     NamespaceVectorType                     m_namespaceDecls;
00922 
00927     bool                                    m_isWrapperless;
00928 
00932     ExtensionNamespacesMapType              m_extensionNamespaces;
00933 
00937     ElemTemplate*                           m_firstTemplate;
00938 
00943     URLStackType                            m_includeStack;
00944 
00950     ElemTemplateMapType                     m_namedTemplates;
00951 
00955     ElemVariableVectorType                  m_topLevelVariables;
00956 
00960     double                                  m_XSLTVerDeclared;
00961 
00967     PatternTableMapType                         m_elementPatternTable;
00968 
00969     const PatternTableMapType::const_iterator   m_elementPatternTableEnd;
00970 
00971     PatternTableVectorType                      m_elementAnyPatternList;
00972 
00978     PatternTableMapType                         m_attributePatternTable;
00979 
00980     const PatternTableMapType::const_iterator   m_attributePatternTableEnd;
00981 
00982     PatternTableVectorType                      m_attributeAnyPatternList;
00983 
00987     PatternTableVectorType                  m_textPatternList;
00988 
00989     PatternTableVectorType                  m_commentPatternList;
00990 
00991     PatternTableVectorType                  m_rootPatternList;
00992 
00993     PatternTableVectorType                  m_piPatternList;
00994 
00998     PatternTableVectorType                  m_nodePatternList;
00999 
01004     MatchPattern2Container                  m_matchPattern2Container;
01005 
01009     MatchPattern2Container::size_type       m_patternCount;
01010 
01011     ElemDecimalFormatVectorType             m_elemDecimalFormats;
01012 
01013     NamespacesHandler                       m_namespacesHandler;
01014 
01015     static const XalanDOMString             s_emptyString;
01016 };
01017 
01018 
01019 
01020 XALAN_CPP_NAMESPACE_END
01021 
01022 
01023 
01024 #endif  // XALAN_STYLESHEET_HEADER_GUARD

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

Xalan-C++ XSLT Processor Version 1.8
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.