dbertoni    2003/03/04 21:04:57

  Modified:    c/src/XSLT ElemApplyTemplates.cpp ElemApplyTemplates.hpp
                        ElemForEach.cpp ElemTemplateElement.cpp
                        ElemTemplateElement.hpp
  Log:
  Don't select attributes that are namespace declarations when applying 
templates.
  
  Revision  Changes    Path
  1.32      +23 -30    xml-xalan/c/src/XSLT/ElemApplyTemplates.cpp
  
  Index: ElemApplyTemplates.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemApplyTemplates.cpp,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- ElemApplyTemplates.cpp    1 Feb 2003 00:24:31 -0000       1.31
  +++ ElemApplyTemplates.cpp    5 Mar 2003 05:04:54 -0000       1.32
  @@ -170,46 +170,39 @@
                  executionContext, *this));
        }
   
  -#if 1
        ParentType::transformSelectedChildren(
                        executionContext,
                        0);
  -#else
  -     XalanNode* const        sourceNode = executionContext.getCurrentNode();
  -     assert(sourceNode != 0);
  +}
   
  -     // Push the params & stack frame, but then execute the select
  -     // expression inside transformSelectedChildren, which must be
  -     // executed in the stack frame before the new stack frame.
  -     StylesheetExecutionContext::ParamsPushPop       thePushPop(
  -                     executionContext,
  -                     *this,
  -                     sourceNode,
  -                     this);
   
  -     const XalanQName* const         currentMode = 
executionContext.getCurrentMode();
  -     assert(currentMode != 0);
   
  -     if (isDefaultTemplate() == false &&
  -             !m_mode->equals(*currentMode))
  -     {
  -             executionContext.setCurrentMode(m_mode);
  +void
  +ElemApplyTemplates::transformChild(
  +                     StylesheetExecutionContext&             
executionContext,
  +                     const ElemTemplateElement&              xslInstruction,
  +                     const ElemTemplateElement*              theTemplate,
  +                     XalanNode*                                              
child) const
  +{
  +     assert(child != 0);
   
  -             transformSelectedChildren(
  -                             executionContext,
  -                             0,
  -                             thePushPop.getStackFrameIndex());
  +     const XalanNode::NodeType       nodeType = child->getNodeType();
   
  -             executionContext.setCurrentMode(currentMode);
  -     }
  -     else
  +     // Filter out any attributes nodes that are namespace declarations
  +     if (nodeType != XalanNode::ATTRIBUTE_NODE ||
  +#if defined(XALAN_OLD_STYLE_CASTS)
  +             DOMServices::isNamespaceDeclaration((const XalanAttr&)*child) 
== false)
  +#else
  +             DOMServices::isNamespaceDeclaration(static_cast<const 
XalanAttr&>(*child)) == false)
  +#endif
        {
  -             transformSelectedChildren(
  -                             executionContext,
  -                             0,
  -                             thePushPop.getStackFrameIndex());
  +             ParentType::transformChild(
  +                     executionContext,
  +                     xslInstruction,
  +                     theTemplate,
  +                     child,
  +                     nodeType);
        }
  -#endif
   }
   
   
  
  
  
  1.17      +11 -0     xml-xalan/c/src/XSLT/ElemApplyTemplates.hpp
  
  Index: ElemApplyTemplates.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemApplyTemplates.hpp,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- ElemApplyTemplates.hpp    1 Feb 2003 00:24:31 -0000       1.16
  +++ ElemApplyTemplates.hpp    5 Mar 2003 05:04:54 -0000       1.17
  @@ -114,6 +114,17 @@
        childTypeAllowed(int    xslToken) const;
   
        virtual void
  +     transformChild(
  +                     StylesheetExecutionContext&     executionContext,
  +                     const ElemTemplateElement&              xslInstruction,
  +                     const ElemTemplateElement*              theTemplate,
  +                     XalanNode*                                              
child) const;
  +
  +#if !defined(XALAN_NO_USING_DECLARATION)
  +     using ParentType::transformChild;
  +#endif
  +
  +     virtual void
        selectAndSortChildren(
                        StylesheetExecutionContext&             
executionContext,
                        const ElemTemplateElement*              theTemplate,
  
  
  
  1.35      +1 -1      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.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- ElemForEach.cpp   1 Feb 2003 00:24:31 -0000       1.34
  +++ ElemForEach.cpp   5 Mar 2003 05:04:54 -0000       1.35
  @@ -520,7 +520,7 @@
                                executionContext,
                                sourceNodes);
   
  -     for(unsigned int i = 0; i < sourceNodesCount; i++) 
  +     for(NodeRefListBase::size_type i = 0; i < sourceNodesCount; i++) 
        {
                XalanNode* const                childNode = sourceNodes.item(i);
                assert(childNode != 0);
  
  
  
  1.93      +32 -9     xml-xalan/c/src/XSLT/ElemTemplateElement.cpp
  
  Index: ElemTemplateElement.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemTemplateElement.cpp,v
  retrieving revision 1.92
  retrieving revision 1.93
  diff -u -r1.92 -r1.93
  --- ElemTemplateElement.cpp   12 Feb 2003 23:08:56 -0000      1.92
  +++ ElemTemplateElement.cpp   5 Mar 2003 05:04:54 -0000       1.93
  @@ -613,7 +613,7 @@
   
   
   
  -bool
  +void
   ElemTemplateElement::transformChild(
                        StylesheetExecutionContext&             
executionContext,
                        const ElemTemplateElement&              xslInstruction,
  @@ -622,7 +622,26 @@
   {
        assert(child != 0);
   
  -     const XalanNode::NodeType       nodeType = child->getNodeType();
  +     transformChild(
  +             executionContext,
  +             xslInstruction,
  +             theTemplate,
  +             child,
  +             child->getNodeType());
  +}
  +
  +
  +
  +
  +void
  +ElemTemplateElement::transformChild(
  +                     StylesheetExecutionContext&             
executionContext,
  +                     const ElemTemplateElement&              xslInstruction,
  +                     const ElemTemplateElement*              theTemplate,
  +                     XalanNode*                                              
child,
  +                     XalanNode::NodeType                             
nodeType) const
  +{
  +     assert(child != 0);
   
        if(0 == theTemplate)
        {
  @@ -638,6 +657,7 @@
                theTemplate = stylesheetTree->findTemplate(
                                                executionContext,
                                                child,
  +                                             nodeType,
                                                
*executionContext.getCurrentMode(),
                                                isApplyImports);
        }
  @@ -665,7 +685,7 @@
                        break;
                }     
        }
  -                     
  +                             
        if(0 != theTemplate)
        {
                if(theTemplate == 
getStylesheet().getStylesheetRoot().getDefaultTextRule())
  @@ -681,10 +701,15 @@
                                {
                                        const XalanDOMString&   val = 
child->getNodeValue();
   
  -                                     executionContext.characters(
  -                                             toCharArray(val), 
  -                                             0,
  -                                             length(val));
  +                                     const XalanDOMString::size_type         
len = length(val);
  +
  +                                     if (len > 0)
  +                                     {
  +                                             executionContext.characters(
  +                                                     toCharArray(val), 
  +                                                     0,
  +                                                     len);
  +                                     }
                                }
                                break;
   
  @@ -706,8 +731,6 @@
                        theTemplate->executeChildren(executionContext, child);
                }
        }
  -
  -     return true;
   }
   
   
  
  
  
  1.59      +20 -4     xml-xalan/c/src/XSLT/ElemTemplateElement.hpp
  
  Index: ElemTemplateElement.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemTemplateElement.hpp,v
  retrieving revision 1.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- ElemTemplateElement.hpp   12 Feb 2003 23:08:56 -0000      1.58
  +++ ElemTemplateElement.hpp   5 Mar 2003 05:04:54 -0000       1.59
  @@ -837,18 +837,34 @@
         * template and process the contents.
         * 
         * @param executionContext The current execution context
  -      * @param xslInstruction The calling element (deprecated -- I dont 
think we 
  -      *              need this).
  +      * @param xslInstruction The calling element
         * @param template The template to use if xsl:for-each, or null.
         * @param child The source context node.
  -      * @return true if applied a template, false if not.
         */
  -     bool
  +     virtual void
        transformChild(
                        StylesheetExecutionContext&     executionContext,
                        const ElemTemplateElement&              xslInstruction,
                        const ElemTemplateElement*              theTemplate,
                        XalanNode*                                              
child) const;
  +
  +     /**
  +      * Given an element, find the corresponding
  +      * template and process the contents.
  +      * 
  +      * @param executionContext The current execution context
  +      * @param xslInstruction The calling element
  +      * @param template The template to use if xsl:for-each, or null.
  +      * @param child The source context node.
  +      * @param nodeType The type of child.
  +      */
  +     virtual void
  +     transformChild(
  +                     StylesheetExecutionContext&     executionContext,
  +                     const ElemTemplateElement&              xslInstruction,
  +                     const ElemTemplateElement*              theTemplate,
  +                     XalanNode*                                              
child,
  +                     XalanNode::NodeType                             
nodeType) const;
   
        /**
         * Given an xsl token type, determine whether or not a child
  
  
  

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

Reply via email to