dbertoni    01/06/25 08:20:22

  Modified:    c/src/XSLT ElemAttributeSet.cpp ElemAttributeSet.hpp
                        ElemUse.cpp ElemUse.hpp Stylesheet.cpp
                        StylesheetExecutionContext.hpp
                        StylesheetExecutionContextDefault.cpp
                        StylesheetExecutionContextDefault.hpp
                        VariablesStack.hpp
  Log:
  Fix for attribset42, which tests XSLT 1.0 erratum 66 regarding 
xsl:attribute-set instance with the same name.  Also fixed bug regarding 
scoping of variables within xsl:attribute-set.
  
  Revision  Changes    Path
  1.11      +34 -1     xml-xalan/c/src/XSLT/ElemAttributeSet.cpp
  
  Index: ElemAttributeSet.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemAttributeSet.cpp,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ElemAttributeSet.cpp      2001/03/09 16:20:08     1.10
  +++ ElemAttributeSet.cpp      2001/06/25 15:19:59     1.11
  @@ -125,10 +125,43 @@
   
   
   void
  +ElemAttributeSet::adopt(ElemAttributeSet&    theSource)
  +{
  +     ElemTemplateElement* node = theSource.getFirstChildElem();
  +
  +     while(node != 0) 
  +     {
  +             assert(node->getXSLToken() == Constants::ELEMNAME_ATTRIBUTE);
  +
  +             theSource.removeChild(node);
  +
  +             XalanAutoPtr<ElemTemplateElement>       theGuard(node);
  +
  +             appendChild(node);
  +
  +             theGuard.release();
  +
  +             node = theSource.getFirstChildElem();
  +     }
  +
  +     copyQNames(theSource);
  +}
  +
  +
  +
  +void
   ElemAttributeSet::execute(StylesheetExecutionContext&                
executionContext) const
   {
  +     typedef StylesheetExecutionContext::SetAndRestoreCurrentStackFrameIndex 
        SetAndRestoreCurrentStackFrameIndex;
  +     typedef StylesheetExecutionContext::ElementRecursionStackPusher         
                ElementRecursionStackPusher;
  +
        // This will push and pop the stack automatically...
  -     StylesheetExecutionContext::ElementRecursionStackPusher         
thePusher(executionContext, this);
  +     ElementRecursionStackPusher             thePusher(executionContext, 
this);
  +
  +     // Make sure only global variables are visible during execution...
  +     SetAndRestoreCurrentStackFrameIndex             theSetAndRestore(
  +                                     executionContext, 
  +                                     
executionContext.getGlobalStackFrameIndex());
   
        ElemUse::execute(executionContext);
   
  
  
  
  1.11      +31 -1     xml-xalan/c/src/XSLT/ElemAttributeSet.hpp
  
  Index: ElemAttributeSet.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemAttributeSet.hpp,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ElemAttributeSet.hpp      2001/03/09 16:20:07     1.10
  +++ ElemAttributeSet.hpp      2001/06/25 15:20:01     1.11
  @@ -107,8 +107,18 @@
                return m_QName;
        }
   
  +     /**
  +      * Adopt the information of the supplied instance.
  +      * The children are removed from the supplied instance,
  +      * and any QNames for use-attribute-sets are copied.
  +      *
  +      * @param theSource The source ElemAttributeSet instance.
  +      */
  +     void
  +     adopt(ElemAttributeSet&         theSource);
  +
        // These methods are inherited from ElemUse ...
  -     
  +
        virtual const XalanDOMString&
        getElementName() const;
   
  @@ -124,6 +134,26 @@
   
        QNameByValue    m_QName;
   };
  +
  +
  +
  +inline bool
  +operator==(
  +                     const ElemAttributeSet&         theLHS,
  +                     const ElemAttributeSet&         theRHS)
  +{
  +     return theLHS.getQName() == theRHS.getQName();
  +}
  +
  +
  +
  +inline bool
  +operator<(
  +                     const ElemAttributeSet&         theLHS,
  +                     const ElemAttributeSet&         theRHS)
  +{
  +     return theLHS.getQName() < theRHS.getQName();
  +}
   
   
   
  
  
  
  1.12      +7 -2      xml-xalan/c/src/XSLT/ElemUse.cpp
  
  Index: ElemUse.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemUse.cpp,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ElemUse.cpp       2001/03/09 16:19:57     1.11
  +++ ElemUse.cpp       2001/06/25 15:20:02     1.12
  @@ -157,12 +157,17 @@
   
                m_attributeSetsNames.reserve(numTokens);
   
  +             XalanDOMString  qname;
  +
                while(tokenizer.hasMoreTokens())
                {
  -                     const XalanDOMString            qname = 
tokenizer.nextToken();
  +                     tokenizer.nextToken(qname);
                        assert(length(qname) != 0);
   
  -                     
m_attributeSetsNames.push_back(QNameVectorType::value_type(qname, 
getStylesheet().getNamespaces()));
  +                     m_attributeSetsNames.push_back(
  +                             QNameVectorType::value_type(
  +                                     qname,
  +                                     getStylesheet().getNamespaces()));
                }
        }
   
  
  
  
  1.12      +16 -0     xml-xalan/c/src/XSLT/ElemUse.hpp
  
  Index: ElemUse.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemUse.hpp,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ElemUse.hpp       2001/03/09 16:19:57     1.11
  +++ ElemUse.hpp       2001/06/25 15:20:03     1.12
  @@ -118,6 +118,20 @@
                        const AttributeList&                    atts,
                        int                                                     
        which);
   
  +     /**
  +      * Copy the QNames from the source
  +      *
  +      * @param theSource The source ElemUse instance.
  +      */
  +     void
  +     copyQNames(const ElemUse&       theSource)
  +     {
  +             m_attributeSetsNames.insert(
  +                     m_attributeSetsNames.end(),
  +                     theSource.m_attributeSetsNames.begin(),
  +                     theSource.m_attributeSetsNames.end());
  +     }
  +
        // These methods are inherited from ElemTemplateElement ...
        
        virtual const XalanDOMString&
  @@ -125,6 +139,8 @@
   
        virtual void
        execute(StylesheetExecutionContext&             executionContext) const;
  +
  +private:
   
   #if defined(XALAN_NO_NAMESPACES)
        typedef vector<QNameByValue>            QNameVectorType;
  
  
  
  1.56      +62 -5     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.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- Stylesheet.cpp    2001/06/06 21:55:29     1.55
  +++ Stylesheet.cpp    2001/06/25 15:20:05     1.56
  @@ -325,6 +325,30 @@
   
   
   
  +class attrSetCompare
  +{
  +public:
  +
  +     attrSetCompare(const ElemAttributeSet&  theAttrSet) :
  +             m_attrSet(theAttrSet)
  +     {
  +     }
  +
  +     bool
  +     operator()(const ElemAttributeSet*      theRHS) const
  +     {
  +             assert(theRHS != 0);
  +
  +             return m_attrSet == *theRHS;
  +     }
  +
  +private:
  +
  +     const ElemAttributeSet&         m_attrSet;
  +};
  +
  +
  +
   void
   Stylesheet::postConstruction(StylesheetConstructionContext&          
constructionContext)
   {
  @@ -390,11 +414,40 @@
        }
   
        {
  +#if !defined(XALAN_NO_NAMESPACES)
  +             using std::find_if;
  +#endif
                for (AttributeSetVectorType::size_type i = 0; i < 
m_attributeSets.size(); ++i)
                {
  -                     assert(m_attributeSets[i] != 0);
  +                     ElemAttributeSet* const         theCurrent = 
m_attributeSets[i];
   
  -                     
m_attributeSets[i]->postConstruction(constructionContext, m_namespacesHandler);
  +                     assert(theCurrent != 0);
  +
  +                     for(;;)
  +                     {
  +                             // Look for duplicate sets...
  +                             const AttributeSetVectorType::iterator  
theResult =
  +                                     find_if(
  +                                                     m_attributeSets.begin() 
+ (i + 1),
  +                                                     m_attributeSets.end(),
  +                                                     
attrSetCompare(*theCurrent));
  +
  +                             // Did we find it?
  +                             if(theResult == m_attributeSets.end())
  +                             {
  +                                     break;
  +                             }
  +                             else
  +                             {
  +                                     theCurrent->adopt(**theResult);
  +
  +                                     delete *theResult;
  +
  +                                     m_attributeSets.erase(theResult);
  +                             }
  +                     }
  +
  +                     theCurrent->postConstruction(constructionContext, 
m_namespacesHandler);
                }
        }
   
  @@ -1454,6 +1507,8 @@
                const QName&            /* qname */, 
                ElemAttributeSet*       attrSet)
   {
  +     assert(attrSet != 0);
  +
        m_attributeSets.push_back(attrSet);
   }            
   
  @@ -1484,8 +1539,10 @@
                {
                        const Stylesheet* const         stylesheet = 
m_imports[i];
   
  -                     stylesheet->applyAttrSets(attributeSetsNames, 
  -                                                                      
executionContext, sourceNode);
  +                     stylesheet->applyAttrSets(
  +                             attributeSetsNames, 
  +                             executionContext,
  +                             sourceNode);
                }
   
                for(QNameVectorType::size_type j = 0; j < nNames; j++)
  @@ -1505,7 +1562,7 @@
                        }
                }
        }
  -}    
  +}
   
   
   
  
  
  
  1.57      +8 -0      xml-xalan/c/src/XSLT/StylesheetExecutionContext.hpp
  
  Index: StylesheetExecutionContext.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContext.hpp,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- StylesheetExecutionContext.hpp    2001/06/14 19:28:23     1.56
  +++ StylesheetExecutionContext.hpp    2001/06/25 15:20:07     1.57
  @@ -727,6 +727,14 @@
        };
   
        /**
  +      * Get the top of the global stack frame.
  +      *
  +      * @return current value of index
  +      */
  +     virtual int
  +     getGlobalStackFrameIndex() const = 0;
  +
  +     /**
         * Get the top of the stack frame from where a search 
         * for a variable or param should take place.
         *
  
  
  
  1.67      +11 -3     
xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.cpp
  
  Index: StylesheetExecutionContextDefault.cpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.cpp,v
  retrieving revision 1.66
  retrieving revision 1.67
  diff -u -r1.66 -r1.67
  --- StylesheetExecutionContextDefault.cpp     2001/06/14 19:28:24     1.66
  +++ StylesheetExecutionContextDefault.cpp     2001/06/25 15:20:07     1.67
  @@ -767,6 +767,14 @@
   
   
   int
  +StylesheetExecutionContextDefault::getGlobalStackFrameIndex() const
  +{
  +     return m_variablesStack.getGlobalStackFrameIndex();
  +}
  +
  +
  +
  +int
   StylesheetExecutionContextDefault::getCurrentStackFrameIndex() const
   {
        return m_variablesStack.getCurrentStackFrameIndex();
  @@ -1661,9 +1669,9 @@
        }
        else
        {
  -             warn(
  -                     TranscodeFromLocalCodePage("Variable reference given 
for variable out of context or without definition!  Name = ") +
  -                     name.getLocalPart());
  +             error(
  +                     TranscodeFromLocalCodePage("Variable reference given 
for variable out of context or without definition!  Name = '") +
  +                     name.getLocalPart() + "'");
   
                return getXObjectFactory().createUnknown(name.getLocalPart());
        }
  
  
  
  1.61      +3 -0      
xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.hpp
  
  Index: StylesheetExecutionContextDefault.hpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.hpp,v
  retrieving revision 1.60
  retrieving revision 1.61
  diff -u -r1.60 -r1.61
  --- StylesheetExecutionContextDefault.hpp     2001/06/14 19:28:25     1.60
  +++ StylesheetExecutionContextDefault.hpp     2001/06/25 15:20:08     1.61
  @@ -428,6 +428,9 @@
        popElementFrame(const ElemTemplateElement*      elem);
   
        virtual int
  +     getGlobalStackFrameIndex() const;
  +
  +     virtual int
        getCurrentStackFrameIndex() const;
   
        virtual void
  
  
  
  1.12      +11 -0     xml-xalan/c/src/XSLT/VariablesStack.hpp
  
  Index: VariablesStack.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/VariablesStack.hpp,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- VariablesStack.hpp        2001/05/10 18:05:33     1.11
  +++ VariablesStack.hpp        2001/06/25 15:20:09     1.12
  @@ -307,6 +307,17 @@
                return m_currentStackFrameIndex;
        }
   
  +     /**
  +      * Get the top of the global stack frame.
  +      *
  +      * @return current value of index
  +      */
  +     int
  +     getGlobalStackFrameIndex() const
  +     {
  +             return m_globalStackFrameIndex;
  +     }
  +
        class InvalidStackContextException : public XSLTProcessorException
        {
        public:
  
  
  

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

Reply via email to