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 00299 static void 00300 toRoman( 00301 CountType val, 00302 bool prefixesAreOK, 00303 XalanDOMString& theResult); 00304 00305 private: 00306 00307 void 00308 evaluateLetterValueAVT( 00309 StylesheetExecutionContext& executionContext, 00310 XalanDOMString& value) const; 00311 00312 void 00313 traditionalAlphaCount( 00314 CountType theValue, 00315 const XalanNumberingResourceBundle& theResourceBundle, 00316 XalanDOMString& theResult) const; 00317 00318 /* 00319 * Get Formatted number 00320 */ 00321 void 00322 getFormattedNumber( 00323 StylesheetExecutionContext& executionContext, 00324 XalanDOMChar numberType, 00325 XalanDOMString::size_type numberWidth, 00326 CountType listElement, 00327 XalanDOMString& theResult) const; 00328 00329 const XPath* m_countMatchPattern; 00330 const XPath* m_fromMatchPattern; 00331 const XPath* m_valueExpr; 00332 00333 CountType m_level; // = Constants.NUMBERLEVEL_SINGLE; 00334 00335 const AVT* m_format_avt; 00336 const AVT* m_lang_avt; 00337 const AVT* m_lettervalue_avt; 00338 const AVT* m_groupingSeparator_avt; 00339 const AVT* m_groupingSize_avt; 00340 00341 const unsigned long m_id; 00342 00346 static const XalanDOMChar s_atString[]; 00347 00351 static const XalanDOMString& s_textString; 00352 00356 static const XalanDOMString& s_commentString; 00357 00361 static const XalanDOMString& s_slashString; 00362 00366 static const XalanDOMChar s_piString[]; 00367 00371 static const XalanDOMChar s_levelString[]; 00372 00376 static const XalanDOMChar s_multipleString[]; 00377 00381 static const XalanDOMChar s_anyString[]; 00382 00386 static const XalanDOMChar s_singleString[]; 00387 00391 static const XalanDOMChar s_alphabeticString[]; 00392 00396 static const XalanDOMChar s_traditionalString[]; 00397 00401 static const XalanDOMChar s_errorString[]; 00402 00406 static const XalanDOMChar s_alphaCountTable[]; 00407 00408 static const XalanDOMString::size_type s_alphaCountTableSize; 00409 00410 static const XalanDOMChar s_elalphaCountTable[]; 00411 00412 static const XalanDOMString::size_type s_elalphaCountTableSize; 00413 00419 static const DecimalToRoman s_romanConvertTable[]; 00420 00421 static const size_t s_romanConvertTableSize; 00425 static const XalanNumberingResourceBundle& s_elalphaResourceBundle; 00426 00427 00428 public: 00429 00434 class NumberFormatStringTokenizer 00435 { 00436 public: 00437 00438 typedef XalanDOMString::size_type size_type; 00439 00445 NumberFormatStringTokenizer(const XalanDOMString& theString); 00446 00452 void 00453 setString(const XalanDOMString& theString); 00454 00458 void 00459 reset() 00460 { 00461 m_currentPosition = 0; 00462 } 00463 00464 00470 void 00471 nextToken(XalanDOMString& theToken); 00472 00478 bool 00479 hasMoreTokens() const 00480 { 00481 return m_currentPosition >= m_maxPosition ? false : true; 00482 } 00483 00489 size_type 00490 countTokens() const; 00491 00492 private: 00493 00494 size_type m_currentPosition; 00495 00496 size_type m_maxPosition; 00497 00498 const XalanDOMString* m_string; 00499 }; 00500 00501 private: 00502 }; 00503 00504 00505 00506 XALAN_CPP_NAMESPACE_END 00507 00508 00509 00510 #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.10 |
|