dbertoni    01/03/11 08:47:52

  Modified:    c/src/XSLT StylesheetExecutionContextDefault.cpp
                        StylesheetExecutionContextDefault.hpp
  Log:
  Fixed bug with recursive execution of pushParams().
  
  Revision  Changes    Path
  1.59      +80 -53    
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.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- StylesheetExecutionContextDefault.cpp     2001/03/06 21:23:00     1.58
  +++ StylesheetExecutionContextDefault.cpp     2001/03/11 16:47:51     1.59
  @@ -624,72 +624,38 @@
                        XalanNode*                                      
sourceNode,
                        const ElemTemplateElement*      targetTemplate)
   {
  -     const ElemTemplateElement*      child =
  -                     xslCallTemplateElement.getFirstChildElem();
  -
  -     // This will ensure that the contents of m_paramsVector are
  -     // cleared.
  -     CollectionClearGuard<ParamsVectorType>  theGuard(m_paramsVector);
  -
  -     if (0 != child)
  +     // We have a params vector that we reuse, but occasionally, a
  +     // param will result in recursive execution, so we'll use a
  +     // temporary when we detect such a situation.
  +     if(m_paramsVector.size() == 0)
        {
  -             assert(m_paramsVector.size() == 0);
  +             // This will ensure that the contents of m_paramsVector are
  +             // cleared.
  +             CollectionClearGuard<ParamsVectorType>  
theGuard(m_paramsVector);
   
  -             // This object will take care of popping, then
  -             // pushing the context marker at the top of the
  -             // stack, even if an exception is thrown.
  -             PopPushContextMarker    thePopPush(*this);
  -
                // Make sure we have the default capacity for the params
                // vector...
                if (m_paramsVector.capacity() == 0)
                {
                         m_paramsVector.reserve(eDefaultParamsVectorSize);
                }
  -
  -             while(0 != child)
  -             {
  -                     if(Constants::ELEMNAME_WITHPARAM == 
child->getXSLToken())
  -                     {
  -                             const ElemWithParam* const      xslParamElement 
=
  -#if defined(XALAN_OLD_STYLE_CASTS)
  -                                             (ElemWithParam*)child;
  -#else
  -                                             static_cast<const 
ElemWithParam*>(child);
  -#endif
  -
  -                             const XPath* const      pxpath = 
xslParamElement->getSelectPattern();
   
  -                             XObjectPtr      theXObject;
  +             getParams(xslCallTemplateElement, sourceNode, m_paramsVector);
   
  -                             if(0 != pxpath)
  -                             {
  -                                     theXObject =
  -                                             createVariable(
  -                                                     &xslCallTemplateElement,
  -                                                     *pxpath,
  -                                                     sourceNode,
  -                                                     *xslParamElement);
  -                             }
  -                             else
  -                             {
  -                                     theXObject =
  -                                             createVariable(
  -                                                     &xslCallTemplateElement,
  -                                                     *xslParamElement,
  -                                                     sourceNode);
  -                             }
  +             m_variablesStack.pushParams(
  +                                     m_paramsVector,
  +                                     targetTemplate);
  +     }
  +     else
  +     {
  +             ParamsVectorType        tempParams;
   
  -                             
m_paramsVector.push_back(ParamsVectorType::value_type(&xslParamElement->getQName(),
 theXObject));
  -                     }
  +             getParams(xslCallTemplateElement, sourceNode, tempParams);
   
  -                     child = child->getNextSiblingElem();
  -             }
  +             m_variablesStack.pushParams(
  +                                     tempParams,
  +                                     targetTemplate);
        }
  -
  -     m_variablesStack.pushParams(
  -                             m_paramsVector,
  -                             targetTemplate);
   }
   
   
  @@ -1798,6 +1764,67 @@
                        const XalanNode*        styleNode) const
   {
        message(TranscodeFromLocalCodePage(msg), sourceNode, styleNode);
  +}
  +
  +
  +
  +void
  +StylesheetExecutionContextDefault::getParams(
  +                     const ElemTemplateElement&      xslCallTemplateElement,
  +                     XalanNode*                                      
sourceNode,
  +                     ParamsVectorType&                       params)
  +{
  +     assert(params.size() == 0);
  +
  +     const ElemTemplateElement*      child =
  +                     xslCallTemplateElement.getFirstChildElem();
  +
  +     if (0 != child)
  +     {
  +             // This object will take care of popping, then
  +             // pushing the context marker at the top of the
  +             // stack, even if an exception is thrown.
  +             PopPushContextMarker    thePopPush(*this);
  +
  +             while(0 != child)
  +             {
  +                     if(Constants::ELEMNAME_WITHPARAM == 
child->getXSLToken())
  +                     {
  +                             const ElemWithParam* const      xslParamElement 
=
  +#if defined(XALAN_OLD_STYLE_CASTS)
  +                                             (ElemWithParam*)child;
  +#else
  +                                             static_cast<const 
ElemWithParam*>(child);
  +#endif
  +
  +                             const XPath* const      pxpath = 
xslParamElement->getSelectPattern();
  +
  +                             XObjectPtr      theXObject;
  +
  +                             if(0 != pxpath)
  +                             {
  +                                     theXObject =
  +                                             createVariable(
  +                                                     &xslCallTemplateElement,
  +                                                     *pxpath,
  +                                                     sourceNode,
  +                                                     *xslParamElement);
  +                             }
  +                             else
  +                             {
  +                                     theXObject =
  +                                             createVariable(
  +                                                     &xslCallTemplateElement,
  +                                                     *xslParamElement,
  +                                                     sourceNode);
  +                             }
  +
  +                             
params.push_back(ParamsVectorType::value_type(&xslParamElement->getQName(), 
theXObject));
  +                     }
  +
  +                     child = child->getNextSiblingElem();
  +             }
  +     }
   }
   
   
  
  
  
  1.52      +14 -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.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- StylesheetExecutionContextDefault.hpp     2001/03/06 21:23:01     1.51
  +++ StylesheetExecutionContextDefault.hpp     2001/03/11 16:47:52     1.52
  @@ -836,6 +836,20 @@
   private:
   
        /**
  +      * Given a context, create the params for a template
  +      * call.
  +      *
  +      * @param xslCallTemplateElement "call-template" element
  +      * @param sourceNode             source node
  +      * @param params The params
  +      */
  +     void
  +     getParams(
  +                     const ElemTemplateElement&      xslCallTemplateElement,
  +                     XalanNode*                                      
sourceNode,
  +                     ParamsVectorType&                       params);
  +
  +     /**
         * Get a XalanSourceTreeDocument, primarily for creating result 
         * tree fragments.
         */
  
  
  

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

Reply via email to