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 00067 00068 // Base include file. Must be first. 00069 #include <XSLT/XSLTDefinitions.hpp> 00070 00071 00072 00073 // Base class header file. 00074 #include <XSLT/ElemTemplateElement.hpp> 00075 00076 00077 00078 #include "XPath/MutableNodeRefList.hpp" 00079 00080 00081 00082 #include <XSLT/DecimalToRoman.hpp> 00083 #include <XSLT/XalanNumberingResourceBundle.hpp> 00084 00085 00086 00087 class AVT; 00088 class QName; 00089 class XalanNumberFormat; 00090 class XPath; 00091 class XPathExecutionContext; 00092 00093 00094 00095 class ElemNumber: public ElemTemplateElement 00096 { 00097 private: 00098 00099 struct Counter; 00100 00101 public: 00102 00103 #if defined(XALAN_NO_NAMESPACES) 00104 typedef vector<DecimalToRoman> DecimalToRomanVectorType; 00105 typedef vector<int> IntArrayType; 00106 typedef map<XalanDOMChar, 00107 XalanNumberingResourceBundle, 00108 less<XalanDOMChar> > NumberingResourceBundleMapType; 00109 #else 00110 typedef std::vector<DecimalToRoman> DecimalToRomanVectorType; 00111 typedef std::vector<int> IntArrayType; 00112 typedef std::map<XalanDOMChar, 00113 XalanNumberingResourceBundle> NumberingResourceBundleMapType; 00114 #endif 00115 00119 static void 00120 initialize(); 00121 00125 static void 00126 terminate(); 00127 00137 ElemNumber( 00138 StylesheetConstructionContext& constructionContext, 00139 Stylesheet& stylesheetTree, 00140 const AttributeList& atts, 00141 int lineNumber, 00142 int columnNumber); 00143 00144 virtual 00145 ~ElemNumber(); 00146 00147 // These methods are inherited from ElemTemplateElement ... 00148 00149 virtual const XalanDOMString& 00150 getElementName() const; 00151 00152 virtual void 00153 execute( 00154 StylesheetExecutionContext& executionContext, 00155 XalanNode* sourceTree, 00156 XalanNode* sourceNode, 00157 const QName& mode) const; 00158 00162 XalanNode* getPreviousNode( 00163 StylesheetExecutionContext& executionContext, 00164 XalanNode* pos) const; 00165 00169 XalanNode* getTargetNode( 00170 StylesheetExecutionContext& executionContext, 00171 XalanNode* sourceNode) const; 00172 00173 protected: 00174 00184 XalanNode* 00185 findAncestor( 00186 StylesheetExecutionContext& executionContext, 00187 const XPath* fromMatchPattern, 00188 const XPath* countMatchPattern, 00189 XalanNode* context, 00190 const XalanElement* namespaceContext) const; 00191 00201 XalanNode* 00202 findPrecedingOrAncestorOrSelf( 00203 StylesheetExecutionContext& executionContext, 00204 const XPath* fromMatchPattern, 00205 const XPath* countMatchPattern, 00206 XalanNode* context, 00207 const XalanElement* namespaceContext) const; 00208 00212 const XPath* 00213 getCountMatchPattern( 00214 StylesheetExecutionContext& executionContext, 00215 XalanNode* contextNode) const; 00216 00221 XalanDOMString 00222 getCountString( 00223 StylesheetExecutionContext& executionContext, 00224 XalanNode* sourceTree, 00225 XalanNode* sourceNode) const; 00226 00235 MutableNodeRefList getMatchingAncestors( 00236 StylesheetExecutionContext& executionContext, 00237 XalanNode* node, 00238 bool stopAtFirstFound) const; 00239 00246 XalanNumberFormat* 00247 getNumberFormatter( 00248 StylesheetExecutionContext& executionContext, 00249 XalanNode* contextNode) const; 00250 00261 XalanDOMString 00262 formatNumberList( 00263 StylesheetExecutionContext& executionContext, 00264 const IntArrayType& theList, 00265 XalanNode* contextNode) const; 00266 00278 XalanDOMString int2singlealphaCount(int val, 00279 const XalanDOMString& table); 00280 00292 static XalanDOMString 00293 int2alphaCount( 00294 int val, 00295 const XalanDOMString& table); 00296 00308 static XalanDOMString 00309 tradAlphaCount(int val); 00310 00320 static XalanDOMString 00321 long2roman( 00322 long val, 00323 bool prefixesAreOK); 00324 00325 private: 00326 00327 bool 00328 evaluateLetterValueAVT( 00329 StylesheetExecutionContext& executionContext, 00330 XalanNode* contextNode, 00331 const XalanDOMString& compareValue) const; 00332 00333 XalanDOMString 00334 traditionalAlphaCount( 00335 int theValue, 00336 const XalanNumberingResourceBundle& theResourceBundle) const; 00337 00338 /* 00339 * Get Formatted number 00340 */ 00341 XalanDOMString 00342 getFormattedNumber( 00343 StylesheetExecutionContext& executionContext, 00344 XalanNode* contextNode, 00345 XalanDOMChar numberType, 00346 int numberWidth, 00347 int listElement) const; 00348 00349 const XPath* m_countMatchPattern; 00350 const XPath* m_fromMatchPattern; 00351 const XPath* m_valueExpr; 00352 00353 int m_level; // = Constants.NUMBERLEVEL_SINGLE; 00354 00355 const AVT* m_format_avt; 00356 const AVT* m_lang_avt; 00357 const AVT* m_lettervalue_avt; 00358 const AVT* m_groupingSeparator_avt; 00359 const AVT* m_groupingSize_avt; 00360 00364 static const XalanDOMString& s_atString; 00365 00369 static const XalanDOMString& s_textString; 00370 00374 static const XalanDOMString& s_commentString; 00375 00379 static const XalanDOMString& s_slashString; 00380 00384 static const XalanDOMString& s_piString; 00385 00389 static const XalanDOMString& s_leftParenString; 00390 00394 static const XalanDOMString& s_dotString; 00395 00399 static const XalanDOMString& s_oneString; 00400 00405 static const XalanDOMString& s_alphaCountTable; 00406 00407 static const XalanDOMString& s_elalphaCountTable; 00408 00414 static const DecimalToRomanVectorType& s_romanConvertTable; 00415 00419 static const NumberingResourceBundleMapType& s_resourceBundles; 00420 00421 00426 class NumberFormatStringTokenizer 00427 { 00428 public: 00429 00435 explicit 00436 NumberFormatStringTokenizer(const XalanDOMString& theStr = XalanDOMString()); 00437 00443 void 00444 setString(const XalanDOMString& theString); 00445 00449 void 00450 reset() 00451 { 00452 m_currentPosition = 0; 00453 } 00454 00461 XalanDOMString 00462 nextToken(); 00463 00469 bool 00470 hasMoreTokens() const 00471 { 00472 return (m_currentPosition >= m_maxPosition) ? false : true; 00473 } 00474 00480 int 00481 countTokens() const; 00482 00483 private: 00484 00485 int m_currentPosition; 00486 int m_maxPosition; 00487 XalanDOMString m_str; 00488 }; // end NumberFormatStringTokenizer 00489 00490 }; // end ElemNumber 00491 00492 #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 |
|