dbertoni    2004/04/05 17:15:37

  Modified:    c/src/xalanc/XSLT Stylesheet.cpp Stylesheet.hpp
                        StylesheetExecutionContextDefault.cpp
                        StylesheetExecutionContextDefault.hpp
                        StylesheetHandler.cpp StylesheetRoot.cpp
                        StylesheetRoot.hpp XSLTEngineImpl.cpp
                        XSLTEngineImpl.hpp XalanSpaceNodeTester.cpp
                        XalanSpaceNodeTester.hpp
  Log:
  New code for improved preserve/strip space handling.
  
  Revision  Changes    Path
  1.10      +39 -4     xml-xalan/c/src/xalanc/XSLT/Stylesheet.cpp
  
  Index: Stylesheet.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/Stylesheet.cpp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Stylesheet.cpp    26 Feb 2004 22:58:58 -0000      1.9
  +++ Stylesheet.cpp    6 Apr 2004 00:15:36 -0000       1.10
  @@ -84,6 +84,7 @@
        m_stylesheetRoot(root),
        m_baseIdent(baseIdentifier),
        m_keyDeclarations(),
  +     m_whitespaceElements(),
        m_XSLTNamespaceURI(constructionContext.getXSLTNamespaceURI()),
        m_imports(),
        m_importsSize(0),
  @@ -441,13 +442,40 @@
   
   
   void
  +Stylesheet::addWhitespaceElement(const XalanSpaceNodeTester& theTester)
  +{
  +     typedef WhitespaceElementsVectorType::iterator  iterator;
  +
  +     const XPath::eMatchScore        theMatchScore = 
theTester.getMatchScore();
  +
  +     iterator        i = m_whitespaceElements.begin();
  +
  +     while(i != m_whitespaceElements.end())
  +     {
  +             if (theMatchScore >= (*i).getMatchScore())
  +             {
  +                     break;
  +             }
  +             else
  +             {
  +                     ++i;
  +             }
  +     }
  +
  +     m_whitespaceElements.insert(i, theTester);
  +}
  +
  +
  +
  +void
   Stylesheet::postConstruction(StylesheetConstructionContext&          
constructionContext)
   {
        {
                m_importsSize = m_imports.size();
   
  -             // Call postConstruction() on any imported stylesheets, the get 
any aliases
  -             // in reverse order, to preserve import precedence. Also, get 
any key declarations.
  +             // Call postConstruction() on any imported stylesheets, the get 
things
  +             // in reverse order, to preserve import precedence. Also, get 
any key
  +             // declarations and preserve/strip space information.
                const StylesheetVectorType::reverse_iterator    theEnd = 
m_imports.rend();
                StylesheetVectorType::reverse_iterator  i = m_imports.rbegin();
   
  @@ -457,12 +485,19 @@
   
                        
m_namespacesHandler.copyNamespaceAliases((*i)->getNamespacesHandler());
   
  -                     // $$ ToDo: Should we clear the imported stylesheet's 
key
  -                     // declarations after we copy them?
                        m_keyDeclarations.insert(
                                m_keyDeclarations.end(),
                                (*i)->m_keyDeclarations.begin(),
                                (*i)->m_keyDeclarations.end());
  +
  +                     
KeyDeclarationVectorType().swap((*i)->m_keyDeclarations);
  +
  +                     m_whitespaceElements.insert(
  +                             m_whitespaceElements.end(),
  +                             (*i)->m_whitespaceElements.begin(),
  +                             (*i)->m_whitespaceElements.end());
  +
  +                     
WhitespaceElementsVectorType().swap((*i)->m_whitespaceElements);
   
                        ++i;
                }
  
  
  
  1.9       +8 -0      xml-xalan/c/src/xalanc/XSLT/Stylesheet.hpp
  
  Index: Stylesheet.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/Stylesheet.hpp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Stylesheet.hpp    26 Feb 2004 22:58:58 -0000      1.8
  +++ Stylesheet.hpp    6 Apr 2004 00:15:36 -0000       1.9
  @@ -46,6 +46,7 @@
   #include <xalanc/XSLT/NamespacesHandler.hpp>
   #include <xalanc/XSLT/KeyDeclaration.hpp>
   #include <xalanc/XSLT/StylesheetExecutionContext.hpp>
  +#include <xalanc/XSLT/XalanSpaceNodeTester.hpp>
   
   
   
  @@ -104,6 +105,7 @@
        typedef vector<Stylesheet*>                                             
StylesheetVectorType;
        typedef vector<XalanDOMString>                                  
URLStackType;
        typedef vector<ElemDecimalFormat*>                              
ElemDecimalFormatVectorType;
  +     typedef vector<XalanSpaceNodeTester>                    
WhitespaceElementsVectorType;
   #else
        typedef std::map<XalanDOMString, ExtensionNSHandler*>   
ExtensionNamespacesMapType;
        typedef std::map<XalanQNameByReference,
  @@ -115,6 +117,7 @@
        typedef std::vector<Stylesheet*>                                        
        StylesheetVectorType;
        typedef std::vector<XalanDOMString>                                     
        URLStackType;
        typedef std::vector<ElemDecimalFormat*>                                 
ElemDecimalFormatVectorType;
  +     typedef std::vector<XalanSpaceNodeTester>                               
WhitespaceElementsVectorType;
   #endif
   
        /**
  @@ -261,6 +264,9 @@
                m_namespaces.pop_back(); 
        }
   
  +     void
  +     addWhitespaceElement(const XalanSpaceNodeTester&        theTester);
  +
        /**
         * Called after construction is completed.
         */
  @@ -856,6 +862,8 @@
         * xsl:key element.
         */
        KeyDeclarationVectorType                        m_keyDeclarations;
  +
  +     WhitespaceElementsVectorType            m_whitespaceElements;
   
        static const XalanQNameByReference      s_emptyQName;
   
  
  
  
  1.25      +16 -7     
xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContextDefault.cpp
  
  Index: StylesheetExecutionContextDefault.cpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContextDefault.cpp,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- StylesheetExecutionContextDefault.cpp     2 Apr 2004 02:45:34 -0000       
1.24
  +++ StylesheetExecutionContextDefault.cpp     6 Apr 2004 00:15:36 -0000       
1.25
  @@ -137,7 +137,8 @@
        m_usePerInstanceDocumentFactory(false),
        m_cloneTextNodesOnly(false),
        m_escapeURLs(eEscapeURLsDefault),
  -     m_omitMETATag(eOmitMETATagDefault)
  +     m_omitMETATag(eOmitMETATagDefault),
  +     m_hasStripOrPreserveSpace(false)
   {
       m_currentTemplateStack.push_back(0);
   }
  @@ -178,7 +179,8 @@
        m_documentAllocator(eDocumentAllocatorBlockSize),
        m_usePerInstanceDocumentFactory(false),
        m_cloneTextNodesOnly(false),
  -     m_escapeURLs(eEscapeURLsDefault)
  +     m_escapeURLs(eEscapeURLsDefault),
  +     m_hasStripOrPreserveSpace(false)
   {
       m_currentTemplateStack.push_back(0);
   }
  @@ -250,9 +252,11 @@
        else
        {
                m_xsltProcessor->setExecutionContext(this);
  -     }
   
  -     m_countersTable.resize(theStylesheet->getElemNumberCount());
  +             m_hasStripOrPreserveSpace = 
theStylesheet->hasPreserveOrStripSpaceElements();
  +
  +             m_countersTable.resize(theStylesheet->getElemNumberCount());
  +     }
   }
   
   
  @@ -1747,6 +1751,8 @@
        m_xpathExecutionContextDefault.reset();
   
        m_cloneTextNodesOnly = false;
  +
  +     m_hasStripOrPreserveSpace = false;
   }
   
   
  @@ -2069,13 +2075,16 @@
   bool
   StylesheetExecutionContextDefault::shouldStripSourceNode(const XalanText&    
node)
   {
  -     if (m_xsltProcessor == 0)
  +     if (m_hasStripOrPreserveSpace == false || m_stylesheetRoot == 0)
        {
  -             return 
m_xpathExecutionContextDefault.shouldStripSourceNode(node);
  +             return false;
        }
        else
        {
  -             return m_xsltProcessor->shouldStripSourceNode(*this, node);
  +             assert(m_stylesheetRoot->hasPreserveOrStripSpaceElements() == 
true);
  +        assert(length(node.getData()) != 0);
  +
  +             return m_stylesheetRoot->shouldStripSourceNode(node);
        }
   }
   
  
  
  
  1.19      +2 -0      
xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContextDefault.hpp
  
  Index: StylesheetExecutionContextDefault.hpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/xalanc/XSLT/StylesheetExecutionContextDefault.hpp,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- StylesheetExecutionContextDefault.hpp     2 Apr 2004 02:45:34 -0000       
1.18
  +++ StylesheetExecutionContextDefault.hpp     6 Apr 2004 00:15:36 -0000       
1.19
  @@ -1116,6 +1116,8 @@
        // Determines whether or not to override the property in the stylesheet.
        eOmitMETATag                                            m_omitMETATag;
   
  +     bool                                                            
m_hasStripOrPreserveSpace;
  +
        static XalanNumberFormatFactory         
s_defaultXalanNumberFormatFactory;
   
        static XalanNumberFormatFactory*        s_xalanNumberFormatFactory;
  
  
  
  1.14      +11 -22    xml-xalan/c/src/xalanc/XSLT/StylesheetHandler.cpp
  
  Index: StylesheetHandler.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/StylesheetHandler.cpp,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- StylesheetHandler.cpp     2 Apr 2004 02:45:34 -0000       1.13
  +++ StylesheetHandler.cpp     6 Apr 2004 00:15:36 -0000       1.14
  @@ -1000,29 +1000,17 @@
   
                        while(tokenizer.hasMoreTokens())
                        {
  -                             // Use only the root, at least for right now.
                                tokenizer.nextToken(theNameTest);
   
  -                             /**
  -                              * Creating a match pattern is too much 
overhead, but it's a reasonably 
  -                              * easy and safe way to do this right now.
  -                              */
  -                             const XPath* const      matchPat =
  -                                             
m_constructionContext.createMatchPattern(
  -                                                             0,
  -                                                             theNameTest,
  -                                                             theProxy);
  -
  -                const XalanSpaceNodeTester  
theNodeTest(m_constructionContext, theNameTest, theProxy, locator);
  -
  -                             if(isPreserveSpace == true)
  -                             {
  -                                     
m_stylesheet.getStylesheetRoot().pushWhitespacePreservingElement(matchPat);
  -                             }
  -                             else
  -                             {
  -                                     
m_stylesheet.getStylesheetRoot().pushWhitespaceStrippingElement(matchPat);
  -                             }
  +                             m_stylesheet.addWhitespaceElement(
  +                                     XalanSpaceNodeTester(
  +                                                     isPreserveSpace == true 
?
  +                                                             
XalanSpaceNodeTester::ePreserve :
  +                                                             
XalanSpaceNodeTester::eStrip,
  +                                                     m_constructionContext,
  +                                                     theNameTest,
  +                                                     theProxy,
  +                                                     locator));
                        }
                }
                else if(!isAttrOK(aname, atts, i))
  @@ -1037,7 +1025,8 @@
                        XalanMessageLoader::getMessage(
                                XalanMessages::ElementRequiresAttribute_2Param,
                                isPreserveSpace == true ? 
  -                             
Constants::ELEMNAME_PRESERVESPACE_WITH_PREFIX_STRING : 
Constants::ELEMNAME_STRIPSPACE_WITH_PREFIX_STRING,
  +                                 
Constants::ELEMNAME_PRESERVESPACE_WITH_PREFIX_STRING :
  +                                     
Constants::ELEMNAME_STRIPSPACE_WITH_PREFIX_STRING,
                                Constants::ATTRNAME_ELEMENTS),
                        locator);
        }
  
  
  
  1.15      +20 -63    xml-xalan/c/src/xalanc/XSLT/StylesheetRoot.cpp
  
  Index: StylesheetRoot.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/StylesheetRoot.cpp,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- StylesheetRoot.cpp        3 Apr 2004 02:27:22 -0000       1.14
  +++ StylesheetRoot.cpp        6 Apr 2004 00:15:36 -0000       1.15
  @@ -103,8 +103,6 @@
        m_indentAmount(-1),
        m_omitMETATag(false),
        m_elemNumberNextID(0),
  -     m_whitespacePreservingElements(),
  -     m_whitespaceStrippingElements(),
        m_attributeSetsMap()
   {
        // Our base class has already resolved the URI and pushed it on
  @@ -802,76 +800,35 @@
   
   
   bool
  -StylesheetRoot::shouldStripSourceNode(
  -                     StylesheetExecutionContext&             
executionContext,
  -                     const XalanText&                                
textNode) const
  +StylesheetRoot::shouldStripSourceNode(const XalanText&       textNode) const
   {
  -     bool    strip = false;
  -
  -     XalanNode* const        parent = textNode.getParentNode();
  -     assert(parent != 0 && parent->getNodeType() == XalanNode::ELEMENT_NODE);
  -
  -     XPath::eMatchScore      highPreserveScore = XPath::eMatchScoreNone;
  -     XPath::eMatchScore      highStripScore = XPath::eMatchScoreNone;
  +     const XalanNode* const  parent = textNode.getParentNode();
  +     assert(parent != 0);
   
  +     if (textNode.isIgnorableWhitespace() == true &&
  +             parent->getNodeType() == XalanNode::ELEMENT_NODE)
        {
  -             const XPathVectorType&  theElements =
  -                             m_whitespacePreservingElements;
  -
  -             const XPathVectorType::size_type        nTests =
  -                             theElements.size();
  -
  -             for(XPathVectorType::size_type i = 0; i < nTests; i++)
  -             {
  -                     const XPath* const      matchPat = theElements[i];
  -                     assert(matchPat != 0);
  -
  -                     const XPath::eMatchScore        score = 
matchPat->getMatchScore(parent, executionContext);
  -
  -                     if(score > highPreserveScore)
  -                             highPreserveScore = score;
  -             }
  -     }
  -
  -     {
  -             const XPathVectorType&  theElements =
  -                             m_whitespaceStrippingElements;
  -
  -             const XPathVectorType::size_type        nTests =
  -                     theElements.size();
  -
  -             for(XPathVectorType::size_type i = 0; i < nTests; i++)
  -             {
  -                     const XPath* const      matchPat =
  -                                                                     
theElements[i];
  -                     assert(matchPat != 0);
  +             const XalanElement* const       theElement =
  +#if defined(XALAN_OLD_STYLE_CASTS)
  +                             (const XalanElement*)parent;
  +#else
  +                             static_cast<const XalanElement*>(parent);
  +#endif
   
  -                     const XPath::eMatchScore        score = 
matchPat->getMatchScore(parent, executionContext);
  +             typedef WhitespaceElementsVectorType::const_iterator    
const_iterator;
   
  -                     if(score > highStripScore)
  -                             highStripScore = score;
  -             }
  -     }
  -                     
  -     if(highPreserveScore > XPath::eMatchScoreNone ||
  -        highStripScore > XPath::eMatchScoreNone)
  -     {
  -             if(highPreserveScore > highStripScore)
  +             for (const_iterator i = m_whitespaceElements.begin();
  +                             i != m_whitespaceElements.end();
  +                                     ++i)
                {
  -                     strip = false;
  -             }
  -             else if(highStripScore > highPreserveScore)
  -             {
  -                     strip = true;
  -             }
  -             else
  -             {
  -                     executionContext.warn(
  -                                     
XalanMessageLoader::getMessage(XalanMessages::MatchConflictBetween_strip_space_preserve_space));
 
  +                     if ((*i)(*theElement) != XPath::eMatchScoreNone)
  +                     {
  +                             return (*i).getType() == 
XalanSpaceNodeTester::eStrip;
  +                     }
                }
        }
   
  -     return strip;
  +     return false;
   }
   
   
  
  
  
  1.7       +2 -29     xml-xalan/c/src/xalanc/XSLT/StylesheetRoot.hpp
  
  Index: StylesheetRoot.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/StylesheetRoot.hpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- StylesheetRoot.hpp        26 Feb 2004 22:58:58 -0000      1.6
  +++ StylesheetRoot.hpp        6 Apr 2004 00:15:36 -0000       1.7
  @@ -57,14 +57,12 @@
   
   #if defined(XALAN_NO_STD_NAMESPACE)
        typedef vector<const XalanQName*>               XalanQNameVectorType;
  -     typedef vector<const XPath*>                    XPathVectorType;
        typedef vector<ElemAttributeSet*>               AttributeSetVectorType;
        typedef map<const XalanQName*,
                            AttributeSetVectorType,
                                pointer_less<const XalanQName> >        
AttributeSetMapType;
   #else
        typedef std::vector<const XalanQName*>  XalanQNameVectorType;
  -     typedef std::vector<const XPath*>               XPathVectorType;
        typedef std::vector<ElemAttributeSet*>  AttributeSetVectorType;
        typedef std::map<const XalanQName*,
                                         AttributeSetVectorType,
  @@ -380,26 +378,11 @@
        bool
        hasPreserveOrStripSpaceElements() const
        {
  -             return m_whitespacePreservingElements.empty() == false ||
  -                        m_whitespaceStrippingElements.empty() == false;
  -     }
  -
  -     void
  -     pushWhitespacePreservingElement(const XPath*    theXPath)
  -     {
  -             m_whitespacePreservingElements.push_back(theXPath);
  -     }
  -
  -     void
  -     pushWhitespaceStrippingElement(const XPath*             theXPath)
  -     {
  -             m_whitespaceStrippingElements.push_back(theXPath);
  +             return m_whitespaceElements.empty() == false;
        }
   
        bool
  -     shouldStripSourceNode(
  -                     StylesheetExecutionContext&             
executionContext,
  -                     const XalanText&                                
textNode) const;
  +     shouldStripSourceNode(const XalanText&  textNode) const;
   
        void
        addAttributeSet(ElemAttributeSet&       theAttributeSet);
  @@ -549,16 +532,6 @@
         * This is set to true if we should omit the META tag in HTML output 
(the default is false)
         */
        unsigned long                           m_elemNumberNextID;
  -
  -     /**
  -      * A lookup table of all space preserving elements.
  -      */
  -     XPathVectorType                         m_whitespacePreservingElements;
  -  
  -     /**
  -      * A lookup table of all space stripping elements.
  -      */
  -     XPathVectorType                         m_whitespaceStrippingElements;
   
        /**
         * A lookup table of all attribute sets.
  
  
  
  1.16      +1 -36     xml-xalan/c/src/xalanc/XSLT/XSLTEngineImpl.cpp
  
  Index: XSLTEngineImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/XSLTEngineImpl.cpp,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- XSLTEngineImpl.cpp        3 Apr 2004 02:26:29 -0000       1.15
  +++ XSLTEngineImpl.cpp        6 Apr 2004 00:15:36 -0000       1.16
  @@ -156,7 +156,6 @@
        m_dummyAttributesList(),
        m_scratchString(),
        m_attributeNamesVisited(),
  -     m_hasStripOrPreserveSpace(false),
        m_hasCDATASectionElements(false),
        m_xpathConstructionContext()
   {
  @@ -188,7 +187,6 @@
   
        m_attributeNamesVisited.clear();
   
  -     m_hasStripOrPreserveSpace = false;
        m_hasCDATASectionElements = false;
   
        m_xpathConstructionContext.reset();
  @@ -342,8 +340,6 @@
                        theFormatter->setPrefixResolver(this);
                }
   
  -             m_hasStripOrPreserveSpace = 
m_stylesheetRoot->hasPreserveOrStripSpaceElements();
  -
                m_hasCDATASectionElements = 
m_stylesheetRoot->hasCDATASectionElements();
   
                m_stylesheetRoot->process(sourceTree, outputTarget, 
executionContext);
  @@ -387,8 +383,6 @@
                        theFormatter->setPrefixResolver(this);
                }
   
  -             m_hasStripOrPreserveSpace = 
m_stylesheetRoot->hasPreserveOrStripSpaceElements();
  -
                m_hasCDATASectionElements = 
m_stylesheetRoot->hasCDATASectionElements();
   
                m_stylesheetRoot->process(sourceTree, outputTarget, 
executionContext);
  @@ -2040,7 +2034,7 @@
                   node.getParentNode()->getNodeType() != 
XalanNode::DOCUMENT_NODE);
   
       if (overrideStrip == true ||
  -        shouldStripSourceNode(*m_executionContext, node) == false)
  +        m_executionContext->shouldStripSourceNode(node) == false)
       {
            const XalanDOMString&       data = node.getData();
           assert(0 != length(data));
  @@ -2938,35 +2932,6 @@
                                attr->getNodeName(),
                                attr->getNodeValue(),
                                attList);
  -             }
  -     }
  -}
  -
  -
  -
  -bool
  -XSLTEngineImpl::shouldStripSourceNode(
  -                     StylesheetExecutionContext&             
executionContext,
  -                     const XalanText&                                
textNode) const
  -{
  -     if (m_hasStripOrPreserveSpace == false || m_stylesheetRoot == 0)
  -     {
  -             return false;
  -     }
  -     else
  -     {
  -             assert(m_stylesheetRoot->hasPreserveOrStripSpaceElements() == 
true);
  -        assert(length(textNode.getData()) != 0);
  -
  -        if(textNode.isIgnorableWhitespace() == false)
  -        {
  -            return false;
  -        }
  -        else
  -             {
  -                     return m_stylesheetRoot->shouldStripSourceNode(
  -                                                     executionContext,
  -                                                     textNode);
                }
        }
   }
  
  
  
  1.10      +0 -20     xml-xalan/c/src/xalanc/XSLT/XSLTEngineImpl.hpp
  
  Index: XSLTEngineImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/XSLTEngineImpl.hpp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- XSLTEngineImpl.hpp        2 Apr 2004 02:45:34 -0000       1.9
  +++ XSLTEngineImpl.hpp        6 Apr 2004 00:15:36 -0000       1.10
  @@ -663,24 +663,6 @@
                        XalanDOMString::size_type       length);
   
        /**
  -      * Tells, through the combination of the default-space attribute on
  -      * xsl:stylesheet, xsl:strip-space, xsl:preserve-space, and the 
xml:space
  -      * attribute, whether or not extra whitespace should be stripped from 
the
  -      * node.  Literal elements from template elements should <em>not</em> be
  -      * tested with this function.
  -      *
  -      * @param executionContext  current execution context
  -      * @param node text node from the source tree
  -      * @return true if the text node should be stripped of extra whitespace
  -      *
  -      * $$$ ToDo: This has no business being here in the engine...
  -      */
  -     bool
  -     shouldStripSourceNode(
  -                     StylesheetExecutionContext&             
executionContext,
  -                     const XalanText&                                node) 
const;
  -
  -     /**
         * Clone a node to the result tree
         *
         * @param node      node to clone
  @@ -1705,8 +1687,6 @@
        XalanDOMString                                          m_scratchString;
   
        XalanDOMStringPointerVectorType         m_attributeNamesVisited;
  -
  -     bool                                                            
m_hasStripOrPreserveSpace;
   
        bool                                                            
m_hasCDATASectionElements;
   
  
  
  
  1.2       +20 -109   xml-xalan/c/src/xalanc/XSLT/XalanSpaceNodeTester.cpp
  
  Index: XalanSpaceNodeTester.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/XalanSpaceNodeTester.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XalanSpaceNodeTester.cpp  2 Apr 2004 02:45:34 -0000       1.1
  +++ XalanSpaceNodeTester.cpp  6 Apr 2004 00:15:36 -0000       1.2
  @@ -33,128 +33,39 @@
   
   
   XalanSpaceNodeTester::XalanSpaceNodeTester() :
  -    m_nodeTester(),
  -    m_matchScore(XPath::eMatchScoreNone)
  +    NodeTester(),
  +    m_matchScore(XPath::eMatchScoreNone),
  +     m_type(ePreserve)
   {
   }
  -    
   
   
  -static const XalanDOMString     s_emptyString;
  +
  +XalanSpaceNodeTester::XalanSpaceNodeTester(const XalanSpaceNodeTester&       
theSource) :
  +    NodeTester(theSource),
  +    m_matchScore(theSource.m_matchScore),
  +     m_type(theSource.m_type)
  +{
  +}
  +    
   
   
   
   XalanSpaceNodeTester::XalanSpaceNodeTester(
  +                     eType                                                   
theType,
               StylesheetConstructionContext&  theConstructionContext,
               const XalanDOMString&           theNameTest,
               const PrefixResolver&           thePrefixResolver,
               const LocatorType*              theLocator) :
  -    m_nodeTester(),
  -    m_matchScore(XPath::eMatchScoreNone)
  +    NodeTester(
  +             theConstructionContext,
  +             theNameTest,
  +             thePrefixResolver,
  +             theLocator,
  +             &m_matchScore),
  +    m_matchScore(),
  +     m_type(theType)
   {
  -     const XalanDOMString::size_type     theLength =
  -                length(theNameTest);
  -
  -    if (theLength == 1 && theNameTest[0] == XPath::PSEUDONAME_ANY[0])
  -    {
  -        m_nodeTester = XPath::NodeTester(s_emptyString, s_emptyString, 
m_matchScore);
  -    }
  -    else
  -    {
  -        const XalanDOMString::size_type     theIndex =
  -                indexOf(theNameTest, XalanUnicode::charColon);
  -
  -        // If there's no ':', it's an NCName...
  -        if (theIndex == theLength)
  -        {
  -            if (XalanQName::isValidNCName(theNameTest) == false)
  -            {
  -                     theConstructionContext.error(
  -                    XalanMessageLoader::getMessage(
  -                        XalanMessages::IsNotValidQName_1Param,
  -                        theNameTest),
  -                        0,
  -                        theLocator);
  -            }
  -            else
  -            {
  -                m_nodeTester =
  -                    XPath::NodeTester(
  -                        s_emptyString,
  -                        theConstructionContext.getPooledString(theNameTest),
  -                        m_matchScore);
  -            }
  -        }
  -        else
  -        {
  -            StylesheetConstructionContext::GetAndReleaseCachedString    
scratchGuard(theConstructionContext);
  -
  -             XalanDOMString&         theScratchString = scratchGuard.get();
  -
  -            theScratchString.assign(theNameTest, 0, theIndex);
  -
  -            // Get the namespace URI for the prefix...
  -            const XalanDOMString* const     theNamespaceURI =
  -                thePrefixResolver.getNamespaceForPrefix(theScratchString);
  -
  -            if (theNamespaceURI == 0)
  -            {
  -                     theConstructionContext.error(
  -                    XalanMessageLoader::getMessage(
  -                        XalanMessages::UndeclaredNamespacePrefix_1Param,
  -                        theScratchString),
  -                        0,
  -                        theLocator);
  -            }
  -            else
  -            {
  -                // OK, now we have a namespace URI...
  -                if (XalanQName::isValidNCName(theScratchString) == false)
  -                {
  -                         theConstructionContext.error(
  -                        XalanMessageLoader::getMessage(
  -                            XalanMessages::IsNotValidQName_1Param,
  -                            theNameTest),
  -                            0,
  -                            theLocator);
  -                }
  -                else if (theIndex == theLength - 2 &&
  -                         theNameTest[theIndex + 1] == 
XPath::PSEUDONAME_ANY[0])
  -                {
  -                    // It's of the form "NCName:*"
  -                    m_nodeTester =
  -                        XPath::NodeTester(
  -                            
theConstructionContext.getPooledString(*theNamespaceURI),
  -                            s_emptyString,
  -                            m_matchScore);
  -                }
  -                else
  -                {
  -                    theScratchString.assign(theNameTest, theIndex + 1, 
theLength - theIndex - 1);
  -
  -                    if (XalanQName::isValidNCName(theScratchString) == false)
  -                    {
  -                             theConstructionContext.error(
  -                            XalanMessageLoader::getMessage(
  -                                XalanMessages::IsNotValidQName_1Param,
  -                                theNameTest),
  -                                0,
  -                                theLocator);
  -                    }
  -                    else
  -                    {
  -                        // It's of the form "NCName:NCName"
  -                        m_nodeTester =
  -                            XPath::NodeTester(
  -                                
theConstructionContext.getPooledString(*theNamespaceURI),
  -                                
theConstructionContext.getPooledString(theScratchString),
  -                                m_matchScore);
  -                    }
  -                }
  -            }
  -        }
  -    }
  -
       assert(m_matchScore != XPath::eMatchScoreNone);
   }
       
  
  
  
  1.2       +29 -7     xml-xalan/c/src/xalanc/XSLT/XalanSpaceNodeTester.hpp
  
  Index: XalanSpaceNodeTester.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/xalanc/XSLT/XalanSpaceNodeTester.hpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XalanSpaceNodeTester.hpp  2 Apr 2004 02:45:34 -0000       1.1
  +++ XalanSpaceNodeTester.hpp  6 Apr 2004 00:15:36 -0000       1.2
  @@ -41,13 +41,24 @@
   
   
   
  -class XalanSpaceNodeTester
  +class XalanSpaceNodeTester : public XPath::NodeTester
   {
   public:
   
  +     typedef XPath::NodeTester       ParentType;
  +
  +     enum eType
  +     {
  +             eStrip,
  +             ePreserve
  +     };
  +
       XalanSpaceNodeTester();
   
  +    XalanSpaceNodeTester(const XalanSpaceNodeTester& theSource);
  +
       XalanSpaceNodeTester(
  +                     eType                                                   
theType,
               StylesheetConstructionContext&  theContext,
               const XalanDOMString&           theNameTest,
               const PrefixResolver&           thePrefixResolver,
  @@ -61,17 +72,28 @@
           return m_matchScore;
       }
   
  -     XPath::eMatchScore
  -     operator()(const XalanNode&     context) const
  +     eType
  +     getType() const
        {
  -         return m_nodeTester(context);
  +             return m_type;
        }
   
  -private:
  +     XalanSpaceNodeTester&
  +     operator=(const XalanSpaceNodeTester&   theRHS)
  +     {
  +             m_matchScore = theRHS.m_matchScore;
  +             m_type = theRHS.m_type;
   
  -    XPath::NodeTester   m_nodeTester;
  +             ParentType::operator=(theRHS);
  +
  +             return *this;
  +     }
  +
  +private:
   
       XPath::eMatchScore  m_matchScore;
  +
  +     eType                           m_type;
   };
   
   
  
  
  

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

Reply via email to