## Xalan-C++ API Documentation

### The Xalan C++ XSLT Processor Version 1.10

Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members

# 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 <xalanc/XalanDOM/XalanNode.hpp>
    00028 #include <xalanc/XalanDOM/XalanDOMString.hpp>
    00029
    00030
    00031
    00032 #include <xalanc/Include/XalanVector.hpp>
    00033 #include <xalanc/Include/XalanMap.hpp>
    00034
    00035
    00036
    00037 #include <xalanc/PlatformSupport/PrefixResolver.hpp>
    00038
    00039
    00040
    00041 #include <xalanc/XPath/NameSpace.hpp>
    00042 #include <xalanc/XPath/XalanQNameByReference.hpp>
    00043 #include <xalanc/XPath/XPath.hpp>
    00044
    00045
    00046
    00047 #include <xalanc/XSLT/NamespacesHandler.hpp>
    00048 #include <xalanc/XSLT/KeyDeclaration.hpp>
    00049 #include <xalanc/XSLT/StylesheetConstructionContext.hpp>
    00050 #include <xalanc/XSLT/StylesheetExecutionContext.hpp>
    00051 #include <xalanc/XSLT/XalanSpaceNodeTester.hpp>
    00052
    00053
    00054
    00055 XALAN_CPP_NAMESPACE_BEGIN
    00056
    00057
    00058
    00059 class ExtensionNSHandler;
    00060 class XalanDecimalFormatSymbols;
    00061 class ElemDecimalFormat;
    00062 class ElemTemplate;
    00063 class ElemTemplateElement;
    00064 class ElemVariable;
    00065 class KeyTable;
    00066 class NodeRefListBase;
    00067 class PrefixResolver;
    00068 class StylesheetConstructionContext;
    00069 class StylesheetRoot;
    00070 class XalanMatchPatternData;
    00071 class XalanQName;
    00072 class XObject;
    00073 class StylesheetExecutionContext;
    00074
    00075
    00076 typedef XalanVector<const XalanMatchPatternData*>   PatternTableVectorTypeDecl;
    00077 XALAN_USES_MEMORY_MANAGER(PatternTableVectorTypeDecl)
    00078
    00079
    00084 class XALAN_XSLT_EXPORT Stylesheet : protected PrefixResolver
    00085 {
    00086
    00087 public:
    00088
    00089     typedef StylesheetConstructionContext::size_type        size_type;
    00090     typedef StylesheetExecutionContext::ParamVectorType     ParamVectorType;
    00091     typedef XalanQName::NamespaceVectorType                 NamespaceVectorType;
    00092     typedef XalanQName::NamespacesStackType                 NamespacesStackType;
    00093
    00094     typedef XalanVector<ElemVariable*>                  ElemVariableVectorType;
    00095     typedef XalanVector<KeyDeclaration>                 KeyDeclarationVectorType;
    00096     typedef XalanVector<Stylesheet*>                    StylesheetVectorType;
    00097     typedef XalanVector<XalanDOMString>                 URLStackType;
    00098     typedef XalanVector<ElemDecimalFormat*>             ElemDecimalFormatVectorType;
    00099     typedef XalanVector<XalanSpaceNodeTester>           WhitespaceElementsVectorType;
    00100     typedef PatternTableVectorTypeDecl                  PatternTableVectorType;
    00101
    00102     typedef  XalanMap<XalanDOMString, ExtensionNSHandler*>      ExtensionNamespacesMapType;
    00103
    00104     typedef  XalanMap<XalanQNameByReference,
    00105                          const ElemTemplate* >      ElemTemplateMapType;
    00106
    00107     typedef XalanMap<const XalanNode*, KeyTable* >  KeyTablesTableType;
    00108
    00109     typedef XalanMap<XalanDOMString, PatternTableVectorType> PatternTableMapType;
    00110
    00111     typedef StylesheetConstructionContext::GetAndReleaseCachedString    GetAndReleaseCachedString;
    00112
    00118     Stylesheet(
    00119             StylesheetRoot&                 root,
    00120             const XalanDOMString&           baseIdentifier,
    00121             StylesheetConstructionContext&  constructionContext);
    00122
    00123     virtual
    00124     ~Stylesheet();
    00125
    00126     static Stylesheet*
    00127     create(MemoryManagerType& theManager,
    00128             StylesheetRoot&                 root,
    00129             const XalanDOMString&           baseIdentifier,
    00130             StylesheetConstructionContext&  constructionContext);
    00131
    00132     MemoryManagerType&
    00133     getMemoryManager()
    00134     {
    00135         return m_elementPatternTable.getMemoryManager();
    00136     }
    00137
    00143     double
    00144     getXSLTVerDeclared() const
    00145     {
    00146         return m_XSLTVerDeclared;
    00147     }
    00148
    00154     void
    00155     setXSLTVerDeclared(double ver)
    00156     {
    00157         m_XSLTVerDeclared = ver;
    00158     }
    00159
    00165     const StylesheetRoot&
    00166     getStylesheetRoot() const
    00167     {
    00168         return m_stylesheetRoot;
    00169     }
    00170
    00176     StylesheetRoot&
    00177     getStylesheetRoot()
    00178     {
    00179         return m_stylesheetRoot;
    00180     }
    00181
    00187     const NamespacesStackType&
    00188     getNamespaces() const
    00189     {
    00190         return m_namespaces;
    00191     }
    00192
    00198     NamespacesStackType&
    00199     getNamespaces()
    00200     {
    00201         return m_namespaces;
    00202     }
    00203
    00204     const NamespacesHandler&
    00205     getNamespacesHandler() const
    00206     {
    00207         return m_namespacesHandler;
    00208     }
    00209
    00210     NamespacesHandler&
    00211     getNamespacesHandler()
    00212     {
    00213         return m_namespacesHandler;
    00214     }
    00215
    00221     const NamespaceVectorType&
    00222     getNamespaceDecls() const
    00223     {
    00224         return m_namespaceDecls;
    00225     }
    00226
    00232     NamespaceVectorType&
    00233     getNamespaceDecls()
    00234     {
    00235         return m_namespaceDecls;
    00236     }
    00237
    00243     void
    00244     setNamespaceDecls(const NamespaceVectorType& ns)
    00245     {
    00246         m_namespaceDecls = ns;
    00247     }
    00248
    00255     void
    00256     pushNamespaces(const AttributeListType&     atts);
    00257
    00261     void
    00262     popNamespaces()
    00263     {
    00264         assert(m_namespaces.empty() == false);
    00265
    00266         m_namespaces.pop_back();
    00267     }
    00268
    00269     void
    00270     addWhitespaceElement(const XalanSpaceNodeTester&    theTester);
    00271
    00275     virtual void
    00276     postConstruction(StylesheetConstructionContext&     constructionContext);
    00277
    00287     bool
    00288     isAttrOK(
    00289             const XalanDOMChar*             attrName,
    00290             const AttributeListType&        atts,
    00291             int                             which,
    00292             StylesheetConstructionContext&  constructionContext) const;
    00293
    00300     const XalanDOMString*
    00301     getNamespaceFromStack(const XalanDOMString&     nodeName,
    00302                             XalanDOMString&         theBuffer) const
    00303     {
    00304         return getNamespaceFromStack(c_wstr(nodeName), theBuffer);
    00305     }
    00306
    00313     const XalanDOMString*
    00314     getNamespaceFromStack(const XalanDOMChar*   nodeName,
    00315                             XalanDOMString&     theBuffer) const;
    00316
    00324     const XalanDOMString*
    00325     getNamespaceForPrefixFromStack(const XalanDOMString&    prefix) const
    00326     {
    00327         return XalanQName::getNamespaceForPrefix(m_namespaces, prefix);
    00328     }
    00329
    00337     const XalanDOMString*
    00338     getNamespaceForPrefixFromStack(const XalanDOMChar*  prefix) const
    00339     {
    00340         assert(prefix != 0);
    00341
    00342         return XalanQName::getNamespaceForPrefix(m_namespaces, (const XalanDOMChar*)prefix);
    00343     }
    00344
    00352     const XalanDOMString*
    00353     getNamespaceForPrefix(
    00354             const XalanDOMString&           prefix,
    00355             StylesheetConstructionContext&  constructionContext) const;
    00356
    00364     const XalanDOMString*
    00365     getNamespaceForPrefix(
    00366             const XalanDOMChar*             prefix,
    00367             StylesheetConstructionContext&  constructionContext) const;
    00368
    00376     void
    00377     processExcludeResultPrefixes(
    00378         StylesheetConstructionContext&  theConstructionContext,
    00379         const XalanDOMChar*             theValue)
    00380     {
    00381         m_namespacesHandler.processExcludeResultPrefixes(
    00382                 theConstructionContext,
    00383                 theValue,
    00384                 m_namespaces);
    00385     }
    00386
    00393     void
    00394     addTemplate(
    00395             ElemTemplate*                   theTemplate,
    00396             StylesheetConstructionContext&  constructionContext);
    00397
    00406     bool
    00407     getYesOrNo(
    00408             const XalanDOMChar*             aname,
    00409             const XalanDOMChar*             val,
    00410             StylesheetConstructionContext&  constructionContext) const;
    00411
    00417     const XalanDOMString&
    00418     getBaseIdentifier() const
    00419     {
    00420         return m_baseIdent;
    00421     }
    00422
    00431     const XalanDOMString&
    00432     getCurrentIncludeBaseIdentifier() const
    00433     {
    00434         return m_includeStack.empty() == true ? getBaseIdentifier() : m_includeStack.back();
    00435     }
    00436
    00444     void
    00445     processNSAliasElement(
    00446             const XalanDOMChar*             name,
    00447             const AttributeListType&        atts,
    00448             StylesheetConstructionContext&  constructionContext);
    00449
    00455     void
    00456     processDecimalFormatElement(
    00457             StylesheetConstructionContext&  constructionContext,
    00458             const AttributeListType&        atts,
    00459             const LocatorType*              locator = 0);
    00460
    00468     const XalanDecimalFormatSymbols*
    00469     getDecimalFormatSymbols(const XalanQName&   theQName) const;
    00470
    00476     void
    00477     addImport(Stylesheet*   theStylesheet)
    00478     {
    00479         m_imports.insert(m_imports.begin(), theStylesheet);
    00480     }
    00481
    00487     bool
    00488     isWrapperless() const
    00489     {
    00490         return m_isWrapperless;
    00491     }
    00492
    00493     ElemTemplateElement*
    00494     initWrapperless(
    00495             StylesheetConstructionContext&  constructionContext,
    00496             const LocatorType*              locator);
    00497
    00503     URLStackType&
    00504     getIncludeStack()
    00505     {
    00506         return m_includeStack;
    00507     }
    00508
    00517     void
    00518     processKeyElement(
    00519             const PrefixResolver&           nsContext,
    00520             const AttributeListType&        atts,
    00521             const LocatorType*              locator,
    00522             StylesheetConstructionContext&  constructionContext);
    00523
    00530     const ElemTemplate*
    00531     findNamedTemplate(const XalanQName&     qname) const;
    00532
    00541     const ElemTemplate*
    00542     findTemplate(
    00543             StylesheetExecutionContext&     executionContext,
    00544             XalanNode*                      targetNode) const
    00545     {
    00546         assert(targetNode != 0);
    00547
    00548         return findTemplate(
    00549                 executionContext,
    00550                 targetNode,
    00551                 targetNode->getNodeType(),
    00552                 s_emptyQName,
    00553                 false);
    00554     }
    00555
    00567     const ElemTemplate*
    00568     findTemplate(
    00569             StylesheetExecutionContext&     executionContext,
    00570             XalanNode*                      targetNode,
    00571             XalanNode::NodeType             targetNodeType,
    00572             const XalanQName&               mode,
    00573             bool                            onlyUseImports) const;
    00574
    00581     static void
    00582     addObjectIfNotFound(
    00583             const XalanMatchPatternData*    thePattern,
    00584             PatternTableVectorType&         theVector);
    00585
    00595     static void
    00596     addObjectIfNotFound(
    00597             const XalanMatchPatternData*    thePattern,
    00598             const XalanMatchPatternData*    theArray[],
    00599             unsigned int&                   theArraySize);
    00600
    00608     const PatternTableVectorType*
    00609     locateElementMatchPatternDataList(const XalanDOMString&     theName) const;
    00610
    00618     const PatternTableVectorType*
    00619     locateAttributeMatchPatternDataList(const XalanDOMString&   theName) const;
    00620
    00627     const PatternTableVectorType*
    00628     locateMatchPatternDataList(
    00629             const XalanNode&        theNode,
    00630             XalanNode::NodeType     targetNodeType) const;
    00631
    00640     void
    00641     processExtensionNamespace(
    00642             StylesheetConstructionContext&  theConstructionContext,
    00643             const XalanDOMString&           uri);
    00644
    00651     ExtensionNSHandler*
    00652     lookupExtensionNSHandler(const XalanDOMString&  uri) const
    00653     {
    00654         const ExtensionNamespacesMapType::const_iterator    it =
    00655           m_extensionNamespaces.find(uri);
    00656
    00657         return it == m_extensionNamespaces.end() ? 0 : (*it).second;
    00658     }
    00659
    00666     void
    00667     setTopLevelVariable(ElemVariable*   var)
    00668     {
    00669         m_topLevelVariables.push_back(var);
    00670     }
    00671
    00679     void
    00680     pushTopLevelVariables(
    00681             StylesheetExecutionContext&     executionContext,
    00682             const ParamVectorType&          topLevelParams) const;
    00683
    00684
    00685     // These interfaces are inherited from PrefixResolver...
    00686
    00687     virtual const XalanDOMString*
    00688     getNamespaceForPrefix(const XalanDOMString&     prefix) const;
    00689
    00690     virtual const XalanDOMString&
    00691     getURI() const;
    00692
    00693     const XalanDOMString&
    00694     getXSLTNamespaceURI() const
    00695     {
    00696         return m_XSLTNamespaceURI;
    00697     }
    00698
    00699     void
    00700     setXSLTNamespaceURI(const XalanDOMString&   theURI)
    00701     {
    00702         m_XSLTNamespaceURI = theURI;
    00703     }
    00704
    00705     const ElemTemplate*
    00706     getFirstTemplate() const
    00707     {
    00708         return m_firstTemplate;
    00709     }
    00710
    00711 protected:
    00712
    00716     StylesheetRoot&                     m_stylesheetRoot;
    00717
    00721     XalanDOMString                      m_baseIdent;
    00722
    00727     KeyDeclarationVectorType            m_keyDeclarations;
    00728
    00729     WhitespaceElementsVectorType        m_whitespaceElements;
    00730
    00731     static const XalanQNameByReference  s_emptyQName;
    00732
    00733 private:
    00734
    00735     // Not defined...
    00736     Stylesheet(const Stylesheet&);
    00737
    00738     Stylesheet&
    00739     operator=(const Stylesheet&);
    00740
    00741     bool
    00742     operator==(const Stylesheet&) const;
    00743
    00744
    00755     const ElemTemplate*
    00756     findTemplateInImports(
    00757             StylesheetExecutionContext&     executionContext,
    00758             XalanNode*                      targetNode,
    00759             XalanNode::NodeType             targetNodeType,
    00760             const XalanQName&               mode) const;
    00761
    00766     XalanDOMString                          m_XSLTNamespaceURI;
    00767
    00771     StylesheetVectorType                    m_imports;
    00772
    00773     StylesheetVectorType::size_type         m_importsSize;
    00774
    00778     NamespacesStackType                     m_namespaces;
    00779
    00784     NamespaceVectorType                     m_namespaceDecls;
    00785
    00790     bool                                    m_isWrapperless;
    00791
    00795     ExtensionNamespacesMapType              m_extensionNamespaces;
    00796
    00800     ElemTemplate*                           m_firstTemplate;
    00801
    00806     URLStackType                            m_includeStack;
    00807
    00813     ElemTemplateMapType                     m_namedTemplates;
    00814
    00818     ElemVariableVectorType                  m_topLevelVariables;
    00819
    00823     double                                  m_XSLTVerDeclared;
    00824
    00830     PatternTableMapType                         m_elementPatternTable;
    00831
    00832     const PatternTableMapType::const_iterator   m_elementPatternTableEnd;
    00833
    00834     PatternTableVectorType                      m_elementAnyPatternList;
    00835
    00841     PatternTableMapType                         m_attributePatternTable;
    00842
    00843     const PatternTableMapType::const_iterator   m_attributePatternTableEnd;
    00844
    00845     PatternTableVectorType                      m_attributeAnyPatternList;
    00846
    00850     PatternTableVectorType                  m_textPatternList;
    00851
    00852     PatternTableVectorType                  m_commentPatternList;
    00853
    00854     PatternTableVectorType                  m_rootPatternList;
    00855
    00856     PatternTableVectorType                  m_piPatternList;
    00857
    00861     PatternTableVectorType                  m_nodePatternList;
    00862
    00863     size_type                               m_patternCount;
    00864
    00865     ElemDecimalFormatVectorType             m_elemDecimalFormats;
    00866
    00867     NamespacesHandler                       m_namespacesHandler;
    00868
    00869     static const XalanDOMString             s_emptyString;
    00870 };
    00871
    00872
    00873
    00874 XALAN_CPP_NAMESPACE_END
    00875
    00876
    00877
    00878 #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.10 Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.