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 #if !defined(XALAN_ELEMNUMBER_HEADER_GUARD) 00017 #define XALAN_ELEMNUMBER_HEADER_GUARD 00018 00019 00020 00021 // Base include file. Must be first. 00022 #include <xalanc/XSLT/XSLTDefinitions.hpp> 00023 00024 00025 00026 #include <xalanc/Include/XalanVector.hpp> 00027 00028 00029 00030 // Base class header file. 00031 #include <xalanc/XSLT/ElemTemplateElement.hpp> 00032 00033 00034 00035 #include <xalanc/XPath/NodeRefListBase.hpp> 00036 00037 00038 00039 #include <xalanc/XSLT/CountersTable.hpp> 00040 #include <xalanc/XSLT/DecimalToRoman.hpp> 00041 #include <xalanc/XSLT/XalanNumberingResourceBundle.hpp> 00042 00043 00044 00045 XALAN_CPP_NAMESPACE_BEGIN 00046 00047 00048 00049 class AVT; 00050 class MutableNodeRefList; 00051 class XalanNumberFormat; 00052 class XPath; 00053 class XPathExecutionContext; 00054 00055 00056 00057 class ElemNumber: public ElemTemplateElement 00058 { 00059 public: 00060 00061 typedef CountersTable::CountType CountType; 00062 00063 enum eLevel 00064 { 00065 eSingle, 00066 eMultiple, 00067 eAny 00068 }; 00069 00070 typedef XalanVector<CountType> CountTypeArrayType; 00071 00075 static void 00076 initialize(MemoryManagerType& theManager); 00077 00081 static void 00082 terminate(); 00083 00094 ElemNumber( 00095 StylesheetConstructionContext& constructionContext, 00096 Stylesheet& stylesheetTree, 00097 const AttributeListType& atts, 00098 int lineNumber, 00099 int columnNumber, 00100 unsigned long id); 00101 00102 static ElemNumber* 00103 create( 00104 MemoryManagerType& theManager, 00105 StylesheetConstructionContext& constructionContext, 00106 Stylesheet& stylesheetTree, 00107 const AttributeListType& atts, 00108 int lineNumber, 00109 int columnNumber, 00110 unsigned long id); 00111 00112 virtual 00113 ~ElemNumber(); 00114 00115 // These methods are inherited from ElemTemplateElement ... 00116 00117 virtual const XalanDOMString& 00118 getElementName() const; 00119 00120 #if !defined(XALAN_RECURSIVE_STYLESHEET_EXECUTION) 00121 virtual const ElemTemplateElement* 00122 startElement(StylesheetExecutionContext& executionContext) const; 00123 #else 00124 virtual void 00125 execute(StylesheetExecutionContext& executionContext) const; 00126 #endif 00127 00128 unsigned long 00129 getID() const 00130 { 00131 return m_id; 00132 } 00133 00137 XalanNode* getPreviousNode( 00138 StylesheetExecutionContext& executionContext, 00139 XalanNode* pos) const; 00140 00144 XalanNode* getTargetNode( 00145 StylesheetExecutionContext& executionContext, 00146 XalanNode* sourceNode) const; 00147 00148 virtual const XPath* 00149 getXPath(unsigned int index = 0) const; 00150 00151 protected: 00152 00164 XalanNode* 00165 findAncestor( 00166 StylesheetExecutionContext& executionContext, 00167 const XPath* fromMatchPattern, 00168 const XPath* countMatchPattern, 00169 XalanNode* context) const; 00170 00182 XalanNode* 00183 findPrecedingOrAncestorOrSelf( 00184 StylesheetExecutionContext& executionContext, 00185 const XPath* fromMatchPattern, 00186 const XPath* countMatchPattern, 00187 XalanNode* context) const; 00188 00192 const XPath* 00193 getCountMatchPattern( 00194 StylesheetExecutionContext& executionContext, 00195 XalanNode* contextNode) const; 00196 00201 void 00202 getCountString( 00203 StylesheetExecutionContext& executionContext, 00204 XalanDOMString& theResult) const; 00205 00206 void 00207 getCountString( 00208 StylesheetExecutionContext& executionContext, 00209 const MutableNodeRefList& ancestors, 00210 CountersTable& ctable, 00211 CountType numberList[], 00212 NodeRefListBase::size_type numberListLength, 00213 XalanDOMString& theResult) const; 00214 00225 void 00226 getMatchingAncestors( 00227 StylesheetExecutionContext& executionContext, 00228 XalanNode* node, 00229 bool stopAtFirstFound, 00230 MutableNodeRefList& ancestors) const; 00231 00237 XalanNumberFormat* 00238 getNumberFormatter(StylesheetExecutionContext& executionContext) const; 00239 00248 void 00249 formatNumberList( 00250 StylesheetExecutionContext& executionContext, 00251 const CountType theList[], 00252 NodeRefListBase::size_type theListLength, 00253 XalanDOMString& formattedNumber) const; 00254 00266 static void 00267 int2singlealphaCount( 00268 CountType val, 00269 const XalanDOMString& table, 00270 XalanDOMString& theResult); 00271 00284 static void 00285 int2alphaCount( 00286 CountType val, 00287 const XalanDOMChar table[], 00288 XalanDOMString::size_type length, 00289 XalanDOMString& theResult); 00290 00302 static void 00303 tradAlphaCount( 00304 CountType val, 00305 XalanDOMString& theResult); 00306 00315 static void 00316 long2roman( 00317 CountType val, 00318 bool prefixesAreOK, 00319 XalanDOMString& theResult); 00320 00321 private: 00322 00323 void 00324 evaluateLetterValueAVT( 00325 StylesheetExecutionContext& executionContext, 00326 XalanDOMString& value) const; 00327 00328 void 00329 traditionalAlphaCount( 00330 CountType theValue, 00331 const XalanNumberingResourceBundle& theResourceBundle, 00332 XalanDOMString& theResult) const; 00333 00334 /* 00335 * Get Formatted number 00336 */ 00337 void 00338 getFormattedNumber( 00339 StylesheetExecutionContext& executionContext, 00340 XalanDOMChar numberType, 00341 XalanDOMString::size_type numberWidth, 00342 CountType listElement, 00343 XalanDOMString& theResult) const; 00344 00345 const XPath* m_countMatchPattern; 00346 const XPath* m_fromMatchPattern; 00347 const XPath* m_valueExpr; 00348 00349 CountType m_level; // = Constants.NUMBERLEVEL_SINGLE; 00350 00351 const AVT* m_format_avt; 00352 const AVT* m_lang_avt; 00353 const AVT* m_lettervalue_avt; 00354 const AVT* m_groupingSeparator_avt; 00355 const AVT* m_groupingSize_avt; 00356 00357 const unsigned long m_id; 00358 00362 static const XalanDOMChar s_atString[]; 00363 00367 static const XalanDOMString& s_textString; 00368 00372 static const XalanDOMString& s_commentString; 00373 00377 static const XalanDOMString& s_slashString; 00378 00382 static const XalanDOMChar s_piString[]; 00383 00387 static const XalanDOMChar s_levelString[]; 00388 00392 static const XalanDOMChar s_multipleString[]; 00393 00397 static const XalanDOMChar s_anyString[]; 00398 00402 static const XalanDOMChar s_singleString[]; 00403 00407 static const XalanDOMChar s_alphabeticString[]; 00408 00412 static const XalanDOMChar s_traditionalString[]; 00413 00417 static const XalanDOMChar s_errorString[]; 00418 00422 static const XalanDOMChar s_alphaCountTable[]; 00423 00424 static const XalanDOMString::size_type s_alphaCountTableSize; 00425 00426 static const XalanDOMChar s_elalphaCountTable[]; 00427 00428 static const XalanDOMString::size_type s_elalphaCountTableSize; 00429 00435 static const DecimalToRoman s_romanConvertTable[]; 00436 00440 static const XalanNumberingResourceBundle& s_elalphaResourceBundle; 00441 00442 00443 public: 00444 00449 class NumberFormatStringTokenizer 00450 { 00451 public: 00452 00453 typedef XalanDOMString::size_type size_type; 00454 00460 NumberFormatStringTokenizer(const XalanDOMString& theString); 00461 00467 void 00468 setString(const XalanDOMString& theString); 00469 00473 void 00474 reset() 00475 { 00476 m_currentPosition = 0; 00477 } 00478 00479 00485 void 00486 nextToken(XalanDOMString& theToken); 00487 00493 bool 00494 hasMoreTokens() const 00495 { 00496 return m_currentPosition >= m_maxPosition ? false : true; 00497 } 00498 00504 size_type 00505 countTokens() const; 00506 00507 private: 00508 00509 size_type m_currentPosition; 00510 00511 size_type m_maxPosition; 00512 00513 const XalanDOMString* m_string; 00514 }; 00515 00516 private: 00517 }; 00518 00519 00520 00521 XALAN_CPP_NAMESPACE_END 00522 00523 00524 00525 #endif // XALAN_ELEMNUMBER_HEADER_GUARD
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
Xalan-C++ XSLT Processor Version 1.9 |
|