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 <vector> 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 #if defined(XALAN_NO_STD_NAMESPACE) 00071 typedef vector<CountType> CountTypeArrayType; 00072 #else 00073 typedef std::vector<CountType> CountTypeArrayType; 00074 #endif 00075 00079 static void 00080 initialize(); 00081 00085 static void 00086 terminate(); 00087 00098 ElemNumber( 00099 StylesheetConstructionContext& constructionContext, 00100 Stylesheet& stylesheetTree, 00101 const AttributeListType& atts, 00102 int lineNumber, 00103 int columnNumber, 00104 unsigned long id); 00105 00106 virtual 00107 ~ElemNumber(); 00108 00109 // These methods are inherited from ElemTemplateElement ... 00110 00111 virtual const XalanDOMString& 00112 getElementName() const; 00113 00114 virtual void 00115 execute(StylesheetExecutionContext& executionContext) const; 00116 00117 unsigned long 00118 getID() const 00119 { 00120 return m_id; 00121 } 00122 00126 XalanNode* getPreviousNode( 00127 StylesheetExecutionContext& executionContext, 00128 XalanNode* pos) const; 00129 00133 XalanNode* getTargetNode( 00134 StylesheetExecutionContext& executionContext, 00135 XalanNode* sourceNode) const; 00136 00137 virtual const XPath* 00138 getXPath(unsigned int index = 0) const; 00139 00140 protected: 00141 00153 XalanNode* 00154 findAncestor( 00155 StylesheetExecutionContext& executionContext, 00156 const XPath* fromMatchPattern, 00157 const XPath* countMatchPattern, 00158 XalanNode* context) const; 00159 00171 XalanNode* 00172 findPrecedingOrAncestorOrSelf( 00173 StylesheetExecutionContext& executionContext, 00174 const XPath* fromMatchPattern, 00175 const XPath* countMatchPattern, 00176 XalanNode* context) const; 00177 00181 const XPath* 00182 getCountMatchPattern( 00183 StylesheetExecutionContext& executionContext, 00184 XalanNode* contextNode) const; 00185 00190 void 00191 getCountString( 00192 StylesheetExecutionContext& executionContext, 00193 XalanDOMString& theResult) const; 00194 00195 void 00196 getCountString( 00197 StylesheetExecutionContext& executionContext, 00198 const MutableNodeRefList& ancestors, 00199 CountersTable& ctable, 00200 CountType numberList[], 00201 NodeRefListBase::size_type numberListLength, 00202 XalanDOMString& theResult) const; 00203 00214 void 00215 getMatchingAncestors( 00216 StylesheetExecutionContext& executionContext, 00217 XalanNode* node, 00218 bool stopAtFirstFound, 00219 MutableNodeRefList& ancestors) const; 00220 00226 XalanNumberFormat* 00227 getNumberFormatter(StylesheetExecutionContext& executionContext) const; 00228 00237 void 00238 formatNumberList( 00239 StylesheetExecutionContext& executionContext, 00240 const CountType theList[], 00241 NodeRefListBase::size_type theListLength, 00242 XalanDOMString& formattedNumber) const; 00243 00255 static void 00256 int2singlealphaCount( 00257 CountType val, 00258 const XalanDOMString& table, 00259 XalanDOMString& theResult); 00260 00273 static void 00274 int2alphaCount( 00275 CountType val, 00276 const XalanDOMChar table[], 00277 XalanDOMString::size_type length, 00278 XalanDOMString& theResult); 00279 00291 static void 00292 tradAlphaCount( 00293 CountType val, 00294 XalanDOMString& theResult); 00295 00304 static void 00305 long2roman( 00306 CountType val, 00307 bool prefixesAreOK, 00308 XalanDOMString& theResult); 00309 00310 private: 00311 00312 void 00313 evaluateLetterValueAVT( 00314 StylesheetExecutionContext& executionContext, 00315 XalanDOMString& value) const; 00316 00317 void 00318 traditionalAlphaCount( 00319 CountType theValue, 00320 const XalanNumberingResourceBundle& theResourceBundle, 00321 XalanDOMString& theResult) const; 00322 00323 /* 00324 * Get Formatted number 00325 */ 00326 void 00327 getFormattedNumber( 00328 StylesheetExecutionContext& executionContext, 00329 XalanDOMChar numberType, 00330 XalanDOMString::size_type numberWidth, 00331 CountType listElement, 00332 XalanDOMString& theResult) const; 00333 00334 const XPath* m_countMatchPattern; 00335 const XPath* m_fromMatchPattern; 00336 const XPath* m_valueExpr; 00337 00338 CountType m_level; // = Constants.NUMBERLEVEL_SINGLE; 00339 00340 const AVT* m_format_avt; 00341 const AVT* m_lang_avt; 00342 const AVT* m_lettervalue_avt; 00343 const AVT* m_groupingSeparator_avt; 00344 const AVT* m_groupingSize_avt; 00345 00346 const unsigned long m_id; 00347 00351 static const XalanDOMChar s_atString[]; 00352 00356 static const XalanDOMString& s_textString; 00357 00361 static const XalanDOMString& s_commentString; 00362 00366 static const XalanDOMString& s_slashString; 00367 00371 static const XalanDOMChar s_piString[]; 00372 00376 static const XalanDOMChar s_levelString[]; 00377 00381 static const XalanDOMChar s_multipleString[]; 00382 00386 static const XalanDOMChar s_anyString[]; 00387 00391 static const XalanDOMChar s_singleString[]; 00392 00396 static const XalanDOMChar s_alphabeticString[]; 00397 00401 static const XalanDOMChar s_traditionalString[]; 00402 00406 static const XalanDOMChar s_errorString[]; 00407 00411 static const XalanDOMChar s_alphaCountTable[]; 00412 00413 static const XalanDOMString::size_type s_alphaCountTableSize; 00414 00415 static const XalanDOMChar s_elalphaCountTable[]; 00416 00417 static const XalanDOMString::size_type s_elalphaCountTableSize; 00418 00424 static const DecimalToRoman s_romanConvertTable[]; 00425 00429 static const XalanNumberingResourceBundle& s_elalphaResourceBundle; 00430 00431 00432 public: 00433 00438 class NumberFormatStringTokenizer 00439 { 00440 public: 00441 00442 typedef XalanDOMString::size_type size_type; 00443 00449 NumberFormatStringTokenizer(const XalanDOMString& theString); 00450 00456 void 00457 setString(const XalanDOMString& theString); 00458 00462 void 00463 reset() 00464 { 00465 m_currentPosition = 0; 00466 } 00467 00474 XalanDOMString 00475 nextToken(); 00476 00482 void 00483 nextToken(XalanDOMString& theToken); 00484 00490 bool 00491 hasMoreTokens() const 00492 { 00493 return m_currentPosition >= m_maxPosition ? false : true; 00494 } 00495 00501 size_type 00502 countTokens() const; 00503 00504 private: 00505 00506 size_type m_currentPosition; 00507 00508 size_type m_maxPosition; 00509 00510 const XalanDOMString* m_string; 00511 }; 00512 00513 private: 00514 }; 00515 00516 00517 00518 XALAN_CPP_NAMESPACE_END 00519 00520 00521 00522 #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.8 |
|