Xalan-C++ API Documentation

The Xalan-C++ XSL Transformer Version 1.0

Main Page   Namespace List   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 
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 vector<Counter>                         CounterVectorType;
00107     typedef map<const ElemNumber*,
00108                 CounterVectorType,
00109                 less<const ElemNumber*> >           ElemToCounterVectorMapType;
00110     typedef map<XalanDOMChar,
00111                 XalanNumberingResourceBundle,
00112                 less<XalanDOMChar> >                NumberingResourceBundleMapType;
00113 #else
00114     typedef std::vector<DecimalToRoman>             DecimalToRomanVectorType;
00115     typedef std::vector<int>                        IntArrayType;
00116     typedef std::vector<Counter>                    CounterVectorType;
00117     typedef std::map<const ElemNumber*,
00118                      CounterVectorType>             ElemToCounterVectorMapType;
00119     typedef std::map<XalanDOMChar,
00120                      XalanNumberingResourceBundle>  NumberingResourceBundleMapType;
00121 #endif
00122 
00126     static void
00127     initialize();
00128 
00132     static void
00133     terminate();
00134 
00145     ElemNumber(
00146             StylesheetConstructionContext&  constructionContext,
00147             Stylesheet&                     stylesheetTree,
00148             const XalanDOMString&           name,
00149             const AttributeList&            atts,
00150             int                             lineNumber,
00151             int                             columnNumber);
00152 
00153     virtual
00154     ~ElemNumber();
00155 
00156     // These methods are inherited from ElemTemplateElement ...
00157     
00158     virtual void
00159     execute(
00160             StylesheetExecutionContext&     executionContext,
00161             XalanNode*                      sourceTree,
00162             XalanNode*                      sourceNode,
00163             const QName&                    mode) const;
00164 
00165 protected:
00166 
00176     XalanNode*
00177     findAncestor(
00178             StylesheetExecutionContext&     executionContext,
00179             const XPath*                    fromMatchPattern,
00180             const XPath*                    countMatchPattern,
00181             XalanNode*                      context,
00182             const XalanElement*             namespaceContext) const;
00183 
00193     XalanNode*
00194     findPrecedingOrAncestorOrSelf(
00195             StylesheetExecutionContext&     executionContext,
00196             const XPath*                    fromMatchPattern,
00197             const XPath*                    countMatchPattern,
00198             XalanNode*                      context,
00199             const XalanElement*             namespaceContext) const;
00200 
00204     const XPath*
00205     getCountMatchPattern(
00206             StylesheetExecutionContext&     executionContext,
00207             XalanNode*                      contextNode) const;
00208 
00213     XalanDOMString
00214     getCountString(
00215             StylesheetExecutionContext&     executionContext,
00216             XalanNode*                      sourceTree, 
00217             XalanNode*                      sourceNode) const;
00218 
00222     XalanNode* getPreviousNode(
00223             StylesheetExecutionContext&     executionContext,
00224             XalanNode*                      pos) const;
00225 
00229     XalanNode* getTargetNode(
00230             StylesheetExecutionContext&     executionContext,
00231             XalanNode*                      sourceNode) const;
00232 
00241     MutableNodeRefList getMatchingAncestors(
00242             StylesheetExecutionContext&     executionContext,
00243             XalanNode*                      node, 
00244             bool                            stopAtFirstFound) const;
00245 
00252     XalanNumberFormat*
00253     getNumberFormatter(
00254             StylesheetExecutionContext&     executionContext,
00255             XalanNode*                      contextNode) const;
00256 
00267     XalanDOMString
00268     formatNumberList(   
00269             StylesheetExecutionContext&     executionContext,
00270             const IntArrayType&             theList,
00271             XalanNode*                      contextNode) const;
00272 
00284     XalanDOMString int2singlealphaCount(int val, 
00285             const XalanDOMString&   table);
00286         
00298     static XalanDOMString
00299     int2alphaCount(
00300             int                     val,
00301             const XalanDOMString&   table);
00302 
00314     static XalanDOMString
00315     tradAlphaCount(int val);
00316 
00326     static XalanDOMString
00327     long2roman(
00328             long    val,
00329             bool    prefixesAreOK);
00330 
00331 
00332 private:
00333 
00334     bool
00335     evaluateLetterValueAVT(
00336             StylesheetExecutionContext&     executionContext,
00337             XalanNode*                      contextNode,
00338             const XalanDOMString&           compareValue) const;
00339 
00340     XalanDOMString
00341     traditionalAlphaCount(
00342             int                                     theValue,
00343             const XalanNumberingResourceBundle&     theResourceBundle) const;
00344 
00345     /*
00346      * Get Formatted number
00347      */
00348     XalanDOMString 
00349     getFormattedNumber(
00350             StylesheetExecutionContext&     executionContext,
00351             XalanNode*                      contextNode,
00352             XalanDOMChar                    numberType,
00353             int                             numberWidth,
00354             int                             listElement) const;
00355 
00356     const XPath*    m_countMatchPattern;
00357     const XPath*    m_fromMatchPattern;
00358     const XPath*    m_valueExpr;
00359 
00360     int             m_level; // = Constants.NUMBERLEVEL_SINGLE;
00361 
00362     const AVT*      m_format_avt;
00363     const AVT*      m_lang_avt;
00364     const AVT*      m_lettervalue_avt;
00365     const AVT*      m_groupingSeparator_avt;
00366     const AVT*      m_groupingSize_avt;
00367 
00372     static const XalanDOMString&            s_alphaCountTable;
00373 
00374     static const XalanDOMString&            s_elalphaCountTable;
00375 
00381     static const DecimalToRomanVectorType&  s_romanConvertTable;
00382 
00386     static const NumberingResourceBundleMapType&    s_resourceBundles;
00387 
00388 
00393     class NumberFormatStringTokenizer
00394     {
00395         public:
00396 
00402             explicit
00403                 NumberFormatStringTokenizer(const XalanDOMString&   theStr = XalanDOMString());
00404 
00410             void
00411                 setString(const XalanDOMString& theString);
00412 
00416             void
00417                 reset()
00418                 {
00419                     m_currentPosition = 0;
00420                 }
00421 
00428             XalanDOMString
00429                 nextToken();
00430 
00436             bool
00437                 hasMoreTokens() const
00438                 {
00439                     return (m_currentPosition >= m_maxPosition) ? false : true;
00440                 }
00441 
00447             int
00448                 countTokens() const;
00449 
00450         private:
00451 
00452             int             m_currentPosition;
00453             int             m_maxPosition;
00454             XalanDOMString  m_str;
00455     }; // end NumberFormatStringTokenizer
00456 
00464     class CountersTable
00465     {
00466         public:
00467 
00471             CountersTable() : 
00472                 m_countersMade(0)
00473                 {
00474                 };
00475 
00476 
00483             int
00484             CountersTable::countNode(
00485                     StylesheetExecutionContext&     support,
00486                     const ElemNumber*               numberElem,
00487                     XalanNode*                      node);
00488 
00489         private:
00490 
00495             CounterVectorType& getCounters(const ElemNumber*    numberElem);
00496 
00502             void appendBtoFList(MutableNodeRefList& flist, MutableNodeRefList& blist);
00503 
00507             MutableNodeRefList m_newFound;
00508 
00509             // For diagnostics
00510             int m_countersMade;
00511 
00512             ElemToCounterVectorMapType  m_counterMap;
00513 
00514     }; // end CountersTable
00515 
00516     friend class CountersTable;
00517 
00525     struct Counter
00526     {
00533         int                         m_countNodesStartCount;
00534 
00538         MutableNodeRefList          m_countNodes;
00539 
00545         const XalanNode*            m_fromNode;
00546 
00550         const ElemNumber*           m_numberElem;
00551 
00555         Counter(
00556                 const ElemNumber*       numberElem,
00557                 MutableNodeRefList&     countNodes) :
00558             m_countNodesStartCount(0),
00559             m_countNodes(countNodes),
00560             m_fromNode(0),
00561             m_numberElem(numberElem)
00562         {
00563         }
00564 
00568         Counter(const ElemNumber*   numberElem = 0) :
00569             m_countNodesStartCount(0),
00570             m_countNodes(),
00571             m_fromNode(0),
00572             m_numberElem(numberElem)
00573         {
00574         }
00575 
00582         int
00583         getPreviouslyCounted(
00584                 StylesheetExecutionContext&     support,
00585                 const XalanNode*                node) const;
00586 
00590         XalanNode*
00591         getLast();
00592     }; // end Counter
00593 
00594     friend struct Counter;
00595 
00596 }; // end ElemNumber
00597 
00598 #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++ XSL Transformer Version 1.0
Copyright © 2000 The Apache Software Foundation. All Rights Reserved.