## Xalan-C++ API Documentation

### The Xalan C++ XSLT Processor Version 1.5

Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members

# ElemNumber.hpp

Go to the documentation of this file.

    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/CountersTable.hpp>
    00081 #include <XSLT/DecimalToRoman.hpp>
    00082 #include <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 protected:
    00179
    00191     XalanNode*
    00192     findAncestor(
    00193             StylesheetExecutionContext&     executionContext,
    00194             const XPath*                    fromMatchPattern,
    00195             const XPath*                    countMatchPattern,
    00196             XalanNode*                      context) const;
    00197
    00209     XalanNode*
    00210     findPrecedingOrAncestorOrSelf(
    00211             StylesheetExecutionContext&     executionContext,
    00212             const XPath*                    fromMatchPattern,
    00213             const XPath*                    countMatchPattern,
    00214             XalanNode*                      context) const;
    00215
    00219     const XPath*
    00220     getCountMatchPattern(
    00221             StylesheetExecutionContext&     executionContext,
    00222             XalanNode*                      contextNode) const;
    00223
    00228     void
    00229     getCountString(
    00230             StylesheetExecutionContext&     executionContext,
    00231             XalanDOMString&                 theResult) const;
    00232
    00233     void
    00234     getCountString(
    00235             StylesheetExecutionContext&     executionContext,
    00236             const MutableNodeRefList&       ancestors,
    00237             CountersTable&                  ctable,
    00238             CountType                       numberList[],
    00239             NodeRefListBase::size_type      numberListLength,
    00240             XalanDOMString&                 theResult) const;
    00241
    00252     void
    00253     getMatchingAncestors(
    00254             StylesheetExecutionContext&     executionContext,
    00255             XalanNode*                      node,
    00256             bool                            stopAtFirstFound,
    00257             MutableNodeRefList&             ancestors) const;
    00258
    00264     XalanNumberFormat*
    00265     getNumberFormatter(StylesheetExecutionContext&      executionContext) const;
    00266
    00275     void
    00276     formatNumberList(
    00277             StylesheetExecutionContext&     executionContext,
    00278             const CountType                 theList[],
    00279             NodeRefListBase::size_type      theListLength,
    00280             XalanDOMString&                 formattedNumber) const;
    00281
    00293     static void
    00294     int2singlealphaCount(
    00295             CountType               val,
    00296             const XalanDOMString&   table,
    00297             XalanDOMString&         theResult);
    00298
    00311     static void
    00312     int2alphaCount(
    00313             CountType                   val,
    00314             const XalanDOMChar          table[],
    00315             XalanDOMString::size_type   length,
    00316             XalanDOMString&             theResult);
    00317
    00329     static void
    00330     tradAlphaCount(
    00331             CountType           val,
    00332             XalanDOMString&     theResult);
    00333
    00342     static void
    00343     long2roman(
    00344             CountType           val,
    00345             bool                prefixesAreOK,
    00346             XalanDOMString&     theResult);
    00347
    00348 private:
    00349
    00350     void
    00351     evaluateLetterValueAVT(
    00352             StylesheetExecutionContext&     executionContext,
    00353             XalanDOMString&                 value) const;
    00354
    00355     void
    00356     traditionalAlphaCount(
    00357             CountType                               theValue,
    00358             const XalanNumberingResourceBundle&     theResourceBundle,
    00359             XalanDOMString&                         theResult) const;
    00360
    00361     /*
    00362      * Get Formatted number
    00363      */
    00364     void
    00365     getFormattedNumber(
    00366             StylesheetExecutionContext&     executionContext,
    00367             XalanDOMChar                    numberType,
    00368             XalanDOMString::size_type       numberWidth,
    00369             CountType                       listElement,
    00370             XalanDOMString&                 theResult) const;
    00371
    00372     const XPath*    m_countMatchPattern;
    00373     const XPath*    m_fromMatchPattern;
    00374     const XPath*    m_valueExpr;
    00375
    00376     CountType       m_level; // = Constants.NUMBERLEVEL_SINGLE;
    00377
    00378     const AVT*      m_format_avt;
    00379     const AVT*      m_lang_avt;
    00380     const AVT*      m_lettervalue_avt;
    00381     const AVT*      m_groupingSeparator_avt;
    00382     const AVT*      m_groupingSize_avt;
    00383
    00384     const unsigned long     m_id;
    00385
    00389     static const XalanDOMChar               s_atString[];
    00390
    00394     static const XalanDOMString&            s_textString;
    00395
    00399     static const XalanDOMString&            s_commentString;
    00400
    00404     static const XalanDOMString&            s_slashString;
    00405
    00409     static const XalanDOMChar               s_piString[];
    00410
    00414     static const XalanDOMChar               s_levelString[];
    00415
    00419     static const XalanDOMChar               s_multipleString[];
    00420
    00424     static const XalanDOMChar               s_anyString[];
    00425
    00429     static const XalanDOMChar               s_singleString[];
    00430
    00434     static const XalanDOMChar               s_alphabeticString[];
    00435
    00439     static const XalanDOMChar               s_traditionalString[];
    00440
    00444     static const XalanDOMChar               s_errorString[];
    00445
    00449     static const XalanDOMChar               s_alphaCountTable[];
    00450
    00451     static const XalanDOMString::size_type  s_alphaCountTableSize;
    00452
    00453     static const XalanDOMChar               s_elalphaCountTable[];
    00454
    00455     static const XalanDOMString::size_type  s_elalphaCountTableSize;
    00456
    00462     static const DecimalToRoman             s_romanConvertTable[];
    00463
    00467     static const XalanNumberingResourceBundle&  s_elalphaResourceBundle;
    00468
    00469
    00470 public:
    00471
    00476     class NumberFormatStringTokenizer
    00477     {
    00478     public:
    00479
    00480         typedef XalanDOMString::size_type   size_type;
    00481
    00487         NumberFormatStringTokenizer(const XalanDOMString&   theString);
    00488
    00494         void
    00495         setString(const XalanDOMString& theString);
    00496
    00500         void
    00501         reset()
    00502         {
    00503             m_currentPosition = 0;
    00504         }
    00505
    00512         XalanDOMString
    00513         nextToken();
    00514
    00520         void
    00521         nextToken(XalanDOMString&   theToken);
    00522
    00528         bool
    00529         hasMoreTokens() const
    00530         {
    00531             return m_currentPosition >= m_maxPosition ? false : true;
    00532         }
    00533
    00539         size_type
    00540         countTokens() const;
    00541
    00542     private:
    00543
    00544         size_type               m_currentPosition;
    00545
    00546         size_type               m_maxPosition;
    00547
    00548         const XalanDOMString*   m_string;
    00549     };
    00550
    00551 private:
    00552 };
    00553
    00554
    00555
    00556 XALAN_CPP_NAMESPACE_END
    00557
    00558
    00559
    00560 #endif  // XALAN_ELEMNUMBER_HEADER_GUARD

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

Xalan-C++ XSLT Processor Version 1.5 Copyright © 2000, 2001, 2002, 2003 The Apache Software Foundation. All Rights Reserved.