dbertoni    2003/03/04 21:03:25

  Modified:    c/src/XSLT Stylesheet.cpp Stylesheet.hpp
  Log:
  Cleaned up inconsistent naming for vector.  Added assert to catch instances 
of namespace declaration attributes when locating a template.
  
  Revision  Changes    Path
  1.91      +39 -25    xml-xalan/c/src/XSLT/Stylesheet.cpp
  
  Index: Stylesheet.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/Stylesheet.cpp,v
  retrieving revision 1.90
  retrieving revision 1.91
  diff -u -r1.90 -r1.91
  --- Stylesheet.cpp    12 Feb 2003 23:08:56 -0000      1.90
  +++ Stylesheet.cpp    5 Mar 2003 05:03:25 -0000       1.91
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -411,8 +411,8 @@
   
   static void
   addToList(
  -                     Stylesheet::PatternTableListType&       theList,
  -                     const Stylesheet::MatchPattern2*        thePattern)
  +                     Stylesheet::PatternTableVectorType&             theList,
  +                     const Stylesheet::MatchPattern2*                
thePattern)
   {
        typedef Stylesheet::size_type   size_type;
        assert(thePattern != 0);
  @@ -420,7 +420,7 @@
        const double            thePatternPriority = 
thePattern->getPriorityOrDefault();
        const size_type         thePatternPosition = 
thePattern->getPositionInStylesheet();
   
  -     typedef Stylesheet::PatternTableListType        PatternTableListType;
  +     typedef Stylesheet::PatternTableVectorType      PatternTableListType;
        typedef PatternTableListType::iterator          iterator;
   
        iterator                theCurrent = theList.begin();
  @@ -451,11 +451,11 @@
   
   static void
   addToTable(
  -                Stylesheet::PatternTableMapType&                     
theTable,
  -                const Stylesheet::PatternTableListType&      theList)
  +                Stylesheet::PatternTableMapType&                             
theTable,
  +                const Stylesheet::PatternTableVectorType&    theList)
   {
        typedef Stylesheet::PatternTableMapType         PatternTableMapType;
  -     typedef Stylesheet::PatternTableListType        PatternTableListType;
  +     typedef Stylesheet::PatternTableVectorType      PatternTableListType;
   
        PatternTableMapType::iterator                           theCurrentTable 
= theTable.begin();
        const PatternTableMapType::iterator                     theTableEnd = 
theTable.end();
  @@ -898,7 +898,7 @@
   
   
   
  -inline const Stylesheet::PatternTableListType* 
  +inline const Stylesheet::PatternTableVectorType* 
   Stylesheet::locateElementMatchPatternList2(const XalanDOMString&     
theName) const
   {
        assert(m_elementPatternTableEnd == m_elementPatternTable.end());
  @@ -918,7 +918,7 @@
   
   
   
  -inline const Stylesheet::PatternTableListType* 
  +inline const Stylesheet::PatternTableVectorType* 
   Stylesheet::locateAttributeMatchPatternList2(const XalanDOMString&   
theName) const
   {
        assert(m_attributePatternTableEnd == m_attributePatternTable.end());
  @@ -938,10 +938,14 @@
   
   
   
  -inline const Stylesheet::PatternTableListType*
  -Stylesheet::locateMatchPatternList2(const XalanNode& theNode) const
  +inline const Stylesheet::PatternTableVectorType*
  +Stylesheet::locateMatchPatternList2(
  +                     const XalanNode&                theNode,
  +                     XalanNode::NodeType             targetNodeType) const
   {
  -     switch(theNode.getNodeType())
  +     assert(theNode.getNodeType() == targetNodeType);
  +
  +     switch(targetNodeType)
        {
        case XalanNode::ELEMENT_NODE:
                return 
locateElementMatchPatternList2(DOMServices::getLocalNameOfNode(theNode));
  @@ -952,6 +956,11 @@
                break;
   
        case XalanNode::ATTRIBUTE_NODE:
  +#if defined(XALAN_OLD_STYLE_CASTS)
  +             assert(DOMServices::isNamespaceDeclaration((const 
XalanAttr&)theNode) == false);
  +#else
  +             assert(DOMServices::isNamespaceDeclaration(static_cast<const 
XalanAttr&>(theNode)) == false);
  +#endif
                return 
locateAttributeMatchPatternList2(DOMServices::getLocalNameOfNode(theNode));
                break;
   
  @@ -980,9 +989,11 @@
   inline const ElemTemplate*
   Stylesheet::findTemplateInImports(
                        StylesheetExecutionContext&     executionContext,
  -                     XalanNode*                                              
targetNode, 
  +                     XalanNode*                                              
targetNode,
  +                     XalanNode::NodeType                             
targetNodeType,
                        const XalanQName&                               mode) 
const
   {
  +     assert(targetNode->getNodeType() == targetNodeType);
        assert(m_importsSize == m_imports.size());
   
        for(StylesheetVectorType::size_type i = 0; i < m_importsSize; i++)
  @@ -994,6 +1005,7 @@
                        stylesheet->findTemplate(
                                executionContext,
                                targetNode,
  +                             targetNodeType,
                                mode, 
                                false);
   
  @@ -1011,11 +1023,13 @@
   const ElemTemplate*
   Stylesheet::findTemplate(
                        StylesheetExecutionContext&     executionContext,
  -                     XalanNode*                                              
targetNode, 
  +                     XalanNode*                                              
targetNode,
  +                     XalanNode::NodeType                             
targetNodeType,
                        const XalanQName&                               mode,
                        bool                                                    
onlyUseImports) const
   {
        assert(targetNode != 0);
  +     assert(targetNode->getNodeType() == targetNodeType);
        assert(m_patternCount == m_matchPattern2Container.size());
   
        if(m_isWrapperless == true)
  @@ -1024,7 +1038,7 @@
        }
        else if (onlyUseImports == true)
        {
  -             return findTemplateInImports(executionContext, targetNode, 
mode);
  +             return findTemplateInImports(executionContext, targetNode, 
targetNodeType, mode);
        }
        else
        {
  @@ -1034,14 +1048,14 @@
                {
                        // Points to the current list of match patterns.  Note
                        // that this may point to more than one table.
  -                     const PatternTableListType*     matchPatternList =
  -                                     locateMatchPatternList2(*targetNode);
  +                     const PatternTableVectorType*   matchPatternList =
  +                                     locateMatchPatternList2(*targetNode, 
targetNodeType);
                        assert(matchPatternList != 0);
   
  -                     PatternTableListType::const_iterator            
theCurrentEntry =
  +                     PatternTableVectorType::const_iterator          
theCurrentEntry =
                                        matchPatternList->begin();
   
  -                     const PatternTableListType::const_iterator      
theTableEnd =
  +                     const PatternTableVectorType::const_iterator    
theTableEnd =
                                        matchPatternList->end();
   
                        while(theCurrentEntry != theTableEnd)
  @@ -1084,19 +1098,19 @@
   
                        if(0 == bestMatchedRule)
                        {
  -                             bestMatchedRule = 
findTemplateInImports(executionContext, targetNode, mode);
  +                             bestMatchedRule = 
findTemplateInImports(executionContext, targetNode, targetNodeType, mode);
                        }
                }
                else
                {
  -                     const PatternTableListType*     matchPatternList =
  -                                     locateMatchPatternList2(*targetNode);
  +                     const PatternTableVectorType*   matchPatternList =
  +                                     locateMatchPatternList2(*targetNode, 
targetNodeType);
                        assert(matchPatternList != 0);
   
  -                     PatternTableListType::const_iterator            
theCurrentEntry =
  +                     PatternTableVectorType::const_iterator          
theCurrentEntry =
                                        matchPatternList->begin();
   
  -                     const PatternTableListType::const_iterator      
theTableEnd =
  +                     const PatternTableVectorType::const_iterator    
theTableEnd =
                                        matchPatternList->end();
   
                        if (theCurrentEntry != theTableEnd)
  @@ -1257,7 +1271,7 @@
   
                        if(0 == bestMatchedRule)
                        {
  -                             bestMatchedRule = 
findTemplateInImports(executionContext, targetNode, mode);
  +                             bestMatchedRule = 
findTemplateInImports(executionContext, targetNode, targetNodeType, mode);
                        }
                }
   
  
  
  
  1.58      +34 -25    xml-xalan/c/src/XSLT/Stylesheet.hpp
  
  Index: Stylesheet.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/Stylesheet.hpp,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- Stylesheet.hpp    12 Feb 2003 23:08:57 -0000      1.57
  +++ Stylesheet.hpp    5 Mar 2003 05:03:25 -0000       1.58
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -609,7 +609,14 @@
                        StylesheetExecutionContext&     executionContext,
                        XalanNode*                                              
targetNode) const
        {
  -             return findTemplate(executionContext, targetNode, s_emptyQName, 
false);
  +             assert(targetNode != 0);
  +
  +             return findTemplate(
  +                             executionContext,
  +                             targetNode,
  +                             targetNode->getNodeType(),
  +                             s_emptyQName,
  +                             false);
        }
   
        /**
  @@ -617,15 +624,17 @@
         * XSL document, according to the rules specified in the xsl draft. 
         *
         * @param executionContext current execution context
  -      * @param targetElem        element that needs a rule
  -      * @param mode              string indicating the display mode
  +      * @param targetNode        node that needs a rule
  +      * @param targetNodeType    the type of targetNode
  +      * @param mode              string indicating the mode
         * @param onlyUseImports    only use imports, do not use any templates 
from the stylesheet itself
         * @return pointer to rule that best matches targetElem
         */
        const ElemTemplate*
        findTemplate(
                        StylesheetExecutionContext&     executionContext,
  -                     XalanNode*                                              
targetNode, 
  +                     XalanNode*                                              
targetNode,
  +                     XalanNode::NodeType                             
targetNodeType,
                        const XalanQName&                               mode,
                        bool                                                    
onlyUseImports) const;
   
  @@ -754,22 +763,18 @@
        };
   
   #if defined(XALAN_NO_STD_NAMESPACE)
  -     typedef vector<const MatchPattern2*>            PatternTableListType;
  -
        typedef vector<const MatchPattern2*>            PatternTableVectorType;
   
        typedef map<XalanDOMString,
  -                         PatternTableListType,
  +                         PatternTableVectorType,
                                less<XalanDOMString> >                  
PatternTableMapType;
   
        typedef deque<MatchPattern2>                            
MatchPattern2Container;
   #else
  -     typedef std::vector<const MatchPattern2*>       PatternTableListType;
  -
        typedef std::vector<const MatchPattern2*>       PatternTableVectorType;
   
        typedef std::map<XalanDOMString,
  -                                      PatternTableListType>          
PatternTableMapType;
  +                                      PatternTableVectorType>        
PatternTableMapType;
   
        typedef std::deque<MatchPattern2>                       
MatchPattern2Container;
   #endif
  @@ -807,7 +812,7 @@
         *
         * @param theName The name to match
         */
  -     const PatternTableListType*
  +     const PatternTableVectorType*
        locateElementMatchPatternList2(const XalanDOMString&    theName) const;
   
        /**
  @@ -817,7 +822,7 @@
         *
         * @param theName The name to match
         */
  -     const PatternTableListType*
  +     const PatternTableVectorType*
        locateAttributeMatchPatternList2(const XalanDOMString&  theName) const;
   
        /**
  @@ -826,8 +831,10 @@
         *
         * @param XalanNode The node to match
         */
  -     const PatternTableListType*
  -     locateMatchPatternList2(const XalanNode&        theNode) const;
  +     const PatternTableVectorType*
  +     locateMatchPatternList2(
  +                     const XalanNode&                theNode,
  +                     XalanNode::NodeType             targetNodeType) const;
   
        /**
         * Add an extension namespace handler. This provides methods for calling
  @@ -1089,14 +1096,16 @@
         * stylesheet, using only imports
         *
         * @param executionContext current execution context
  -      * @param targetElem        element that needs a rule
  -      * @param mode              string indicating the display mode
  +      * @param targetNode        node that needs a rule
  +      * @param targetNodeType    the type of targetNode
  +      * @param mode              string indicating the mode
         * @return pointer to rule that best matches targetElem
         */
        const ElemTemplate*
        findTemplateInImports(
                        StylesheetExecutionContext&     executionContext,
  -                     XalanNode*                                              
targetNode, 
  +                     XalanNode*                                              
targetNode,
  +                     XalanNode::NodeType                             
targetNodeType,
                        const XalanQName&                               mode) 
const;
   
        /**
  @@ -1173,7 +1182,7 @@
   
        const PatternTableMapType::const_iterator       
m_elementPatternTableEnd;
   
  -     PatternTableListType                                            
m_elementAnyPatternList;
  +     PatternTableVectorType                                          
m_elementAnyPatternList;
   
        /**
         * This table is keyed on the target attributes of patterns, and 
contains linked
  @@ -1184,23 +1193,23 @@
   
        const PatternTableMapType::const_iterator       
m_attributePatternTableEnd;
   
  -     PatternTableListType                                            
m_attributeAnyPatternList;
  +     PatternTableVectorType                                          
m_attributeAnyPatternList;
   
        /**
         * These tables are for text, comment, root, and PI node templates.
         */
  -     PatternTableListType                                    
m_textPatternList;
  +     PatternTableVectorType                                  
m_textPatternList;
   
  -     PatternTableListType                                    
m_commentPatternList;
  +     PatternTableVectorType                                  
m_commentPatternList;
   
  -     PatternTableListType                                    
m_rootPatternList;
  +     PatternTableVectorType                                  
m_rootPatternList;
   
  -     PatternTableListType                                    m_piPatternList;
  +     PatternTableVectorType                                  m_piPatternList;
   
        /**
         * This table is for patterns that match "node()".
         */
  -     PatternTableListType                                    
m_nodePatternList;
  +     PatternTableVectorType                                  
m_nodePatternList;
   
        /**
         * This will hold all of the MatchPattern2 instances for the
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to