00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 1999-2004 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 <xalanc/XSLT/XSLTDefinitions.hpp> 00064 00065 00066 00067 #include <vector> 00068 00069 00070 00071 // Base class header file. 00072 #include <xalanc/XSLT/ElemTemplateElement.hpp> 00073 00074 00075 00076 #include <xalanc/XPath/NodeRefListBase.hpp> 00077 00078 00079 00080 #include <xalanc/XSLT/CountersTable.hpp> 00081 #include <xalanc/XSLT/DecimalToRoman.hpp> 00082 #include <xalanc/XSLT/XalanNumberingResourceBundle.hpp> 00083 00084 00085 00086 XALAN_CPP_NAMESPACE_BEGIN 00087 00088 00089 00090 class AVT; 00091 class MutableNodeRefList; 00092 class XalanNumberFormat; 00093 class XPath; 00094 class XPathExecutionContext; 00095 00096 00097 00098 class ElemNumber: public ElemTemplateElement 00099 { 00100 public: 00101 00102 typedef CountersTable::CountType CountType; 00103 00104 enum eLevel 00105 { 00106 eSingle, 00107 eMultiple, 00108 eAny 00109 }; 00110 00111 #if defined(XALAN_NO_STD_NAMESPACE) 00112 typedef vector<CountType> CountTypeArrayType; 00113 #else 00114 typedef std::vector<CountType> CountTypeArrayType; 00115 #endif 00116 00120 static void 00121 initialize(); 00122 00126 static void 00127 terminate(); 00128 00139 ElemNumber( 00140 StylesheetConstructionContext& constructionContext, 00141 Stylesheet& stylesheetTree, 00142 const AttributeListType& atts, 00143 int lineNumber, 00144 int columnNumber, 00145 unsigned long id); 00146 00147 virtual 00148 ~ElemNumber(); 00149 00150 // These methods are inherited from ElemTemplateElement ... 00151 00152 virtual const XalanDOMString& 00153 getElementName() const; 00154 00155 virtual void 00156 execute(StylesheetExecutionContext& executionContext) const; 00157 00158 unsigned long 00159 getID() const 00160 { 00161 return m_id; 00162 } 00163 00167 XalanNode* getPreviousNode( 00168 StylesheetExecutionContext& executionContext, 00169 XalanNode* pos) const; 00170 00174 XalanNode* getTargetNode( 00175 StylesheetExecutionContext& executionContext, 00176 XalanNode* sourceNode) const; 00177 00178 virtual const XPath* 00179 getXPath(unsigned int index = 0) const; 00180 00181 protected: 00182 00194 XalanNode* 00195 findAncestor( 00196 StylesheetExecutionContext& executionContext, 00197 const XPath* fromMatchPattern, 00198 const XPath* countMatchPattern, 00199 XalanNode* context) const; 00200 00212 XalanNode* 00213 findPrecedingOrAncestorOrSelf( 00214 StylesheetExecutionContext& executionContext, 00215 const XPath* fromMatchPattern, 00216 const XPath* countMatchPattern, 00217 XalanNode* context) const; 00218 00222 const XPath* 00223 getCountMatchPattern( 00224 StylesheetExecutionContext& executionContext, 00225 XalanNode* contextNode) const; 00226 00231 void 00232 getCountString( 00233 StylesheetExecutionContext& executionContext, 00234 XalanDOMString& theResult) const; 00235 00236 void 00237 getCountString( 00238 StylesheetExecutionContext& executionContext, 00239 const MutableNodeRefList& ancestors, 00240 CountersTable& ctable, 00241 CountType numberList[], 00242 NodeRefListBase::size_type numberListLength, 00243 XalanDOMString& theResult) const; 00244 00255 void 00256 getMatchingAncestors( 00257 StylesheetExecutionContext& executionContext, 00258 XalanNode* node, 00259 bool stopAtFirstFound, 00260 MutableNodeRefList& ancestors) const; 00261 00267 XalanNumberFormat* 00268 getNumberFormatter(StylesheetExecutionContext& executionContext) const; 00269 00278 void 00279 formatNumberList( 00280 StylesheetExecutionContext& executionContext, 00281 const CountType theList[], 00282 NodeRefListBase::size_type theListLength, 00283 XalanDOMString& formattedNumber) const; 00284 00296 static void 00297 int2singlealphaCount( 00298 CountType val, 00299 const XalanDOMString& table, 00300 XalanDOMString& theResult); 00301 00314 static void 00315 int2alphaCount( 00316 CountType val, 00317 const XalanDOMChar table[], 00318 XalanDOMString::size_type length, 00319 XalanDOMString& theResult); 00320 00332 static void 00333 tradAlphaCount( 00334 CountType val, 00335 XalanDOMString& theResult); 00336 00345 static void 00346 long2roman( 00347 CountType val, 00348 bool prefixesAreOK, 00349 XalanDOMString& theResult); 00350 00351 private: 00352 00353 void 00354 evaluateLetterValueAVT( 00355 StylesheetExecutionContext& executionContext, 00356 XalanDOMString& value) const; 00357 00358 void 00359 traditionalAlphaCount( 00360 CountType theValue, 00361 const XalanNumberingResourceBundle& theResourceBundle, 00362 XalanDOMString& theResult) const; 00363 00364 /* 00365 * Get Formatted number 00366 */ 00367 void 00368 getFormattedNumber( 00369 StylesheetExecutionContext& executionContext, 00370 XalanDOMChar numberType, 00371 XalanDOMString::size_type numberWidth, 00372 CountType listElement, 00373 XalanDOMString& theResult) const; 00374 00375 const XPath* m_countMatchPattern; 00376 const XPath* m_fromMatchPattern; 00377 const XPath* m_valueExpr; 00378 00379 CountType m_level; // = Constants.NUMBERLEVEL_SINGLE; 00380 00381 const AVT* m_format_avt; 00382 const AVT* m_lang_avt; 00383 const AVT* m_lettervalue_avt; 00384 const AVT* m_groupingSeparator_avt; 00385 const AVT* m_groupingSize_avt; 00386 00387 const unsigned long m_id; 00388 00392 static const XalanDOMChar s_atString[]; 00393 00397 static const XalanDOMString& s_textString; 00398 00402 static const XalanDOMString& s_commentString; 00403 00407 static const XalanDOMString& s_slashString; 00408 00412 static const XalanDOMChar s_piString[]; 00413 00417 static const XalanDOMChar s_levelString[]; 00418 00422 static const XalanDOMChar s_multipleString[]; 00423 00427 static const XalanDOMChar s_anyString[]; 00428 00432 static const XalanDOMChar s_singleString[]; 00433 00437 static const XalanDOMChar s_alphabeticString[]; 00438 00442 static const XalanDOMChar s_traditionalString[]; 00443 00447 static const XalanDOMChar s_errorString[]; 00448 00452 static const XalanDOMChar s_alphaCountTable[]; 00453 00454 static const XalanDOMString::size_type s_alphaCountTableSize; 00455 00456 static const XalanDOMChar s_elalphaCountTable[]; 00457 00458 static const XalanDOMString::size_type s_elalphaCountTableSize; 00459 00465 static const DecimalToRoman s_romanConvertTable[]; 00466 00470 static const XalanNumberingResourceBundle& s_elalphaResourceBundle; 00471 00472 00473 public: 00474 00479 class NumberFormatStringTokenizer 00480 { 00481 public: 00482 00483 typedef XalanDOMString::size_type size_type; 00484 00490 NumberFormatStringTokenizer(const XalanDOMString& theString); 00491 00497 void 00498 setString(const XalanDOMString& theString); 00499 00503 void 00504 reset() 00505 { 00506 m_currentPosition = 0; 00507 } 00508 00515 XalanDOMString 00516 nextToken(); 00517 00523 void 00524 nextToken(XalanDOMString& theToken); 00525 00531 bool 00532 hasMoreTokens() const 00533 { 00534 return m_currentPosition >= m_maxPosition ? false : true; 00535 } 00536 00542 size_type 00543 countTokens() const; 00544 00545 private: 00546 00547 size_type m_currentPosition; 00548 00549 size_type m_maxPosition; 00550 00551 const XalanDOMString* m_string; 00552 }; 00553 00554 private: 00555 }; 00556 00557 00558 00559 XALAN_CPP_NAMESPACE_END 00560 00561 00562 00563 #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.7 |
|