dbertoni    00/05/29 15:49:01

  Modified:    c/src/XSLT ElemForEach.cpp FunctionDocument.cpp
                        StylesheetExecutionContext.hpp
                        StylesheetExecutionContextDefault.cpp
                        StylesheetExecutionContextDefault.hpp
  Log:
  Created objects to help maintain execution state.  Implemented new element 
stack frame marker.
  
  Revision  Changes    Path
  1.5       +11 -5     xml-xalan/c/src/XSLT/ElemForEach.cpp
  
  Index: ElemForEach.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemForEach.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ElemForEach.cpp   2000/04/12 19:40:58     1.4
  +++ ElemForEach.cpp   2000/05/29 22:49:00     1.5
  @@ -145,11 +145,17 @@
        {
                assert(m_pSelectPattern != 0);
   
  -             transformSelectedChildren(executionContext, getStylesheet(), 
  -                     *this,this,sourceTree,sourceNode,mode,
  -                     m_pSelectPattern, Constants::ELEMNAME_FOREACH,
  -                     executionContext.getCurrentStackFrameIndex()
  -                     );
  +             transformSelectedChildren(
  +                     executionContext,
  +                     getStylesheet(),
  +                     *this,
  +                     this,
  +                     sourceTree,
  +                     sourceNode,
  +                     mode,
  +                     m_pSelectPattern,
  +                     Constants::ELEMNAME_FOREACH,
  +                     executionContext.getCurrentStackFrameIndex());
        }
       else
       {
  
  
  
  1.8       +19 -4     xml-xalan/c/src/XSLT/FunctionDocument.cpp
  
  Index: FunctionDocument.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/FunctionDocument.cpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- FunctionDocument.cpp      2000/05/11 21:32:01     1.7
  +++ FunctionDocument.cpp      2000/05/29 22:49:00     1.8
  @@ -119,9 +119,15 @@
                {
                        XalanDOMString  theMessage("Cannot load requested doc: 
");
   
  -                     theMessage += base;
                        theMessage += localURI;
   
  +                     if (length(base) > 0)
  +                     {
  +                             theMessage += " (Base URI: ";
  +                             theMessage += base;
  +                             theMessage += ")";
  +                     }
  +
                        executionContext.warn(theMessage);
                }
       }
  @@ -203,12 +209,19 @@
                        assert(XObject::eTypeNodeSet != arg->getType() ||
                                                                
arg->nodeset().item(i) != 0);
   
  -                     const XalanDOMString            ref = 
XObject::eTypeNodeSet == arg->getType() ?
  +                     XalanDOMString  ref = XObject::eTypeNodeSet == 
arg->getType() ?
                                                                                
                        executionContext.getNodeData(*arg->nodeset().item(i)) :
                                                                                
                        arg->str();
   
  -                     if(! isEmpty(ref))
  +                     // This is the case where the function was called with
  +                     // an empty string, which refers to the stylesheet 
itself.
  +                     if (nRefs == 1 && isEmpty(ref) == true && args.size() 
== 1)
                        {
  +                             ref = base;
  +                     }
  +
  +                     if(!isEmpty(ref))
  +                     {
                                if(docContext == 0)
                                {
                                        executionContext.error("The context 
node does not have an owner document!");
  @@ -237,7 +250,7 @@
                                if(indexOfColon < theLength && indexOfSlash < 
theLength && indexOfColon < indexOfSlash)
                                {
                                        // The url (or filename, for that 
matter) is absolute.
  -                                     base = XalanDOMString();
  +                                     clear(base);
                                }
   
                                XalanDocument* const    newDoc = 
getDoc(executionContext, ref, base);
  @@ -248,6 +261,8 @@
                                }
                        }
                }
  +
  +             assert(mnl.checkForDuplicates() == false);
   
                return executionContext.getXObjectFactory().createNodeSet(mnl);
        }
  
  
  
  1.17      +79 -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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- StylesheetExecutionContext.hpp    2000/05/25 16:51:34     1.16
  +++ StylesheetExecutionContext.hpp    2000/05/29 22:49:00     1.17
  @@ -721,6 +721,51 @@
        getParamVariable(const QName&   theName) const = 0;
   
        /**
  +      * Push a frame marker for an element.
  +      *
  +      * @param elem the element
  +      */
  +     virtual void
  +     pushElementFrame(const ElemTemplateElement*             elem) = 0;
  +
  +     /**
  +      * Pop a frame marker for an element.
  +      *
  +      * @param elem the element
  +      */
  +     virtual void
  +     popElementFrame(const ElemTemplateElement*      elem) = 0;
  +
  +     /*
  +      * A class to manage pushing and popping an element's stack
  +      * frame context.
  +      */
  +     class PushAndPopElementFrame
  +     {
  +     public:
  +
  +             PushAndPopElementFrame(
  +                     StylesheetExecutionContext&             
executionContext,
  +                     const ElemTemplateElement*              element) :
  +                     m_executionContext(executionContext),
  +                     m_element(element)
  +             {
  +                     executionContext.pushElementFrame(element);
  +             }
  +
  +             ~PushAndPopElementFrame()
  +             {
  +                     m_executionContext.popElementFrame(m_element);
  +             }
  +
  +     private:
  +
  +             StylesheetExecutionContext&             m_executionContext;
  +
  +             const ElemTemplateElement*              m_element;
  +     };
  +
  +     /**
         * Get the top of the stack frame from where a search 
         * for a variable or param should take place.
         *
  @@ -737,6 +782,40 @@
         */
        virtual void
        setCurrentStackFrameIndex(int   currentStackFrameIndex = -1) = 0;
  +
  +     /*
  +      * A class to manage the state of the variable stacks frame index.
  +      */
  +     class SetAndRestoreCurrentStackFrameIndex
  +     {
  +     public:
  +
  +             SetAndRestoreCurrentStackFrameIndex(
  +                     StylesheetExecutionContext&             
executionContext,
  +                     int                                                     
        newIndex) :
  +                     m_executionContext(executionContext),
  +                     
m_savedIndex(executionContext.getCurrentStackFrameIndex())
  +             {
  +                     executionContext.setCurrentStackFrameIndex(newIndex);
  +             }
  +
  +             ~SetAndRestoreCurrentStackFrameIndex()
  +             {
  +                     
m_executionContext.setCurrentStackFrameIndex(m_savedIndex);
  +             }
  +
  +             int
  +             getStackFrameIndex() const
  +             {
  +                     return m_savedIndex;
  +             }
  +
  +     private:
  +
  +             StylesheetExecutionContext&             m_executionContext;
  +
  +             const int                                               
m_savedIndex;
  +     };
   
        /*
         * A class to manage stack state during execution.
  
  
  
  1.15      +16 -0     
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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- StylesheetExecutionContextDefault.cpp     2000/05/26 19:23:51     1.14
  +++ StylesheetExecutionContextDefault.cpp     2000/05/29 22:49:00     1.15
  @@ -547,6 +547,22 @@
   
   
   
  +void
  +StylesheetExecutionContextDefault::pushElementFrame(const 
ElemTemplateElement*       elem)
  +{
  +     m_xsltProcessor.getVariableStacks().pushElementFrame(elem);
  +}
  +
  +
  +
  +void
  +StylesheetExecutionContextDefault::popElementFrame(const 
ElemTemplateElement*        elem)
  +{
  +     m_xsltProcessor.getVariableStacks().popElementFrame(elem);
  +}
  +
  +
  +
   int
   StylesheetExecutionContextDefault::getCurrentStackFrameIndex() const
   {
  
  
  
  1.15      +6 -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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- StylesheetExecutionContextDefault.hpp     2000/05/25 16:51:36     1.14
  +++ StylesheetExecutionContextDefault.hpp     2000/05/29 22:49:00     1.15
  @@ -257,6 +257,12 @@
        virtual XObject*
        getParamVariable(const QName&   theName) const;
   
  +     virtual void
  +     pushElementFrame(const ElemTemplateElement*             elem);
  +
  +     virtual void
  +     popElementFrame(const ElemTemplateElement*      elem);
  +
        virtual int
        getCurrentStackFrameIndex() const;
   
  
  
  

Reply via email to