Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

ElemNumber.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 #if !defined(XALAN_ELEMNUMBER_HEADER_GUARD)
17 #define XALAN_ELEMNUMBER_HEADER_GUARD
18 
19 
20 
21 // Base include file. Must be first.
23 
24 
25 
27 
28 
29 
30 // Base class header file.
32 
33 
34 
36 
37 
38 
42 
43 
44 
45 XALAN_CPP_NAMESPACE_BEGIN
46 
47 
48 
49 class AVT;
50 class MutableNodeRefList;
51 class XalanNumberFormat;
52 class XPath;
54 
55 
56 
58 {
59 public:
60 
62 
63  enum eLevel
64  {
68  };
69 
71 
75  static void
76  initialize(MemoryManagerType& theManager);
77 
81  static void
82  terminate();
83 
94  ElemNumber(
95  StylesheetConstructionContext& constructionContext,
96  Stylesheet& stylesheetTree,
97  const AttributeListType& atts,
98  int lineNumber,
99  int columnNumber,
100  unsigned long id);
101 
102  static ElemNumber*
103  create(
104  MemoryManagerType& theManager,
105  StylesheetConstructionContext& constructionContext,
106  Stylesheet& stylesheetTree,
107  const AttributeListType& atts,
108  int lineNumber,
109  int columnNumber,
110  unsigned long id);
111 
112  virtual
113  ~ElemNumber();
114 
115  // These methods are inherited from ElemTemplateElement ...
116 
117  virtual const XalanDOMString&
118  getElementName() const;
119 
120 #if !defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION)
121  virtual const ElemTemplateElement*
122  startElement(StylesheetExecutionContext& executionContext) const;
123 #else
124  virtual void
125  execute(StylesheetExecutionContext& executionContext) const;
126 #endif
127 
128  unsigned long
129  getID() const
130  {
131  return m_id;
132  }
133 
138  StylesheetExecutionContext& executionContext,
139  XalanNode* pos) const;
140 
145  StylesheetExecutionContext& executionContext,
146  XalanNode* sourceNode) const;
147 
148  virtual const XPath*
149  getXPath(unsigned int index = 0) const;
150 
151 protected:
152 
164  XalanNode*
165  findAncestor(
166  StylesheetExecutionContext& executionContext,
167  const XPath* fromMatchPattern,
168  const XPath* countMatchPattern,
169  XalanNode* context) const;
170 
182  XalanNode*
184  StylesheetExecutionContext& executionContext,
185  const XPath* fromMatchPattern,
186  const XPath* countMatchPattern,
187  XalanNode* context) const;
188 
192  const XPath*
194  StylesheetExecutionContext& executionContext,
195  XalanNode* contextNode) const;
196 
201  void
203  StylesheetExecutionContext& executionContext,
204  XalanDOMString& theResult) const;
205 
206  void
208  StylesheetExecutionContext& executionContext,
209  const MutableNodeRefList& ancestors,
210  CountersTable& ctable,
211  CountType numberList[],
212  NodeRefListBase::size_type numberListLength,
213  XalanDOMString& theResult) const;
214 
225  void
227  StylesheetExecutionContext& executionContext,
228  XalanNode* node,
229  bool stopAtFirstFound,
230  MutableNodeRefList& ancestors) const;
231 
238  getNumberFormatter(StylesheetExecutionContext& executionContext) const;
239 
248  void
250  StylesheetExecutionContext& executionContext,
251  const CountType theList[],
252  NodeRefListBase::size_type theListLength,
253  XalanDOMString& formattedNumber) const;
254 
266  static void
268  CountType val,
269  const XalanDOMString& table,
270  XalanDOMString& theResult);
271 
284  static void
286  CountType val,
287  const XalanDOMChar table[],
289  XalanDOMString& theResult);
290 
299  static void
300  toRoman(
301  CountType val,
302  bool prefixesAreOK,
303  XalanDOMString& theResult);
304 
305 private:
306 
307  void
308  evaluateLetterValueAVT(
309  StylesheetExecutionContext& executionContext,
310  XalanDOMString& value) const;
311 
312  void
313  traditionalAlphaCount(
314  CountType theValue,
315  const XalanNumberingResourceBundle& theResourceBundle,
316  XalanDOMString& theResult) const;
317 
318  /*
319  * Get Formatted number
320  */
321  void
322  getFormattedNumber(
323  StylesheetExecutionContext& executionContext,
324  XalanDOMChar numberType,
325  XalanDOMString::size_type numberWidth,
326  CountType listElement,
327  XalanDOMString& theResult) const;
328 
329  const XPath* m_countMatchPattern;
330  const XPath* m_fromMatchPattern;
331  const XPath* m_valueExpr;
332 
333  CountType m_level; // = Constants.NUMBERLEVEL_SINGLE;
334 
335  const AVT* m_format_avt;
336  const AVT* m_lang_avt;
337  const AVT* m_lettervalue_avt;
338  const AVT* m_groupingSeparator_avt;
339  const AVT* m_groupingSize_avt;
340 
341  const unsigned long m_id;
342 
346  static const XalanDOMChar s_atString[];
347 
351  static const XalanDOMString& s_textString;
352 
356  static const XalanDOMString& s_commentString;
357 
361  static const XalanDOMString& s_slashString;
362 
366  static const XalanDOMChar s_piString[];
367 
371  static const XalanDOMChar s_levelString[];
372 
376  static const XalanDOMChar s_multipleString[];
377 
381  static const XalanDOMChar s_anyString[];
382 
386  static const XalanDOMChar s_singleString[];
387 
391  static const XalanDOMChar s_alphabeticString[];
392 
396  static const XalanDOMChar s_traditionalString[];
397 
401  static const XalanDOMChar s_errorString[];
402 
406  static const XalanDOMChar s_alphaCountTable[];
407 
408  static const XalanDOMString::size_type s_alphaCountTableSize;
409 
410  static const XalanDOMChar s_elalphaCountTable[];
411 
412  static const XalanDOMString::size_type s_elalphaCountTableSize;
413 
419  static const DecimalToRoman s_romanConvertTable[];
420 
421  static const size_t s_romanConvertTableSize;
425  static const XalanNumberingResourceBundle& s_elalphaResourceBundle;
426 
427 
428 public:
429 
435  {
436  public:
437 
439 
446 
452  void
453  setString(const XalanDOMString& theString);
454 
458  void
460  {
461  m_currentPosition = 0;
462  }
463 
464 
470  void
471  nextToken(XalanDOMString& theToken);
472 
478  bool
480  {
481  return m_currentPosition >= m_maxPosition ? false : true;
482  }
483 
489  size_type
490  countTokens() const;
491 
492  private:
493 
494  size_type m_currentPosition;
495 
496  size_type m_maxPosition;
497 
498  const XalanDOMString* m_string;
499  };
500 
501 private:
502 };
503 
504 
505 
506 XALAN_CPP_NAMESPACE_END
507 
508 
509 
510 #endif // XALAN_ELEMNUMBER_HEADER_GUARD
void getCountString(StylesheetExecutionContext &executionContext, XalanDOMString &theResult) const
Given an XML source node, get the count according to the parameters set up by the xsl:number attribut...
Definition: XalanNode.hpp:44
XalanNode * getPreviousNode(StylesheetExecutionContext &executionContext, XalanNode *pos) const
Get the previous node to be counted.
Structure to help in converting integrals to roman numerals.
Definition: DecimalToRoman.hpp:37
virtual ~ElemNumber()
Local implementation of MutableNodeRefList.
Definition: MutableNodeRefList.hpp:44
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
void getMatchingAncestors(StylesheetExecutionContext &executionContext, XalanNode *node, bool stopAtFirstFound, MutableNodeRefList &ancestors) const
Get the ancestors, up to the root, that match the pattern.
XalanNode * findAncestor(StylesheetExecutionContext &executionContext, const XPath *fromMatchPattern, const XPath *countMatchPattern, XalanNode *context) const
Given a 'from' pattern (ala xsl:number), a match pattern and a context, find the first ancestor that ...
void formatNumberList(StylesheetExecutionContext &executionContext, const CountType theList[], NodeRefListBase::size_type theListLength, XalanDOMString &formattedNumber) const
Format an array of integrals into a formatted string.
This is a table of counters, keyed by ElemNumber objects...
Definition: CountersTable.hpp:160
static void terminate()
Perform static shut down.
Definition: ElemNumber.hpp:67
Definition: ElemTemplateElement.hpp:74
Definition: XalanNumberFormat.hpp:34
size_type countTokens() const
Count the number of tokens yet to be parsed.
Definition: StylesheetExecutionContext.hpp:104
virtual const XPath * getXPath(unsigned int index=0) const
Get XPath pattern/expression of one of the element atribute.
Definition: XPath.hpp:62
void nextToken(XalanDOMString &theToken)
Retrieve the next token to be parsed.
XalanNode * findPrecedingOrAncestorOrSelf(StylesheetExecutionContext &executionContext, const XPath *fromMatchPattern, const XPath *countMatchPattern, XalanNode *context) const
Given a 'from' pattern (ala xsl:number), a match pattern and a context, find the first ancestor that ...
Definition: XPathExecutionContext.hpp:72
XalanVector< CountType > CountTypeArrayType
Definition: ElemNumber.hpp:70
bool hasMoreTokens() const
Determine if there are tokens remaining.
Definition: ElemNumber.hpp:479
This class returns tokens using non-alphanumberic characters as delimiters.
Definition: ElemNumber.hpp:434
Definition: XalanNumberingResourceBundle.hpp:39
XalanNumberFormat * getNumberFormatter(StylesheetExecutionContext &executionContext) const
Get a formatter.
XalanDOMString::size_type size_type
Definition: ElemNumber.hpp:438
static void int2singlealphaCount(CountType val, const XalanDOMString &table, XalanDOMString &theResult)
Convert an intergral into alphabetic counting, in other words count using the sequence A B C ...
Definition: ElemNumber.hpp:66
Class to hold an Attribute Value Template.
Definition: AVT.hpp:52
static void int2alphaCount(CountType val, const XalanDOMChar table[], XalanDOMString::size_type length, XalanDOMString &theResult)
Convert an integral into alphabetic counting, in other words count using the sequence A B C ...
XalanNode * getTargetNode(StylesheetExecutionContext &executionContext, XalanNode *sourceNode) const
Get the target node that will be counted.
unsigned long getID() const
Definition: ElemNumber.hpp:129
ElemNumber(StylesheetConstructionContext &constructionContext, Stylesheet &stylesheetTree, const AttributeListType &atts, int lineNumber, int columnNumber, unsigned long id)
Construct an object corresponding to an "xsl:number" element.
void setString(const XalanDOMString &theString)
Sets the string to tokenize.
const XPath * getCountMatchPattern(StylesheetExecutionContext &executionContext, XalanNode *contextNode) const
Get the count match pattern, or a default value.
virtual const ElemTemplateElement * startElement(StylesheetExecutionContext &executionContext) const
Completes "pre-processing" before any sub-elements are invoked (i.e.
unsigned int size_type
Definition: NodeRefListBase.hpp:56
static void initialize(MemoryManagerType &theManager)
Perform static initialization.
void reset()
Reset tokenizer so that nextToken() starts from the beginning.
Definition: ElemNumber.hpp:459
virtual const XalanDOMString & getElementName() const
Get a string for the name of the element.
Definition: ElemNumber.hpp:57
Definition: XalanDOMString.hpp:42
XalanDOMString::size_type length(const XalanDOMString &theString)
Get the length of a XalanDOMString.
Definition: DOMStringHelper.hpp:277
Definition: StylesheetConstructionContext.hpp:73
virtual void execute(StylesheetExecutionContext &executionContext) const
Execute the element.
eLevel
Definition: ElemNumber.hpp:63
static ElemNumber * create(MemoryManagerType &theManager, StylesheetConstructionContext &constructionContext, Stylesheet &stylesheetTree, const AttributeListType &atts, int lineNumber, int columnNumber, unsigned long id)
This class represents the base stylesheet or an "import" stylesheet.
Definition: Stylesheet.hpp:84
static void toRoman(CountType val, bool prefixesAreOK, XalanDOMString &theResult)
Convert an integral into roman numerals.
unsigned int size_type
Definition: XalanDOMString.hpp:53
Definition: ElemNumber.hpp:65
NumberFormatStringTokenizer(const XalanDOMString &theString)
Construct a NumberFormatStringTokenizer.
Definition: XalanVector.hpp:61
CountersTable::CountType CountType
Definition: ElemNumber.hpp:61
Counter::CountType CountType
Definition: CountersTable.hpp:164

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