00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 1999-2002 The Apache Software Foundation. All rights 00006 * reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions 00010 * are met: 00011 * 00012 * 1. Redistributions of source code must retain the above copyright 00013 * notice, this list of conditions and the following disclaimer. 00014 * 00015 * 2. Redistributions in binary form must reproduce the above copyright 00016 * notice, this list of conditions and the following disclaimer in 00017 * the documentation and/or other materials provided with the 00018 * distribution. 00019 * 00020 * 3. The end-user documentation included with the redistribution, 00021 * if any, must include the following acknowledgment: 00022 * "This product includes software developed by the 00023 * Apache Software Foundation (http://www.apache.org/)." 00024 * Alternately, this acknowledgment may appear in the software itself, 00025 * if and wherever such third-party acknowledgments normally appear. 00026 * 00027 * 4. The names "Xalan" and "Apache Software Foundation" must 00028 * not be used to endorse or promote products derived from this 00029 * software without prior written permission. For written 00030 * permission, please contact apache@apache.org. 00031 * 00032 * 5. Products derived from this software may not be called "Apache", 00033 * nor may "Apache" appear in their name, without prior written 00034 * permission of the Apache Software Foundation. 00035 * 00036 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 00037 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00038 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00039 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 00040 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00041 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00042 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 00043 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00044 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00045 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00046 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00047 * SUCH DAMAGE. 00048 * ==================================================================== 00049 * 00050 * This software consists of voluntary contributions made by many 00051 * individuals on behalf of the Apache Software Foundation and was 00052 * originally based on software copyright (c) 1999, International 00053 * Business Machines, Inc., http://www.ibm.com. For more 00054 * information on the Apache Software Foundation, please see 00055 * <http://www.apache.org/>. 00056 */ 00057 #if !defined(XALAN_ELEMNUMBER_HEADER_GUARD) 00058 #define XALAN_ELEMNUMBER_HEADER_GUARD 00059 00060 00061 00062 // Base include file. Must be first. 00063 #include <XSLT/XSLTDefinitions.hpp> 00064 00065 00066 00067 #include <vector> 00068 00069 00070 00071 // Base class header file. 00072 #include <XSLT/ElemTemplateElement.hpp> 00073 00074 00075 00076 #include <XPath/NodeRefListBase.hpp> 00077 00078 00079 00080 #include <XSLT/DecimalToRoman.hpp> 00081 #include <XSLT/XalanNumberingResourceBundle.hpp> 00082 00083 00084 00085 class AVT; 00086 class CountersTable; 00087 class MutableNodeRefList; 00088 class XalanNumberFormat; 00089 class XPath; 00090 class XPathExecutionContext; 00091 00092 00093 00094 class ElemNumber: public ElemTemplateElement 00095 { 00096 private: 00097 00098 struct Counter; 00099 00100 public: 00101 00102 enum eLevel 00103 { 00104 eSingle, 00105 eMultiple, 00106 eAny 00107 }; 00108 00109 #if defined(XALAN_NO_NAMESPACES) 00110 typedef vector<int> IntArrayType; 00111 #else 00112 typedef std::vector<int> IntArrayType; 00113 #endif 00114 00118 static void 00119 initialize(); 00120 00124 static void 00125 terminate(); 00126 00136 ElemNumber( 00137 StylesheetConstructionContext& constructionContext, 00138 Stylesheet& stylesheetTree, 00139 const AttributeList& atts, 00140 int lineNumber, 00141 int columnNumber); 00142 00143 virtual 00144 ~ElemNumber(); 00145 00146 // These methods are inherited from ElemTemplateElement ... 00147 00148 virtual const XalanDOMString& 00149 getElementName() const; 00150 00151 virtual void 00152 execute(StylesheetExecutionContext& executionContext) const; 00153 00157 XalanNode* getPreviousNode( 00158 StylesheetExecutionContext& executionContext, 00159 XalanNode* pos) const; 00160 00164 XalanNode* getTargetNode( 00165 StylesheetExecutionContext& executionContext, 00166 XalanNode* sourceNode) const; 00167 00168 protected: 00169 00179 XalanNode* 00180 findAncestor( 00181 StylesheetExecutionContext& executionContext, 00182 const XPath* fromMatchPattern, 00183 const XPath* countMatchPattern, 00184 XalanNode* context, 00185 const XalanElement* namespaceContext) const; 00186 00196 XalanNode* 00197 findPrecedingOrAncestorOrSelf( 00198 StylesheetExecutionContext& executionContext, 00199 const XPath* fromMatchPattern, 00200 const XPath* countMatchPattern, 00201 XalanNode* context, 00202 const XalanElement* namespaceContext) const; 00203 00207 const XPath* 00208 getCountMatchPattern( 00209 StylesheetExecutionContext& executionContext, 00210 XalanNode* contextNode) const; 00211 00216 void 00217 getCountString( 00218 StylesheetExecutionContext& executionContext, 00219 XalanDOMString& theResult) const; 00220 00221 void 00222 getCountString( 00223 StylesheetExecutionContext& executionContext, 00224 XalanNode* sourceNode, 00225 const MutableNodeRefList& ancestors, 00226 CountersTable& ctable, 00227 int numberList[], 00228 NodeRefListBase::size_type numberListLength, 00229 XalanDOMString& theResult) const; 00230 00241 void 00242 getMatchingAncestors( 00243 StylesheetExecutionContext& executionContext, 00244 XalanNode* node, 00245 bool stopAtFirstFound, 00246 MutableNodeRefList& ancestors) const; 00247 00254 XalanNumberFormat* 00255 getNumberFormatter( 00256 StylesheetExecutionContext& executionContext, 00257 XalanNode* contextNode) const; 00258 00268 void 00269 formatNumberList( 00270 StylesheetExecutionContext& executionContext, 00271 const int theList[], 00272 NodeRefListBase::size_type theListLength, 00273 XalanNode* contextNode, 00274 XalanDOMString& formattedNumber) const; 00275 00287 static void 00288 int2singlealphaCount( 00289 int val, 00290 const XalanDOMString& table, 00291 XalanDOMString& theResult); 00292 00305 static void 00306 int2alphaCount( 00307 int val, 00308 const XalanDOMChar table[], 00309 XalanDOMString::size_type length, 00310 XalanDOMString& theResult); 00311 00323 static void 00324 tradAlphaCount( 00325 int val, 00326 XalanDOMString& theResult); 00327 00336 static void 00337 long2roman( 00338 long val, 00339 bool prefixesAreOK, 00340 XalanDOMString& theResult); 00341 00342 private: 00343 00352 void 00353 long2roman( 00354 StylesheetExecutionContext& executionContext, 00355 XalanNode* contextNode, 00356 long val, 00357 bool prefixesAreOK, 00358 XalanDOMString& theResult) const; 00359 00360 void 00361 evaluateLetterValueAVT( 00362 StylesheetExecutionContext& executionContext, 00363 XalanNode* contextNode, 00364 XalanDOMString& value) const; 00365 00366 void 00367 traditionalAlphaCount( 00368 int theValue, 00369 const XalanNumberingResourceBundle& theResourceBundle, 00370 XalanDOMString& theResult) const; 00371 00372 /* 00373 * Get Formatted number 00374 */ 00375 void 00376 getFormattedNumber( 00377 StylesheetExecutionContext& executionContext, 00378 XalanNode* contextNode, 00379 XalanDOMChar numberType, 00380 XalanDOMString::size_type numberWidth, 00381 int listElement, 00382 XalanDOMString& theResult) const; 00383 00384 const XPath* m_countMatchPattern; 00385 const XPath* m_fromMatchPattern; 00386 const XPath* m_valueExpr; 00387 00388 int m_level; // = Constants.NUMBERLEVEL_SINGLE; 00389 00390 const AVT* m_format_avt; 00391 const AVT* m_lang_avt; 00392 const AVT* m_lettervalue_avt; 00393 const AVT* m_groupingSeparator_avt; 00394 const AVT* m_groupingSize_avt; 00395 00399 static const XalanDOMChar s_atString[]; 00400 00404 static const XalanDOMString& s_textString; 00405 00409 static const XalanDOMString& s_commentString; 00410 00414 static const XalanDOMString& s_slashString; 00415 00419 static const XalanDOMChar s_piString[]; 00420 00424 static const XalanDOMChar s_levelString[]; 00425 00429 static const XalanDOMChar s_multipleString[]; 00430 00434 static const XalanDOMChar s_anyString[]; 00435 00439 static const XalanDOMChar s_singleString[]; 00440 00444 static const XalanDOMChar s_alphabeticString[]; 00445 00449 static const XalanDOMChar s_traditionalString[]; 00450 00454 static const XalanDOMChar s_alphaCountTable[]; 00455 00456 static const XalanDOMString::size_type s_alphaCountTableSize; 00457 00458 static const XalanDOMChar s_elalphaCountTable[]; 00459 00460 static const XalanDOMString::size_type s_elalphaCountTableSize; 00461 00467 static const DecimalToRoman s_romanConvertTable[]; 00468 00472 static const XalanNumberingResourceBundle& s_elalphaResourceBundle; 00473 00474 00475 public: 00476 00481 class NumberFormatStringTokenizer 00482 { 00483 public: 00484 00485 typedef XalanDOMString::size_type size_type; 00486 00492 NumberFormatStringTokenizer(const XalanDOMString& theString); 00493 00499 void 00500 setString(const XalanDOMString& theString); 00501 00505 void 00506 reset() 00507 { 00508 m_currentPosition = 0; 00509 } 00510 00517 XalanDOMString 00518 nextToken(); 00519 00525 void 00526 nextToken(XalanDOMString& theToken); 00527 00533 bool 00534 hasMoreTokens() const 00535 { 00536 return m_currentPosition >= m_maxPosition ? false : true; 00537 } 00538 00544 size_type 00545 countTokens() const; 00546 00547 private: 00548 00549 size_type m_currentPosition; 00550 00551 size_type m_maxPosition; 00552 00553 const XalanDOMString* m_string; 00554 }; 00555 00556 private: 00557 }; 00558 00559 00560 00561 #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.4 |
|