Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

Stylesheet.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #if !defined(XALAN_STYLESHEET_HEADER_GUARD)
18 #define XALAN_STYLESHEET_HEADER_GUARD
19 
20 
21 
22 // Base include file. Must be first.
23 #include "XSLTDefinitions.hpp"
24 
25 
26 
29 
30 
31 
34 
35 
36 
38 
39 
40 
43 #include <xalanc/XPath/XPath.hpp>
44 
45 
46 
52 
53 
54 
55 XALAN_CPP_NAMESPACE_BEGIN
56 
57 
58 
59 class ExtensionNSHandler;
61 class ElemDecimalFormat;
62 class ElemTemplate;
64 class ElemVariable;
65 class KeyTable;
66 class NodeRefListBase;
67 class PrefixResolver;
69 class StylesheetRoot;
71 class XalanQName;
72 class XObject;
74 
75 
78 
79 
80 
85 {
86 
87 public:
88 
93 
101 
103 
106 
108 
110 
112 
118  Stylesheet(
119  StylesheetRoot& root,
120  const XalanDOMString& baseIdentifier,
121  StylesheetConstructionContext& constructionContext);
122 
123  virtual
124  ~Stylesheet();
125 
126  static Stylesheet*
127  create(MemoryManagerType& theManager,
128  StylesheetRoot& root,
129  const XalanDOMString& baseIdentifier,
130  StylesheetConstructionContext& constructionContext);
131 
134  {
135  return m_elementPatternTable.getMemoryManager();
136  }
137 
143  double
145  {
146  return m_XSLTVerDeclared;
147  }
148 
154  void
155  setXSLTVerDeclared(double ver)
156  {
157  m_XSLTVerDeclared = ver;
158  }
159 
165  const StylesheetRoot&
167  {
168  return m_stylesheetRoot;
169  }
170 
178  {
179  return m_stylesheetRoot;
180  }
181 
187  const NamespacesStackType&
189  {
190  return m_namespaces;
191  }
192 
198  NamespacesStackType&
200  {
201  return m_namespaces;
202  }
203 
204  const NamespacesHandler&
206  {
207  return m_namespacesHandler;
208  }
209 
212  {
213  return m_namespacesHandler;
214  }
215 
221  const NamespaceVectorType&
223  {
224  return m_namespaceDecls;
225  }
226 
232  NamespaceVectorType&
234  {
235  return m_namespaceDecls;
236  }
237 
243  void
244  setNamespaceDecls(const NamespaceVectorType& ns)
245  {
246  m_namespaceDecls = ns;
247  }
248 
255  void
256  pushNamespaces(const AttributeListType& atts);
257 
261  void
263  {
264  assert(m_namespaces.empty() == false);
265 
266  m_namespaces.pop_back();
267  }
268 
269  void
270  addWhitespaceElement(const XalanSpaceNodeTester& theTester);
271 
275  virtual void
276  postConstruction(StylesheetConstructionContext& constructionContext);
277 
287  bool
288  isAttrOK(
289  const XalanDOMChar* attrName,
290  const AttributeListType& atts,
291  int which,
292  StylesheetConstructionContext& constructionContext) const;
293 
300  const XalanDOMString*
302  XalanDOMString& theBuffer) const
303  {
304  return getNamespaceFromStack(c_wstr(nodeName), theBuffer);
305  }
306 
313  const XalanDOMString*
314  getNamespaceFromStack(const XalanDOMChar* nodeName,
315  XalanDOMString& theBuffer) const;
316 
324  const XalanDOMString*
326  {
327  return XalanQName::getNamespaceForPrefix(m_namespaces, prefix);
328  }
329 
337  const XalanDOMString*
338  getNamespaceForPrefixFromStack(const XalanDOMChar* prefix) const
339  {
340  assert(prefix != 0);
341 
342  return XalanQName::getNamespaceForPrefix(m_namespaces, (const XalanDOMChar*)prefix);
343  }
344 
352  const XalanDOMString*
354  const XalanDOMString& prefix,
355  StylesheetConstructionContext& constructionContext) const;
356 
364  const XalanDOMString*
366  const XalanDOMChar* prefix,
367  StylesheetConstructionContext& constructionContext) const;
368 
376  void
378  StylesheetConstructionContext& theConstructionContext,
379  const XalanDOMChar* theValue)
380  {
381  m_namespacesHandler.processExcludeResultPrefixes(
382  theConstructionContext,
383  theValue,
384  m_namespaces);
385  }
386 
393  void
394  addTemplate(
395  ElemTemplate* theTemplate,
396  StylesheetConstructionContext& constructionContext);
397 
406  bool
407  getYesOrNo(
408  const XalanDOMChar* aname,
409  const XalanDOMChar* val,
410  StylesheetConstructionContext& constructionContext) const;
411 
417  const XalanDOMString&
419  {
420  return m_baseIdent;
421  }
422 
431  const XalanDOMString&
433  {
434  return m_includeStack.empty() == true ? getBaseIdentifier() : m_includeStack.back();
435  }
436 
444  void
445  processNSAliasElement(
446  const XalanDOMChar* name,
447  const AttributeListType& atts,
448  StylesheetConstructionContext& constructionContext);
449 
455  void
456  processDecimalFormatElement(
457  StylesheetConstructionContext& constructionContext,
458  const AttributeListType& atts,
459  const LocatorType* locator = 0);
460 
469  getDecimalFormatSymbols(const XalanQName& theQName) const;
470 
476  void
477  addImport(Stylesheet* theStylesheet)
478  {
479  m_imports.insert(m_imports.begin(), theStylesheet);
480  }
481 
487  bool
489  {
490  return m_isWrapperless;
491  }
492 
494  initWrapperless(
495  StylesheetConstructionContext& constructionContext,
496  const LocatorType* locator);
497 
503  URLStackType&
505  {
506  return m_includeStack;
507  }
508 
517  void
518  processKeyElement(
519  const PrefixResolver& nsContext,
520  const AttributeListType& atts,
521  const LocatorType* locator,
522  StylesheetConstructionContext& constructionContext);
523 
530  const ElemTemplate*
531  findNamedTemplate(const XalanQName& qname) const;
532 
541  const ElemTemplate*
543  StylesheetExecutionContext& executionContext,
544  XalanNode* targetNode) const
545  {
546  assert(targetNode != 0);
547 
548  return findTemplate(
549  executionContext,
550  targetNode,
551  targetNode->getNodeType(),
552  s_emptyQName,
553  false);
554  }
555 
567  const ElemTemplate*
568  findTemplate(
569  StylesheetExecutionContext& executionContext,
570  XalanNode* targetNode,
571  XalanNode::NodeType targetNodeType,
572  const XalanQName& mode,
573  bool onlyUseImports) const;
574 
581  static void
582  addObjectIfNotFound(
583  const XalanMatchPatternData* thePattern,
584  PatternTableVectorType& theVector);
585 
595  static void
596  addObjectIfNotFound(
597  const XalanMatchPatternData* thePattern,
598  const XalanMatchPatternData* theArray[],
599  unsigned int& theArraySize);
600 
608  const PatternTableVectorType*
609  locateElementMatchPatternDataList(const XalanDOMString& theName) const;
610 
618  const PatternTableVectorType*
619  locateAttributeMatchPatternDataList(const XalanDOMString& theName) const;
620 
627  const PatternTableVectorType*
628  locateMatchPatternDataList(
629  const XalanNode& theNode,
630  XalanNode::NodeType targetNodeType) const;
631 
640  void
641  processExtensionNamespace(
642  StylesheetConstructionContext& theConstructionContext,
643  const XalanDOMString& uri);
644 
653  {
655  m_extensionNamespaces.find(uri);
656 
657  return it == m_extensionNamespaces.end() ? 0 : (*it).second;
658  }
659 
666  void
668  {
669  m_topLevelVariables.push_back(var);
670  }
671 
679  void
681  StylesheetExecutionContext& executionContext,
682  const ParamVectorType& topLevelParams) const;
683 
684 
685  // These interfaces are inherited from PrefixResolver...
686 
687  virtual const XalanDOMString*
688  getNamespaceForPrefix(const XalanDOMString& prefix) const;
689 
690  virtual const XalanDOMString&
691  getURI() const;
692 
693  const XalanDOMString&
695  {
696  return m_XSLTNamespaceURI;
697  }
698 
699  void
701  {
702  m_XSLTNamespaceURI = theURI;
703  }
704 
705  const ElemTemplate*
707  {
708  return m_firstTemplate;
709  }
710 
711 protected:
712 
717 
722 
727  KeyDeclarationVectorType m_keyDeclarations;
728 
729  WhitespaceElementsVectorType m_whitespaceElements;
730 
731  static const XalanQNameByReference s_emptyQName;
732 
733 private:
734 
735  // Not defined...
736  Stylesheet(const Stylesheet&);
737 
738  Stylesheet&
739  operator=(const Stylesheet&);
740 
741  bool
742  operator==(const Stylesheet&) const;
743 
744 
755  const ElemTemplate*
756  findTemplateInImports(
757  StylesheetExecutionContext& executionContext,
758  XalanNode* targetNode,
759  XalanNode::NodeType targetNodeType,
760  const XalanQName& mode) const;
761 
766  XalanDOMString m_XSLTNamespaceURI;
767 
771  StylesheetVectorType m_imports;
772 
773  StylesheetVectorType::size_type m_importsSize;
774 
778  NamespacesStackType m_namespaces;
779 
784  NamespaceVectorType m_namespaceDecls;
785 
790  bool m_isWrapperless;
791 
795  ExtensionNamespacesMapType m_extensionNamespaces;
796 
800  ElemTemplate* m_firstTemplate;
801 
806  URLStackType m_includeStack;
807 
813  ElemTemplateMapType m_namedTemplates;
814 
818  ElemVariableVectorType m_topLevelVariables;
819 
823  double m_XSLTVerDeclared;
824 
830  PatternTableMapType m_elementPatternTable;
831 
832  const PatternTableMapType::const_iterator m_elementPatternTableEnd;
833 
834  PatternTableVectorType m_elementAnyPatternList;
835 
841  PatternTableMapType m_attributePatternTable;
842 
843  const PatternTableMapType::const_iterator m_attributePatternTableEnd;
844 
845  PatternTableVectorType m_attributeAnyPatternList;
846 
850  PatternTableVectorType m_textPatternList;
851 
852  PatternTableVectorType m_commentPatternList;
853 
854  PatternTableVectorType m_rootPatternList;
855 
856  PatternTableVectorType m_piPatternList;
857 
861  PatternTableVectorType m_nodePatternList;
862 
863  size_type m_patternCount;
864 
865  ElemDecimalFormatVectorType m_elemDecimalFormats;
866 
867  NamespacesHandler m_namespacesHandler;
868 
869  static const XalanDOMString s_emptyString;
870 };
871 
872 
873 
874 XALAN_CPP_NAMESPACE_END
875 
876 
877 
878 #endif // XALAN_STYLESHEET_HEADER_GUARD
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
Definition: XalanVector.hpp:1111
NamespacesStackType & getNamespaces()
Retrieve the stack of namespace lists.
Definition: Stylesheet.hpp:199
XalanDOMString m_baseIdent
The base URL of the XSL document.
Definition: Stylesheet.hpp:721
Definition: ElemVariable.hpp:52
static const XalanQNameByReference s_emptyQName
Definition: Stylesheet.hpp:731
const XalanDOMChar * c_wstr(const XalanDOMString &theString)
Get the underlying representation of the target XalanDOMString as a null-terminated string...
Definition: DOMStringHelper.hpp:153
Definition: XalanNode.hpp:44
Definition: ElemTemplate.hpp:41
NamespacesHandler & getNamespacesHandler()
Definition: Stylesheet.hpp:211
XERCES_CPP_NAMESPACE_QUALIFIER AttributeList AttributeListType
Definition: AttributeListImpl.hpp:39
XALAN_CPP_NAMESPACE_BEGIN typedef XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager MemoryManagerType
Definition: XalanMemoryManagement.hpp:39
This class contains information concerning a match pattern in a stylesheet.
Definition: XalanMatchPatternData.hpp:50
XalanQName::NamespaceVectorType NamespaceVectorType
Definition: Stylesheet.hpp:91
XalanMap< XalanQNameByReference, const ElemTemplate * > ElemTemplateMapType
Definition: Stylesheet.hpp:105
Definition: ElemTemplateElement.hpp:74
Definition: NamespacesHandler.hpp:50
KeyDeclarationVectorType m_keyDeclarations
Table of KeyDeclaration objects, which are set by the xsl:key element.
Definition: Stylesheet.hpp:727
XalanVector< XalanDOMString > URLStackType
Definition: Stylesheet.hpp:97
Definition: XalanSpaceNodeTester.hpp:44
This acts as the stylesheet root of the stylesheet tree, and holds values that are shared by all styl...
Definition: StylesheetRoot.hpp:61
void popNamespaces()
Pop a namespace declaration from the namespace stack.
Definition: Stylesheet.hpp:262
XalanVector< ElemVariable * > ElemVariableVectorType
Definition: Stylesheet.hpp:94
NodeType
Definition: XalanNode.hpp:53
Definition: StylesheetExecutionContext.hpp:104
const ElemTemplate * findTemplate(StylesheetExecutionContext &executionContext, XalanNode *targetNode) const
Given a target element, find the template that best matches in the given XSL document, according to the rules specified in the xsl draft.
Definition: Stylesheet.hpp:542
const StylesheetRoot & getStylesheetRoot() const
Retrieve the root stylesheet object.
Definition: Stylesheet.hpp:166
URLStackType & getIncludeStack()
Retrieve the stack of who's including who.
Definition: Stylesheet.hpp:504
Definition: XalanDecimalFormatSymbols.hpp:38
StylesheetConstructionContext::size_type size_type
Definition: Stylesheet.hpp:89
NamespaceVectorType & getNamespaceDecls()
Retrieve the list of namespace declarations currently in effect.
Definition: Stylesheet.hpp:233
void setTopLevelVariable(ElemVariable *var)
Set a top level variable.
Definition: Stylesheet.hpp:667
Definition: XalanQNameByReference.hpp:35
Definition: XalanMap.hpp:113
XalanMap< XalanDOMString, ExtensionNSHandler * > ExtensionNamespacesMapType
Definition: Stylesheet.hpp:102
Definition: KeyTable.hpp:77
const NamespaceVectorType & getNamespaceDecls() const
Retrieve the list of namespace declarations currently in effect.
Definition: Stylesheet.hpp:222
double getXSLTVerDeclared() const
Retrieve XSLT version number.
Definition: Stylesheet.hpp:144
Local implementation of NodeRefList.
Definition: NodeRefListBase.hpp:42
size_t size_type
Definition: StylesheetConstructionContext.hpp:82
StylesheetRoot & m_stylesheetRoot
The root of the stylesheet tree.
Definition: Stylesheet.hpp:716
const XalanDOMString * getNamespaceForPrefixFromStack(const XalanDOMString &prefix) const
Get the namespace from a prefix by searching the stack of namespace lists.
Definition: Stylesheet.hpp:325
virtual NodeType getNodeType() const =0
An enum value representing the type of the underlying object.
const XalanDOMString & getXSLTNamespaceURI() const
Definition: Stylesheet.hpp:694
const XalanDOMString * getNamespaceForPrefixFromStack(const XalanDOMChar *prefix) const
Get the namespace from a prefix by searching the stack of namespace lists.
Definition: Stylesheet.hpp:338
void setNamespaceDecls(const NamespaceVectorType &ns)
Set the list of namespace declarations currently in effect.
Definition: Stylesheet.hpp:244
void processExcludeResultPrefixes(StylesheetConstructionContext &theConstructionContext, const XalanDOMChar *theValue)
See if a namespace should be excluded.
Definition: Stylesheet.hpp:377
virtual const XalanDOMString * getNamespaceForPrefix(const XalanDOMString &prefix) const =0
Retrieve the URI corresponding to a namespace prefix.
XalanVector< const XalanMatchPatternData * > PatternTableVectorTypeDecl
Definition: Stylesheet.hpp:73
StylesheetExecutionContext::ParamVectorType ParamVectorType
Definition: Stylesheet.hpp:90
const NamespacesHandler & getNamespacesHandler() const
Definition: Stylesheet.hpp:205
const XalanDOMString * getNamespaceFromStack(const XalanDOMString &nodeName, XalanDOMString &theBuffer) const
Get the namespace from a qualified name.
Definition: Stylesheet.hpp:301
void addImport(Stylesheet *theStylesheet)
Add an imported stylesheet.
Definition: Stylesheet.hpp:477
XalanVector< XalanSpaceNodeTester > WhitespaceElementsVectorType
Definition: Stylesheet.hpp:99
This class defines an interface for classes that resolve namespace prefixes to their URIs...
Definition: PrefixResolver.hpp:37
Definition: ExtensionNSHandler.hpp:54
static const XalanDOMString * getNamespaceForPrefix(const NamespaceVectorType &namespaces, const XalanDOMString &prefix)
Get the namespace for a prefix by searching a vector of namespaces.
Class to hold XPath return types.
Definition: XObject.hpp:61
XERCES_CPP_NAMESPACE_QUALIFIER Locator LocatorType
Definition: FormatterListener.hpp:47
void setXSLTNamespaceURI(const XalanDOMString &theURI)
Definition: Stylesheet.hpp:700
size_t size_type
Definition: XalanVector.hpp:71
XalanQName::NamespacesStackType NamespacesStackType
Definition: Stylesheet.hpp:92
ExtensionNSHandler * lookupExtensionNSHandler(const XalanDOMString &uri) const
Return the handler for a given extension namespace.
Definition: Stylesheet.hpp:652
virtual void pushTopLevelVariables(const ParamVectorType &topLevelParams)=0
Set a list of top level variables in the specified execution context stylesheet.
#define XALAN_USES_MEMORY_MANAGER(Type)
Definition: XalanMemoryManagement.hpp:468
XalanVector< KeyDeclaration > KeyDeclarationVectorType
Definition: Stylesheet.hpp:95
#define XALAN_XSLT_EXPORT
Definition: XSLTDefinitions.hpp:25
Definition: XPathConstructionContext.hpp:116
WhitespaceElementsVectorType m_whitespaceElements
Definition: Stylesheet.hpp:729
bool isWrapperless() const
whether there is a wrapper template
Definition: Stylesheet.hpp:488
XalanMap< const XalanNode *, KeyTable * > KeyTablesTableType
Definition: Stylesheet.hpp:107
const XalanDOMString & getBaseIdentifier() const
Retrieve the base identifier with which this stylesheet is associated.
Definition: Stylesheet.hpp:418
Definition: XalanDOMString.hpp:42
StylesheetConstructionContext::GetAndReleaseCachedString GetAndReleaseCachedString
Definition: Stylesheet.hpp:111
Definition: StylesheetConstructionContext.hpp:73
XalanVector< Stylesheet * > StylesheetVectorType
Definition: Stylesheet.hpp:96
const NamespacesStackType & getNamespaces() const
Retrieve the stack of namespace lists.
Definition: Stylesheet.hpp:188
XalanVector< ElemDecimalFormat * > ElemDecimalFormatVectorType
Definition: Stylesheet.hpp:98
This class represents the base stylesheet or an "import" stylesheet.
Definition: Stylesheet.hpp:84
MemoryManagerType & getMemoryManager()
Definition: Stylesheet.hpp:133
PatternTableVectorTypeDecl PatternTableVectorType
Definition: Stylesheet.hpp:100
bool empty() const
Definition: XalanDOMString.hpp:274
Class to represent a qualified name: "The name of an internal XSLT object, specifically a named templ...
Definition: XalanQName.hpp:68
Definition: XalanVector.hpp:61
XalanMap< XalanDOMString, PatternTableVectorType > PatternTableMapType
Definition: Stylesheet.hpp:109
Definition: ElemDecimalFormat.hpp:43
const ElemTemplate * getFirstTemplate() const
Definition: Stylesheet.hpp:706
StylesheetRoot & getStylesheetRoot()
Retrieve the root stylesheet object.
Definition: Stylesheet.hpp:177
Xalan implementation of deque.
Definition: XalanDeque.hpp:160
void setXSLTVerDeclared(double ver)
Set XSLT version number.
Definition: Stylesheet.hpp:155
const XalanDOMString & getCurrentIncludeBaseIdentifier() const
Retrieve the base identifier for the most recently included stylesheet.
Definition: Stylesheet.hpp:432

Interpreting class diagrams

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

dot

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

Apache Logo