00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 1999 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 // Base class header file. 00068 #include <XSLT/ElemTemplateElement.hpp> 00069 00070 00071 00072 #include "XPath/MutableNodeRefList.hpp" 00073 00074 00075 00076 #include <XSLT/DecimalToRoman.hpp> 00077 #include <XSLT/XalanNumberingResourceBundle.hpp> 00078 00079 00080 00081 class AVT; 00082 class CountersTable; 00083 class XalanNumberFormat; 00084 class XPath; 00085 class XPathExecutionContext; 00086 00087 00088 00089 class ElemNumber: public ElemTemplateElement 00090 { 00091 private: 00092 00093 struct Counter; 00094 00095 public: 00096 00097 #if defined(XALAN_NO_NAMESPACES) 00098 typedef vector<DecimalToRoman> DecimalToRomanVectorType; 00099 typedef vector<int> IntArrayType; 00100 typedef map<XalanDOMChar, 00101 XalanNumberingResourceBundle, 00102 less<XalanDOMChar> > NumberingResourceBundleMapType; 00103 #else 00104 typedef std::vector<DecimalToRoman> DecimalToRomanVectorType; 00105 typedef std::vector<int> IntArrayType; 00106 typedef std::map<XalanDOMChar, 00107 XalanNumberingResourceBundle> NumberingResourceBundleMapType; 00108 #endif 00109 00113 static void 00114 initialize(); 00115 00119 static void 00120 terminate(); 00121 00131 ElemNumber( 00132 StylesheetConstructionContext& constructionContext, 00133 Stylesheet& stylesheetTree, 00134 const AttributeList& atts, 00135 int lineNumber, 00136 int columnNumber); 00137 00138 virtual 00139 ~ElemNumber(); 00140 00141 // These methods are inherited from ElemTemplateElement ... 00142 00143 virtual const XalanDOMString& 00144 getElementName() const; 00145 00146 virtual void 00147 execute(StylesheetExecutionContext& executionContext) const; 00148 00152 XalanNode* getPreviousNode( 00153 StylesheetExecutionContext& executionContext, 00154 XalanNode* pos) const; 00155 00159 XalanNode* getTargetNode( 00160 StylesheetExecutionContext& executionContext, 00161 XalanNode* sourceNode) const; 00162 00163 protected: 00164 00174 XalanNode* 00175 findAncestor( 00176 StylesheetExecutionContext& executionContext, 00177 const XPath* fromMatchPattern, 00178 const XPath* countMatchPattern, 00179 XalanNode* context, 00180 const XalanElement* namespaceContext) const; 00181 00191 XalanNode* 00192 findPrecedingOrAncestorOrSelf( 00193 StylesheetExecutionContext& executionContext, 00194 const XPath* fromMatchPattern, 00195 const XPath* countMatchPattern, 00196 XalanNode* context, 00197 const XalanElement* namespaceContext) const; 00198 00202 const XPath* 00203 getCountMatchPattern( 00204 StylesheetExecutionContext& executionContext, 00205 XalanNode* contextNode) const; 00206 00211 void 00212 getCountString( 00213 StylesheetExecutionContext& executionContext, 00214 XalanDOMString& theResult) const; 00215 00216 void 00217 getCountString( 00218 StylesheetExecutionContext& executionContext, 00219 XalanNode* sourceNode, 00220 const MutableNodeRefList& ancestors, 00221 CountersTable& ctable, 00222 int numberList[], 00223 unsigned int numberListLength, 00224 XalanDOMString& theResult) const; 00225 00235 void 00236 getMatchingAncestors( 00237 StylesheetExecutionContext& executionContext, 00238 XalanNode* node, 00239 bool stopAtFirstFound, 00240 MutableNodeRefList& ancestors) const; 00241 00248 XalanNumberFormat* 00249 getNumberFormatter( 00250 StylesheetExecutionContext& executionContext, 00251 XalanNode* contextNode) const; 00252 00262 void 00263 formatNumberList( 00264 StylesheetExecutionContext& executionContext, 00265 const int theList[], 00266 unsigned int theListLength, 00267 XalanNode* contextNode, 00268 XalanDOMString& formattedNumber) const; 00269 00281 static void 00282 int2singlealphaCount( 00283 int val, 00284 const XalanDOMString& table, 00285 XalanDOMString& theResult); 00286 00298 static void 00299 int2alphaCount( 00300 int val, 00301 const XalanDOMString& table, 00302 XalanDOMString& theResult); 00303 00315 static void 00316 tradAlphaCount( 00317 int val, 00318 XalanDOMString& theResult); 00319 00328 static void 00329 long2roman( 00330 long val, 00331 bool prefixesAreOK, 00332 XalanDOMString& theResult); 00333 00334 private: 00335 00336 bool 00337 evaluateLetterValueAVT( 00338 StylesheetExecutionContext& executionContext, 00339 XalanNode* contextNode, 00340 const XalanDOMString& compareValue) const; 00341 00342 void 00343 traditionalAlphaCount( 00344 int theValue, 00345 const XalanNumberingResourceBundle& theResourceBundle, 00346 XalanDOMString& theResult) const; 00347 00348 /* 00349 * Get Formatted number 00350 */ 00351 void 00352 getFormattedNumber( 00353 StylesheetExecutionContext& executionContext, 00354 XalanNode* contextNode, 00355 XalanDOMChar numberType, 00356 int numberWidth, 00357 int listElement, 00358 XalanDOMString& theResult) const; 00359 00360 const XPath* m_countMatchPattern; 00361 const XPath* m_fromMatchPattern; 00362 const XPath* m_valueExpr; 00363 00364 int m_level; // = Constants.NUMBERLEVEL_SINGLE; 00365 00366 const AVT* m_format_avt; 00367 const AVT* m_lang_avt; 00368 const AVT* m_lettervalue_avt; 00369 const AVT* m_groupingSeparator_avt; 00370 const AVT* m_groupingSize_avt; 00371 00375 static const XalanDOMString& s_atString; 00376 00380 static const XalanDOMString& s_textString; 00381 00385 static const XalanDOMString& s_commentString; 00386 00390 static const XalanDOMString& s_slashString; 00391 00395 static const XalanDOMString& s_piString; 00396 00400 static const XalanDOMString& s_leftParenString; 00401 00405 static const XalanDOMString& s_dotString; 00406 00410 static const XalanDOMString& s_oneString; 00411 00415 static const XalanDOMString& s_defaultSeparatorString; 00416 00421 static const XalanDOMString& s_alphaCountTable; 00422 00423 static const XalanDOMString& s_elalphaCountTable; 00424 00430 static const DecimalToRomanVectorType& s_romanConvertTable; 00431 00435 static const NumberingResourceBundleMapType& s_resourceBundles; 00436 00437 00442 class NumberFormatStringTokenizer 00443 { 00444 public: 00445 00451 NumberFormatStringTokenizer(const XalanDOMString& theString); 00452 00458 void 00459 setString(const XalanDOMString& theString); 00460 00464 void 00465 reset() 00466 { 00467 m_currentPosition = 0; 00468 } 00469 00476 XalanDOMString 00477 nextToken(); 00478 00484 void 00485 nextToken(XalanDOMString& theToken); 00486 00492 bool 00493 hasMoreTokens() const 00494 { 00495 return m_currentPosition >= m_maxPosition ? false : true; 00496 } 00497 00503 unsigned int 00504 countTokens() const; 00505 00506 private: 00507 00508 unsigned int m_currentPosition; 00509 00510 unsigned int m_maxPosition; 00511 00512 const XalanDOMString* m_string; 00513 }; 00514 }; 00515 00516 00517 00518 #endif // XALAN_ELEMNUMBER_HEADER_GUARD
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
![]() |
Xalan-C++ XSL Transformer Version 1.1 |
|