Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.3

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 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             NodeRefListBase::size_type      numberListLength,
00224             XalanDOMString&                 theResult) const;
00225 
00236     void
00237     getMatchingAncestors(
00238             StylesheetExecutionContext&     executionContext,
00239             XalanNode*                      node, 
00240             bool                            stopAtFirstFound,
00241             MutableNodeRefList&             ancestors) const;
00242 
00249     XalanNumberFormat*
00250     getNumberFormatter(
00251             StylesheetExecutionContext&     executionContext,
00252             XalanNode*                      contextNode) const;
00253 
00263     void
00264     formatNumberList(   
00265             StylesheetExecutionContext&     executionContext,
00266             const int                       theList[],
00267             NodeRefListBase::size_type      theListLength,
00268             XalanNode*                      contextNode,
00269             XalanDOMString&                 formattedNumber) const;
00270 
00282     static void
00283     int2singlealphaCount(
00284             int                     val,
00285             const XalanDOMString&   table,
00286             XalanDOMString&         theResult);
00287         
00299     static void
00300     int2alphaCount(
00301             int                     val,
00302             const XalanDOMString&   table,
00303             XalanDOMString&         theResult);
00304 
00316     static void
00317     tradAlphaCount(
00318             int                 val,
00319             XalanDOMString&     theResult);
00320 
00329     static void
00330     long2roman(
00331             long                val,
00332             bool                prefixesAreOK,
00333             XalanDOMString&     theResult);
00334 
00335 private:
00336 
00345     void
00346     long2roman(
00347             StylesheetExecutionContext&     executionContext,
00348             XalanNode*                      contextNode,
00349             long                            val,
00350             bool                            prefixesAreOK,
00351             XalanDOMString&                 theResult) const;
00352 
00353     void
00354     evaluateLetterValueAVT(
00355             StylesheetExecutionContext&     executionContext,
00356             XalanNode*                      contextNode,
00357             XalanDOMString&                 value) const;
00358 
00359     void
00360     traditionalAlphaCount(
00361             int                                     theValue,
00362             const XalanNumberingResourceBundle&     theResourceBundle,
00363             XalanDOMString&                         theResult) const;
00364 
00365     /*
00366      * Get Formatted number
00367      */
00368     void
00369     getFormattedNumber(
00370             StylesheetExecutionContext&     executionContext,
00371             XalanNode*                      contextNode,
00372             XalanDOMChar                    numberType,
00373             XalanDOMString::size_type       numberWidth,
00374             int                             listElement,
00375             XalanDOMString&                 theResult) const;
00376 
00377     const XPath*    m_countMatchPattern;
00378     const XPath*    m_fromMatchPattern;
00379     const XPath*    m_valueExpr;
00380 
00381     int             m_level; // = Constants.NUMBERLEVEL_SINGLE;
00382 
00383     const AVT*      m_format_avt;
00384     const AVT*      m_lang_avt;
00385     const AVT*      m_lettervalue_avt;
00386     const AVT*      m_groupingSeparator_avt;
00387     const AVT*      m_groupingSize_avt;
00388 
00392     static const XalanDOMString&            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 XalanDOMString&            s_piString;
00413 
00417     static const XalanDOMString&            s_leftParenString;
00418 
00422     static const XalanDOMString&            s_dotString;
00423 
00427     static const XalanDOMString&            s_oneString;
00428 
00432     static const XalanDOMString&            s_defaultSeparatorString;
00433 
00438     static const XalanDOMString&            s_alphaCountTable;
00439 
00440     static const XalanDOMString&            s_elalphaCountTable;
00441 
00447     static const DecimalToRomanVectorType&  s_romanConvertTable;
00448 
00452     static const NumberingResourceBundleMapType&    s_resourceBundles;
00453 
00454 
00459     class NumberFormatStringTokenizer
00460     {
00461     public:
00462 
00463         typedef XalanDOMString::size_type   size_type;
00464 
00470         NumberFormatStringTokenizer(const XalanDOMString&   theString);
00471 
00477         void
00478         setString(const XalanDOMString& theString);
00479 
00483         void
00484         reset()
00485         {
00486             m_currentPosition = 0;
00487         }
00488 
00495         XalanDOMString
00496         nextToken();
00497 
00503         void
00504         nextToken(XalanDOMString&   theToken);
00505 
00511         bool
00512         hasMoreTokens() const
00513         {
00514             return m_currentPosition >= m_maxPosition ? false : true;
00515         }
00516 
00522         size_type
00523         countTokens() const;
00524 
00525     private:
00526 
00527         size_type               m_currentPosition;
00528 
00529         size_type               m_maxPosition;
00530 
00531         const XalanDOMString*   m_string;
00532     };
00533 };
00534 
00535 
00536 
00537 #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.3
Copyright © 2000, 2001 The Apache Software Foundation. All Rights Reserved.