dbertoni    2002/09/25 18:38:16

  Modified:    c/src/XSLT ElemLiteralResult.cpp ElemTemplateElement.cpp
                        NamespacesHandler.cpp NamespacesHandler.hpp
                        ResultTreeFrag.cpp ResultTreeFrag.hpp
                        Stylesheet.cpp Stylesheet.hpp StylesheetHandler.cpp
                        StylesheetRoot.cpp
  Log:
  New pooled string implementation.
  
  Revision  Changes    Path
  1.55      +13 -3     xml-xalan/c/src/XSLT/ElemLiteralResult.cpp
  
  Index: ElemLiteralResult.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemLiteralResult.cpp,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- ElemLiteralResult.cpp     24 Sep 2002 01:42:34 -0000      1.54
  +++ ElemLiteralResult.cpp     26 Sep 2002 01:38:15 -0000      1.55
  @@ -248,6 +248,8 @@
        // that will need namespace declarations...
        m_attrCount = m_avts.size();
   
  +     XalanDOMString  thePrefix;
  +
        for(AVTVectorType::size_type i = 0; i < m_attrCount; ++i)
        {
                const AVT* const        avt = m_avts[i];
  @@ -258,7 +260,9 @@
   
                if (theColonIndex != length(theName))
                {
  -                     
m_namespacesHandler.addActivePrefix(XalanDOMString(theName, 0, theColonIndex));
  +                     theName.substr(thePrefix, 0, theColonIndex);
  +
  +                     
m_namespacesHandler.addActivePrefix(constructionContext, thePrefix);
                }
        }
   
  @@ -406,13 +410,19 @@
   {
        if(equals(localName, Constants::ATTRNAME_EXTENSIONELEMENTPREFIXES))
        {
  -             m_namespacesHandler.processExtensionElementPrefixes(attrValue, 
stylesheetTree.getNamespaces(), constructionContext);
  +             m_namespacesHandler.processExtensionElementPrefixes(
  +                             constructionContext,
  +                             attrValue,
  +                             stylesheetTree.getNamespaces());
   
                return true;
        }
        else if (equals(localName, Constants::ATTRNAME_EXCLUDE_RESULT_PREFIXES))
        {
  -             m_namespacesHandler.processExcludeResultPrefixes(attrValue, 
stylesheetTree.getNamespaces(), constructionContext);
  +             m_namespacesHandler.processExcludeResultPrefixes(
  +                             constructionContext,
  +                             attrValue,
  +                             stylesheetTree.getNamespaces());
   
                return true;
        }
  
  
  
  1.80      +9 -4      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.79
  retrieving revision 1.80
  diff -u -r1.79 -r1.80
  --- ElemTemplateElement.cpp   24 Sep 2002 05:59:38 -0000      1.79
  +++ ElemTemplateElement.cpp   26 Sep 2002 01:38:15 -0000      1.80
  @@ -124,9 +124,11 @@
        XalanElement(),
        PrefixResolver(),
        m_finishedConstruction(false),
  -     m_namespacesHandler(stylesheetTree.getNamespacesHandler(),
  -                                             stylesheetTree.getNamespaces(),
  -                                             
stylesheetTree.getXSLTNamespaceURI()),
  +     m_namespacesHandler(
  +                     constructionContext,
  +                     stylesheetTree.getNamespacesHandler(),
  +                     stylesheetTree.getNamespaces(),
  +                     stylesheetTree.getXSLTNamespaceURI()),
        m_stylesheet(stylesheetTree),
        m_lineNumber(lineNumber),
        m_columnNumber(columnNumber),
  @@ -1055,7 +1057,10 @@
                        StylesheetConstructionContext&  constructionContext,
                        const NamespacesHandler&                
theParentHandler)
   {
  -     m_namespacesHandler.postConstruction(getElementName(), 
&theParentHandler);
  +     m_namespacesHandler.postConstruction(
  +                     constructionContext,
  +                     getElementName(),
  +                     &theParentHandler);
   
        if (hasChildren() == true)
        {
  
  
  
  1.22      +119 -44   xml-xalan/c/src/XSLT/NamespacesHandler.cpp
  
  Index: NamespacesHandler.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/NamespacesHandler.cpp,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- NamespacesHandler.cpp     5 Sep 2002 07:08:13 -0000       1.21
  +++ NamespacesHandler.cpp     26 Sep 2002 01:38:15 -0000      1.22
  @@ -78,6 +78,10 @@
   
   
   
  +const XalanDOMString         
NamespacesHandler::NamespaceExtended::s_emptyString;
  +
  +
  +
   NamespacesHandler::NamespacesHandler() :
        m_excludedResultPrefixes(),
        m_namespaceDeclarations(),
  @@ -91,9 +95,10 @@
   
   
   NamespacesHandler::NamespacesHandler(
  -                     const NamespacesHandler&        /* 
stylesheetNamespacesHandler */,
  -                     const NamespacesStackType&      theCurrentNamespaces,
  -                     const XalanDOMString&           theXSLTNamespaceURI) :
  +                     StylesheetConstructionContext&  theConstructionContext,
  +                     const NamespacesHandler&                /* 
stylesheetNamespacesHandler */,
  +                     const NamespacesStackType&              
theCurrentNamespaces,
  +                     const XalanDOMString&                   
theXSLTNamespaceURI) :
        m_excludedResultPrefixes(),
        m_namespaceDeclarations(),
        m_extensionNamespaceURIs(),
  @@ -131,13 +136,20 @@
                        {
                                if (m_namespaceDeclarations.count(thePrefix) == 
0)
                                {
  -                                     
m_namespaceDeclarations.insert(NamespacesMapType::value_type(thePrefix, 
theNamespace));
  +                                     m_namespaceDeclarations.insert(
  +                                             NamespacesMapType::value_type(
  +                                                     thePrefix,
  +                                                     NamespaceExtended(
  +                                                             
theConstructionContext.getPooledString(theNamespace.getPrefix()),
  +                                                             
theConstructionContext.getPooledString(theNamespace.getURI()))));
                                }
                        }
                        else
                        {
                                m_excludedResultPrefixes.insert(
  -                                             
ExcludedResultPrefixesMapType::value_type(thePrefix, theURI));
  +                                     
ExcludedResultPrefixesMapType::value_type(
  +                                             thePrefix,
  +                                             
&theConstructionContext.getPooledString(theURI)));
                        }
                }
        }
  @@ -145,20 +157,18 @@
   
   
   
  -NamespacesHandler::NamespacesHandler(const NamespacesHandler&        
theSource) :
  -     m_excludedResultPrefixes(theSource.m_excludedResultPrefixes),
  -     m_namespaceDeclarations(theSource.m_namespaceDeclarations),
  -     m_extensionNamespaceURIs(theSource.m_extensionNamespaceURIs),
  -     m_namespaceAliases(theSource.m_namespaceAliases),
  -     m_activePrefixes(theSource.m_activePrefixes),
  -     m_processAliases(theSource.m_processAliases)
  +NamespacesHandler::~NamespacesHandler()
   {
   }
   
   
   
  -NamespacesHandler::~NamespacesHandler()
  +void
  +NamespacesHandler::addExtensionNamespaceURI(
  +                     StylesheetConstructionContext&  theConstructionContext,
  +                     const XalanDOMString&   theURI)
   {
  +     
m_extensionNamespaceURIs.push_back(&theConstructionContext.getPooledString(theURI));
   }
   
   
  @@ -172,7 +182,7 @@
   
        if (i != m_excludedResultPrefixes.end())
        {
  -             return &(*i).second;
  +             return (*i).second;
        }
        else
        {
  @@ -215,7 +225,7 @@
   
                if (i != m_namespaceAliases.end())
                {
  -                     return &(*i).second;
  +                     return (*i).second;
                }
                else
                {
  @@ -227,10 +237,33 @@
   
   
   void
  +NamespacesHandler::setNamespaceAlias(
  +                     StylesheetConstructionContext&  theConstructionContext,
  +                     const XalanDOMString&                   
theStylesheetNamespace,
  +                     const XalanDOMString&                   
theResultNamespace)
  +{
  +     m_namespaceAliases[theStylesheetNamespace] =
  +             &theConstructionContext.getPooledString(theResultNamespace);
  +}
  +
  +
  +
  +void
  +NamespacesHandler::addActivePrefix(
  +                     StylesheetConstructionContext&  theConstructionContext,
  +                     const XalanDOMString&                   thePrefix)
  +{
  +     m_activePrefixes.push_back(
  +             &theConstructionContext.getPooledString(thePrefix));
  +}
  +
  +
  +
  +void
   NamespacesHandler::processExcludeResultPrefixes(
  +             StylesheetConstructionContext&  theConstructionContext,
                const XalanDOMChar*                             theValue,
  -             const NamespacesStackType&              theCurrentNamespaces,
  -             StylesheetConstructionContext&  theConstructionContext)
  +             const NamespacesStackType&              theCurrentNamespaces)
   {
        StringTokenizer         tokenizer(
                                        theValue,
  @@ -259,7 +292,8 @@
                        theConstructionContext.error(theMessage);
                }
   
  -             m_excludedResultPrefixes[thePrefix] = *theNamespace;
  +             m_excludedResultPrefixes[thePrefix] =
  +                     &theConstructionContext.getPooledString(*theNamespace);
       }
   }
   
  @@ -267,9 +301,9 @@
   
   void
   NamespacesHandler::processExtensionElementPrefixes(
  +                     StylesheetConstructionContext&  theConstructionContext,
                        const XalanDOMChar*                             
theValue,
  -                     const NamespacesStackType&              
theCurrentNamespaces,
  -                     StylesheetConstructionContext&  theConstructionContext)
  +                     const NamespacesStackType&              
theCurrentNamespaces)
   {
        StringTokenizer         tokenizer(
                                        theValue,
  @@ -296,7 +330,9 @@
                        theConstructionContext.error(theMessage);
                }
   
  -             m_extensionNamespaceURIs.insert(*theNamespace);
  +             assert(theNamespace != 0);
  +
  +             
m_extensionNamespaceURIs.push_back(&theConstructionContext.getPooledString(*theNamespace));
       }
   }
   
  @@ -304,8 +340,9 @@
   
   void
   NamespacesHandler::postConstruction(
  -                     const XalanDOMString&           theElementName,
  -                     const NamespacesHandler*        parentNamespacesHandler)
  +                     StylesheetConstructionContext&  theConstructionContext,
  +                     const XalanDOMString&                   theElementName,
  +                     const NamespacesHandler*                
parentNamespacesHandler)
   {
        // Copy everything from the parent handler, if there is one...
        if (parentNamespacesHandler != 0)
  @@ -328,12 +365,12 @@
                substring(theElementName, thePrefix, 0, indexOfNSSep);
        }
   
  -     processExcludeResultPrefixes(thePrefix);
  +     processExcludeResultPrefixes(theConstructionContext, thePrefix);
   
        // $$ ToDo: Does this happen before or after exclude-result-prefixes?
        processNamespaceAliases();
   
  -     createResultAttributeNames();
  +     createResultAttributeNames(theConstructionContext);
   
        // We don't need these any more...
        m_activePrefixes.clear();
  @@ -367,7 +404,7 @@
   {
        // These are commone namespaces that are always excluded...
        if(equals(theURI, theXSLTNamespaceURI)
  -                     || m_extensionNamespaceURIs.find(theURI) != 
m_extensionNamespaceURIs.end()
  +                     || isExtensionNamespaceURI(theURI) == true
                        || equals(theURI, DOMServices::s_XMLNamespaceURI))
        {
                return true;
  @@ -401,7 +438,7 @@
   
                for(; i != theEnd; ++i)
                {
  -                     const NameSpaceExtended&        theNamespace = 
(*i).second;
  +                     const NamespaceExtended&        theNamespace = 
(*i).second;
   
                        const XalanDOMString&           thePrefix = 
theNamespace.getPrefix();
   
  @@ -463,7 +500,9 @@
   
        while(i != theEnd)
        {
  -             if (equals((*i).second, theNamespaceURI) == true)
  +             assert((*i).second != 0);
  +
  +             if (equals(*(*i).second, theNamespaceURI) == true)
                {
                        return true;
                }
  @@ -478,6 +517,33 @@
   
   
   
  +bool
  +NamespacesHandler::findString(
  +                     const XalanDOMString&                                   
theString,
  +                     const XalanDOMStringPointerVectorType&  theVector)
  +{
  +     const XalanDOMStringPointerVectorType::const_iterator   theEnd = 
theVector.end();
  +     XalanDOMStringPointerVectorType::const_iterator                 
theCurrent = theVector.begin();
  +
  +     while(theCurrent != theEnd)
  +     {
  +             assert(*theCurrent != 0);
  +
  +             const XalanDOMString* const             theCurrentString = 
*theCurrent;
  +
  +             if (theString == *theCurrentString)
  +             {
  +                     return true;
  +             }
  +
  +             ++theCurrent;
  +     }
  +
  +     return false;
  +}
  +
  +
  +
   void
   NamespacesHandler::clear()
   {
  @@ -511,7 +577,7 @@
   
   
   void
  -NamespacesHandler::createResultAttributeNames()
  +NamespacesHandler::createResultAttributeNames(StylesheetConstructionContext& 
theConstructionContext)
   {
        // Go through all of the result namespaces and create the attribute
        // name that will be used when they're written to the result tree.
  @@ -524,9 +590,11 @@
                NamespacesMapType::iterator             i =
                                m_namespaceDeclarations.begin();
   
  +             XalanDOMString  theName;
  +
                for(; i != theEnd; ++i)
                {
  -                     NameSpaceExtended&              theNamespace = 
(*i).second;
  +                     NamespaceExtended&              theNamespace = 
(*i).second;
   
                        const XalanDOMString&   thePrefix = 
theNamespace.getPrefix();
   
  @@ -534,15 +602,13 @@
                        {
                                // Create a name of the form xmlns:prefix, 
where "prefix" is the
                                // text of the prefix.
  -                             XalanDOMString  theName;
  -
                                // Reserve the appropriate amount of space in 
the string.
                                reserve(theName, 
DOMServices::s_XMLNamespaceWithSeparatorLength + length(thePrefix) + 1);
   
  -                             theName += 
DOMServices::s_XMLNamespaceWithSeparator;
  +                             theName = 
DOMServices::s_XMLNamespaceWithSeparator;
                                theName += thePrefix;
   
  -                             theNamespace.setResultAttributeName(theName);
  +                             
theNamespace.setResultAttributeName(theConstructionContext.getPooledString(theName));
                        }
                        else
                        {
  @@ -556,7 +622,9 @@
   
   
   void
  -NamespacesHandler::processExcludeResultPrefixes(const XalanDOMString&        
theElementPrefix)
  +NamespacesHandler::processExcludeResultPrefixes(
  +                     StylesheetConstructionContext&  theConstructionContext,
  +                     const XalanDOMString&                   
theElementPrefix)
   {
        if (m_excludedResultPrefixes.empty() == false)
        {
  @@ -580,7 +648,7 @@
                // Check for any result prefixes we should exclude...
                while(i != theEnd)
                {
  -                     const NameSpace&                theNamespace = 
(*i).second;
  +                     const NamespaceExtended&        theNamespace = 
(*i).second;
   
                        const XalanDOMString&   thePrefix = 
theNamespace.getPrefix();
                        const XalanDOMString&   theURI = theNamespace.getURI();
  @@ -588,16 +656,18 @@
                        // We can never exclude the prefix of our owner 
element, so
                        // check that first...
                        if (equals(thePrefix, theElementPrefix) == false &&
  -                             m_activePrefixes.find(thePrefix) == 
m_activePrefixes.end() &&
  +                             isActivePrefix(thePrefix) == false &&
                                (isExcludedNamespaceURI(theURI) == true ||
  -                              m_extensionNamespaceURIs.find(theURI) != 
m_extensionNamespaceURIs.end()))
  +                              isExtensionNamespaceURI(theURI) == true))
                        {
                                // It's excluded, so remove it...
                                theDeadEntries.push_back(i);
   
                                // Add it to the excluded prefixes, in case we 
need it later...
                                m_excludedResultPrefixes.insert(
  -                                             
ExcludedResultPrefixesMapType::value_type(thePrefix, theURI));
  +                                             
ExcludedResultPrefixesMapType::value_type(
  +                                                     thePrefix,
  +                                                     
&theConstructionContext.getPooledString(theURI)));
                        }
   
                        ++i;
  @@ -629,7 +699,7 @@
                // alias as appropriate...
                for(; i != theEnd; ++i)
                {
  -                     NameSpace&      theNamespace = (*i).second;
  +                     NamespaceExtended&      theNamespace = (*i).second;
   
                        const XalanDOMString&                   theURI =
                                                theNamespace.getURI();
  @@ -680,7 +750,7 @@
   
   
   void
  -NamespacesHandler::copyExtensionNamespaceURIs(const 
ExtensionNamespaceURISetType&    theExtensionNamespaceURIs)
  +NamespacesHandler::copyExtensionNamespaceURIs(const 
XalanDOMStringPointerVectorType& theExtensionNamespaceURIs)
   {
        if (theExtensionNamespaceURIs.empty() == false)
        {
  @@ -690,16 +760,21 @@
                }
                else
                {
  -                     const ExtensionNamespaceURISetType::const_iterator      
theEnd =
  +                     const XalanDOMStringPointerVectorType::const_iterator   
theEnd =
                                        theExtensionNamespaceURIs.end();
   
  -                     ExtensionNamespaceURISetType::const_iterator    i =
  +                     XalanDOMStringPointerVectorType::const_iterator i =
                                        theExtensionNamespaceURIs.begin();
   
                        // Add them in...
                        while(i != theEnd)
                        {
  -                             m_extensionNamespaceURIs.insert(*i);
  +                             assert(*i != 0);
  +
  +                             if (isExtensionNamespaceURI(**i) == false)
  +                             {
  +                                     m_extensionNamespaceURIs.push_back(*i);
  +                             }
   
                                ++i;
                        }
  
  
  
  1.13      +159 -64   xml-xalan/c/src/XSLT/NamespacesHandler.hpp
  
  Index: NamespacesHandler.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/NamespacesHandler.hpp,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- NamespacesHandler.hpp     5 Sep 2002 07:08:13 -0000       1.12
  +++ NamespacesHandler.hpp     26 Sep 2002 01:38:15 -0000      1.13
  @@ -92,25 +92,75 @@
   {
   public:
   
  -     class NameSpaceExtended : public NameSpace
  +     class NamespaceExtended
        {
        public:
   
  -             NameSpaceExtended(
  -                                     const XalanDOMString&   prefix = 
XalanDOMString(),
  -                                     const XalanDOMString&   uri = 
XalanDOMString()) :
  -                     NameSpace(prefix, uri),
  -                     m_resultAttributeName()
  +             NamespaceExtended() :
  +                     m_prefix(&s_emptyString),
  +                     m_uri(&s_emptyString),
  +                     m_resultAttributeName(&s_emptyString)
                {
                }
   
  -             NameSpaceExtended(const NameSpace&      theNamespace) :
  -                     NameSpace(theNamespace),
  -                     m_resultAttributeName()
  +             NamespaceExtended(
  +                                     const XalanDOMString&   prefix,
  +                                     const XalanDOMString&   uri) :
  +                     m_prefix(&prefix),
  +                     m_uri(&uri),
  +                     m_resultAttributeName(&s_emptyString)
                {
                }
   
                /**
  +              * Retrieve the prefix for namespace
  +              * 
  +              * @return prefix string
  +              */
  +             const XalanDOMString&
  +             getPrefix() const
  +             {
  +                     assert(m_prefix != 0);
  +
  +                     return *m_prefix;
  +             }
  +
  +             /**
  +              * Set the prefix for namespace
  +              * 
  +              * @param prefix The new prefix value
  +              */
  +             void
  +             setPrefix(const XalanDOMString&         prefix)
  +             {
  +                     m_prefix = &prefix;
  +             }
  +
  +             /**
  +              * Retrieve the URI for namespace
  +              * 
  +              * @return URI string
  +              */
  +             const XalanDOMString&
  +             getURI() const
  +             {
  +                     assert(m_uri != 0);
  +
  +                     return *m_uri;
  +             }
  +
  +             /**
  +              * Set the URI for namespace
  +              * 
  +              * @param uri The new uri value
  +              */
  +             void
  +             setURI(const XalanDOMString&    uri)
  +             {
  +                     m_uri = &uri;
  +             }
  +
  +             /**
                 * Retrieve the name of the result attribute.
                 * 
                 * @return name string
  @@ -118,7 +168,9 @@
                const XalanDOMString&
                getResultAttributeName() const
                {
  -                     return m_resultAttributeName;
  +                     assert(m_resultAttributeName != 0);
  +
  +                     return *m_resultAttributeName;
                }
   
                /**
  @@ -129,12 +181,18 @@
                void
                setResultAttributeName(const XalanDOMString&    name)
                {
  -                     m_resultAttributeName = name;
  +                     m_resultAttributeName = &name;
                }
   
        private:
   
  -             XalanDOMString  m_resultAttributeName;
  +             const XalanDOMString*   m_prefix;
  +
  +             const XalanDOMString*   m_uri;
  +
  +             const XalanDOMString*   m_resultAttributeName;
  +
  +             static const XalanDOMString             s_emptyString;
        };
   
        typedef XalanQName::NamespaceVectorType                         
NamespaceVectorType;
  @@ -142,33 +200,29 @@
   
   #if defined(XALAN_NO_NAMESPACES)
        typedef map<XalanDOMString,
  -                             XalanDOMString,
  +                             const XalanDOMString*,
                                less<XalanDOMString> >                          
        ExcludedResultPrefixesMapType;
   
        typedef map<XalanDOMString,
  -                             NameSpaceExtended,
  +                             NamespaceExtended,
                                less<XalanDOMString> >                          
        NamespacesMapType;
   
        typedef map<XalanDOMString,
  -                             XalanDOMString,
  +                             const XalanDOMString*,
                                less<XalanDOMString> >                          
        NamespaceAliasesMapType;
   
  -     typedef set<XalanDOMString,
  -                             less<XalanDOMString> >                          
        ExtensionNamespaceURISetType;
  -
  -     typedef set<XalanDOMString,
  -                             less<XalanDOMString> >                          
        ActivePrefixesSetType;
  +     typedef vector<const XalanDOMString*>                           
XalanDOMStringPointerVectorType;
   #else
  -     typedef std::map<XalanDOMString, XalanDOMString>        
ExcludedResultPrefixesMapType;
  -
        typedef std::map<XalanDOMString,
  -                                      NameSpaceExtended>                     
                NamespacesMapType;
  +                                      const XalanDOMString*>                 
        ExcludedResultPrefixesMapType;
   
  -     typedef std::map<XalanDOMString, XalanDOMString>        
NamespaceAliasesMapType;
  +     typedef std::map<XalanDOMString,
  +                                      NamespaceExtended>                     
                NamespacesMapType;
   
  -     typedef std::set<XalanDOMString>                                        
ExtensionNamespaceURISetType;
  +     typedef std::map<XalanDOMString,
  +                                      const XalanDOMString*>                 
        NamespaceAliasesMapType;
   
  -     typedef std::set<XalanDOMString>                                        
ActivePrefixesSetType;
  +     typedef std::vector<const XalanDOMString*>                      
XalanDOMStringPointerVectorType;
   #endif
   
        /**
  @@ -181,55 +235,57 @@
         * Create an instance namespace handler using the
         * current namespaces in effect.
         *
  +      * @param theConstructionContext The current construction context.
         * @param stylesheetNamespacesHandler The stylesheet's handler.
         * @param theCurrentNamespaces The stack of active namespace 
declarations.
         * @param theXSLTNamespaceURI The namespace URI for XSLT.
         */
        NamespacesHandler(
  -                     const NamespacesHandler&        
stylesheetNamespacesHandler,
  -                     const NamespacesStackType&      theCurrentNamespaces,
  -                     const XalanDOMString&           theXSLTNamespaceURI);
  -
  -     NamespacesHandler(const NamespacesHandler&      theSource);
  +                     StylesheetConstructionContext&  theConstructionContext,
  +                     const NamespacesHandler&                
stylesheetNamespacesHandler,
  +                     const NamespacesStackType&              
theCurrentNamespaces,
  +                     const XalanDOMString&                   
theXSLTNamespaceURI);
   
        ~NamespacesHandler();
   
        /**
         * Process an exclude-result-prefixes attribute.
         *
  +      * @param theConstructionContext The current construction context.
         * @param theValue The attribute's value.
         * @param theCurrentNamespaces The stack of active namespace 
declarations.
  -      * @param theConstructionContext The current construction context.
         */
        void
        processExcludeResultPrefixes(
  +                     StylesheetConstructionContext&  theConstructionContext,
                        const XalanDOMChar*                             
theValue,
  -                     const NamespacesStackType&              
theCurrentNamespaces,
  -                     StylesheetConstructionContext&  theConstructionContext);
  +                     const NamespacesStackType&              
theCurrentNamespaces);
   
        /**
         * Process an extension-element-prefixes attribute.
         *
  +      * @param theConstructionContext The current construction context.
         * @param theValue The attribute's value.
         * @param theCurrentNamespaces The stack of active namespace 
declarations.
  -      * @param theConstructionContext The current construction context.
         */
        void
        processExtensionElementPrefixes(
  +                     StylesheetConstructionContext&  theConstructionContext,
                        const XalanDOMChar*                             
theValue,
  -                     const NamespacesStackType&              
theCurrentNamespaces,
  -                     StylesheetConstructionContext&  theConstructionContext);
  +                     const NamespacesStackType&              
theCurrentNamespaces);
   
        /**
         * Notify the instance that the stylesheet is fully constructed.
         *
  +      * @param theConstructionContext The current construction context.
         * @param theElementName The name of the owning element.
         * @param parentNamespacesHandler The parent handler, if any.
         */
        void
        postConstruction(
  -                     const XalanDOMString&           theElementName = 
XalanDOMString(),
  -                     const NamespacesHandler*        parentNamespacesHandler 
= 0);
  +                     StylesheetConstructionContext&  theConstructionContext,
  +                     const XalanDOMString&                   theElementName 
= XalanDOMString(),
  +                     const NamespacesHandler*                
parentNamespacesHandler = 0);
   
        NamespacesHandler&
        operator=(const NamespacesHandler&      theRHS);
  @@ -249,13 +305,13 @@
        /**
         * Add a URI as an extension namespace prefixes.
         *
  +      * @param theConstructionContext The current construction context.
         * @param theURI The namespace URI.
         */
        void
  -     addExtensionNamespaceURI(const XalanDOMString&  theURI)
  -     {
  -             m_extensionNamespaceURIs.insert(theURI);
  -     }
  +     addExtensionNamespaceURI(
  +                     StylesheetConstructionContext&  theConstructionContext,
  +                     const XalanDOMString&   theURI);
   
        /**
         * Get the namespace URI for the given prefix.
  @@ -278,27 +334,26 @@
        /**
         * Set the namespace alias URI for the given namespace.
         *
  +      * @param theConstructionContext The current construction context.
         * @param theStylesheetNamespace The namespace as declared in the 
stylesheet.
         * @param theResultNamespace The namespace as it should appear in the 
result tree.
         */
        void
        setNamespaceAlias(
  -                     const XalanDOMString&   theStylesheetNamespace,
  -                     const XalanDOMString&   theResultNamespace)
  -     {
  -             m_namespaceAliases[theStylesheetNamespace] = theResultNamespace;
  -     }
  +                     StylesheetConstructionContext&  theConstructionContext,
  +                     const XalanDOMString&                   
theStylesheetNamespace,
  +                     const XalanDOMString&                   
theResultNamespace);
   
        /**
         * Add a prefix to the list of active prefixes.
         *
  +      * @param theConstructionContext The current construction context.
         * @param thePrefix The prefix that is active and requires a namespace 
declaration.
         */
        void
  -     addActivePrefix(const XalanDOMString&   thePrefix)
  -     {
  -             m_activePrefixes.insert(thePrefix);
  -     }
  +     addActivePrefix(
  +                     StylesheetConstructionContext&  theConstructionContext,
  +                     const XalanDOMString&                   thePrefix);
   
        /**
         * Copy the aliases from the given NamespacesHandler.
  @@ -355,17 +410,22 @@
   
        /**
         * Create all of the result attribute names.
  +      *
  +      * @param theConstructionContext The current construction context.
         */
        void
  -     createResultAttributeNames();
  +     createResultAttributeNames(StylesheetConstructionContext&       
theConstructionContext);
   
        /**
         * Process the exclude result prefix data.
         *
  +      * @param theConstructionContext The current construction context.
         * @param theElementPrefix The prefix of the owning element.
         */
        void
  -     processExcludeResultPrefixes(const XalanDOMString&      
theElementPrefix);
  +     processExcludeResultPrefixes(
  +                     StylesheetConstructionContext&  theConstructionContext,
  +                     const XalanDOMString&                   
theElementPrefix);
   
        /**
         * Process the namespace aliases data.
  @@ -382,12 +442,12 @@
        copyNamespaceAliases(const NamespaceAliasesMapType&             
theNamespaceAliases);
   
        /**
  -      * Copy the contents of the supplied set
  +      * Copy the contents of the supplied vector
         *
         * @param theExtensionNamespaceURIs The set to copy.
         */
        void
  -     copyExtensionNamespaceURIs(const ExtensionNamespaceURISetType&  
theExtensionNamespaceURIs);
  +     copyExtensionNamespaceURIs(const XalanDOMStringPointerVectorType&       
theExtensionNamespaceURIs);
   
        /**
         * Copy the contents of the supplied map
  @@ -413,32 +473,67 @@
                        const NameSpace&                        theNamespace) 
const;
   
        /**
  -      * Determine of a given namespace should be excluded as a result of
  +      * Determine if a given namespace should be excluded as a result of
         * an exclude-result-prefixes declaration.
         *
         * @param theNamespaceURI The namespace URI to check.
  -      * @return true of the namespace should be excluded, false if not.
  +      * @return true if the namespace should be excluded, false if not.
         */
        bool
        isExcludedNamespaceURI(const XalanDOMString&    theNamespaceURI) const;
   
  +     /**
  +      * Determine if a given URI is an extension namespace URI
  +      *
  +      * @param theNamespaceURI The namespace URI to check.
  +      * @return true if the namespace uri is an extension namespace URI, 
false if not.
  +      */
  +     bool
  +     isExtensionNamespaceURI(const XalanDOMString&   theNamespaceURI) const
  +     {
  +             return findString(theNamespaceURI, m_extensionNamespaceURIs);
  +     }
  +
  +     /**
  +      * Determine if a given prefix is active.
  +      *
  +      * @param thePrefix The prefix to check.
  +      * @return true if the prefix is active, false if not.
  +      */
  +     bool
  +     isActivePrefix(const XalanDOMString&    thePrefix) const
  +     {
  +             return findString(thePrefix, m_activePrefixes);
  +     }
  +
  +     /**
  +      * Determine if a given string is present in the vector
  +      *
  +      * @param theString The string to find.
  +      * @return true if the string is present, false if not.
  +      */
  +     static bool
  +     findString(
  +                     const XalanDOMString&                                   
theString,
  +                     const XalanDOMStringPointerVectorType&  theVector);
  +
        // Not implemented...
        bool
        operator==(const NamespacesHandler&) const;
   
        // Data members...
  -     ExcludedResultPrefixesMapType   m_excludedResultPrefixes;
  +     ExcludedResultPrefixesMapType           m_excludedResultPrefixes;
   
  -     NamespacesMapType                               m_namespaceDeclarations;
  +     NamespacesMapType                                       
m_namespaceDeclarations;
   
  -     ExtensionNamespaceURISetType    m_extensionNamespaceURIs;
  +     XalanDOMStringPointerVectorType         m_extensionNamespaceURIs;
   
  -     NamespaceAliasesMapType                 m_namespaceAliases;
  +     NamespaceAliasesMapType                         m_namespaceAliases;
   
  -     ActivePrefixesSetType                   m_activePrefixes;
  +     XalanDOMStringPointerVectorType         m_activePrefixes;
   
        // If true namespace aliases will be processed.  If false, they will 
not.
  -     bool                                                    
m_processAliases;
  +     bool                                                            
m_processAliases;
   };
   
   
  
  
  
  1.6       +113 -2    xml-xalan/c/src/XSLT/ResultTreeFrag.cpp
  
  Index: ResultTreeFrag.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ResultTreeFrag.cpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ResultTreeFrag.cpp        23 Feb 2002 03:32:00 -0000      1.5
  +++ ResultTreeFrag.cpp        26 Sep 2002 01:38:15 -0000      1.6
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -70,11 +70,16 @@
   const XalanDOMString ResultTreeFrag::s_emptyString;
   
   
  +static const unsigned int    dummyPos = ~0u;
  +
   
   ResultTreeFrag::ResultTreeFrag(XalanSourceTreeDocumentFragment*              
theDocumentFragment) :
        ResultTreeFragBase(),
        XalanNodeList(),
  -     m_documentFragment(theDocumentFragment)
  +     m_documentFragment(theDocumentFragment),
  +     m_length(dummyPos),
  +     m_lastIndex(dummyPos),
  +     m_lastNode(0)
   {
   }
   
  @@ -404,6 +409,38 @@
   
   
   
  +void
  +ResultTreeFrag::setDocumentFragment(XalanSourceTreeDocumentFragment* 
theDocumentFragment)
  +{
  +     m_documentFragment = theDocumentFragment;
  +     m_length = dummyPos;
  +     m_lastIndex = dummyPos;
  +     m_lastNode = 0;
  +}
  +
  +
  +
  +#if !defined(NDEBUG)
  +const XalanNode*
  +itemDebug(
  +                     const XalanDocumentFragment*    theDocumentFragment,
  +                     unsigned int                                    index)
  +{
  +     assert(theDocumentFragment != 0);
  +
  +     const XalanNode*        theCurrentChild = 
theDocumentFragment->getFirstChild();
  +
  +     for(unsigned int i = 0; i < index && theCurrentChild != 0; ++i)
  +     {
  +             theCurrentChild = theCurrentChild->getNextSibling();
  +     }
  +
  +     return theCurrentChild;
  +}
  +
  +#endif
  +
  +
   XalanNode*
   ResultTreeFrag::item(unsigned int    index) const
   {
  @@ -413,6 +450,62 @@
        {
                return 0;
        }
  +     else if (index == m_lastIndex)
  +     {
  +             assert(itemDebug(m_documentFragment, index) == m_lastNode);
  +
  +             return m_lastNode;
  +     }
  +     else if (m_lastIndex != dummyPos && index == m_lastIndex + 1)
  +     {
  +#if defined(XALAN_NO_MUTABLE)
  +             ((ResultTreeFrag*)this)->m_lastIndex = index;
  +#else
  +             m_lastIndex = index;
  +#endif
  +
  +             if (m_lastNode != 0)
  +             {
  +#if defined(XALAN_NO_MUTABLE)
  +                     ((ResultTreeFrag*)this)->m_lastNode = 
m_lastNode->getNextSibling()
  +#else
  +                     m_lastNode = m_lastNode->getNextSibling();
  +#endif
  +             }
  +             else
  +             {
  +#if defined(XALAN_NO_MUTABLE)
  +                     ((ResultTreeFrag*)this)->m_lastNode = 0
  +#else
  +                     m_lastNode = 0;
  +#endif
  +             }
  +
  +             assert(itemDebug(m_documentFragment, index) == m_lastNode);
  +
  +             return m_lastNode;
  +     }
  +     else if (index > m_lastIndex)
  +     {
  +             XalanNode*      theCurrentChild = m_lastNode;
  +
  +             for(unsigned int i = m_lastIndex; i < index && theCurrentChild 
!= 0; ++i)
  +             {
  +                     theCurrentChild = theCurrentChild->getNextSibling();
  +             }
  +
  +#if defined(XALAN_NO_MUTABLE)
  +             ((ResultTreeFrag*)this)->m_lastIndex = index;
  +             ((ResultTreeFrag*)this)->m_lastNode = theCurrentChild
  +#else
  +             m_lastIndex = index;
  +             m_lastNode = theCurrentChild;
  +#endif
  +
  +             assert(itemDebug(m_documentFragment, index) == m_lastNode);
  +
  +             return m_lastNode;
  +     }
        else
        {
                XalanNode*      theCurrentChild = 
m_documentFragment->getFirstChild();
  @@ -422,6 +515,14 @@
                        theCurrentChild = theCurrentChild->getNextSibling();
                }
   
  +#if defined(XALAN_NO_MUTABLE)
  +             ((ResultTreeFrag*)this)->m_lastIndex = index;
  +             ((ResultTreeFrag*)this)->m_lastNode = theCurrentChild
  +#else
  +             m_lastIndex = index;
  +             m_lastNode = theCurrentChild;
  +#endif
  +
                return theCurrentChild;
        }
   }
  @@ -435,6 +536,10 @@
        {
                return 0;
        }
  +     else if (m_length != dummyPos)
  +     {
  +             return m_length;
  +     }
        else
        {
                unsigned int    theLength = 0;
  @@ -446,6 +551,12 @@
                        ++theLength;
                        theCurrentChild = theCurrentChild->getNextSibling();
                }
  +
  +#if defined(XALAN_NO_MUTABLE)
  +             ((ResultTreeFrag*)this)->m_length = theLength;
  +#else
  +             m_length = theLength;
  +#endif
   
                return theLength;
        }
  
  
  
  1.4       +9 -5      xml-xalan/c/src/XSLT/ResultTreeFrag.hpp
  
  Index: ResultTreeFrag.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ResultTreeFrag.hpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ResultTreeFrag.hpp        23 Feb 2002 03:32:00 -0000      1.3
  +++ ResultTreeFrag.hpp        26 Sep 2002 01:38:15 -0000      1.4
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -219,10 +219,7 @@
        }
   
        void
  -     setDocumentFragment(XalanSourceTreeDocumentFragment*    
theDocumentFragment)
  -     {
  -             m_documentFragment = theDocumentFragment;
  -     }
  +     setDocumentFragment(XalanSourceTreeDocumentFragment*    
theDocumentFragment);
   
   private:
   
  @@ -244,6 +241,13 @@
   
        // Data members...
        XalanSourceTreeDocumentFragment*        m_documentFragment;
  +
  +     // These are for caching results...
  +     mutable unsigned int                            m_length;
  +
  +     mutable unsigned int                            m_lastIndex;
  +
  +     mutable XalanNode*                                      m_lastNode;
   
        static const XalanDOMString             s_emptyString;
   };
  
  
  
  1.81      +9 -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.80
  retrieving revision 1.81
  diff -u -r1.80 -r1.81
  --- Stylesheet.cpp    24 Sep 2002 01:42:35 -0000      1.80
  +++ Stylesheet.cpp    26 Sep 2002 01:38:15 -0000      1.81
  @@ -456,7 +456,7 @@
        }
   
        // Call postConstruction() on our own namespaces handler...
  -     m_namespacesHandler.postConstruction();
  +     m_namespacesHandler.postConstruction(constructionContext);
   
   
        {
  @@ -1213,12 +1213,13 @@
   
   void
   Stylesheet::addExtensionNamespace(
  -                     const XalanDOMString&   uri,
  -                     ExtensionNSHandler*             nsh)
  +                     StylesheetConstructionContext&  theConstructionContext,
  +                     const XalanDOMString&                   uri,
  +                     ExtensionNSHandler*                             nsh)
   {
        
m_extensionNamespaces.insert(ExtensionNamespacesMapType::value_type(uri, nsh));
   
  -     m_namespacesHandler.addExtensionNamespaceURI(uri);
  +     m_namespacesHandler.addExtensionNamespaceURI(theConstructionContext, 
uri);
   }
   
   
  @@ -1358,7 +1359,10 @@
                // $$$ ToDo: Enable other code.  Perhaps an error?
                m_prefixAliases[*stylesheetNamespace] = *resultNamespace;
   
  -             m_namespacesHandler.setNamespaceAlias(*stylesheetNamespace, 
*resultNamespace);
  +             m_namespacesHandler.setNamespaceAlias(
  +                             constructionContext,
  +                             *stylesheetNamespace,
  +                             *resultNamespace);
   #else
                const PrefixAliasesMapType::iterator    i =
                        m_prefixAliases.find(*stylesheetNamespace);
  
  
  
  1.48      +8 -7      xml-xalan/c/src/XSLT/Stylesheet.hpp
  
  Index: Stylesheet.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/Stylesheet.hpp,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- Stylesheet.hpp    24 Jul 2002 23:19:43 -0000      1.47
  +++ Stylesheet.hpp    26 Sep 2002 01:38:15 -0000      1.48
  @@ -381,19 +381,19 @@
        /**
         * See if a namespace should be excluded.
         * 
  -      * @param theValue the prefix of the namespace.
         * @param theConstructionContext the current construction context.
  +      * @param theValue the prefix of the namespace.
         * @return
         */
        void
        processExcludeResultPrefixes(
  -             const XalanDOMChar*                             theValue,
  -             StylesheetConstructionContext&  theConstructionContext)
  +             StylesheetConstructionContext&  theConstructionContext,
  +             const XalanDOMChar*                             theValue)
        {
                m_namespacesHandler.processExcludeResultPrefixes(
  +                             theConstructionContext,
                                theValue,
  -                             m_namespaces,
  -                             theConstructionContext);
  +                             m_namespaces);
        }
   
        /**
  @@ -879,8 +879,9 @@
         */
        void
        addExtensionNamespace(
  -                     const XalanDOMString&   uri,
  -                     ExtensionNSHandler*     nsh);
  +                     StylesheetConstructionContext&  theConstructionContext,
  +                     const XalanDOMString&                   uri,
  +                     ExtensionNSHandler*                     nsh);
   
        /**
         * Return the handler for a given extension namespace.
  
  
  
  1.90      +2 -2      xml-xalan/c/src/XSLT/StylesheetHandler.cpp
  
  Index: StylesheetHandler.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetHandler.cpp,v
  retrieving revision 1.89
  retrieving revision 1.90
  diff -u -r1.89 -r1.90
  --- StylesheetHandler.cpp     24 Sep 2002 06:57:42 -0000      1.89
  +++ StylesheetHandler.cpp     26 Sep 2002 01:38:15 -0000      1.90
  @@ -1109,7 +1109,7 @@
   
                if(equals(aname, Constants::ATTRNAME_EXCLUDE_RESULT_PREFIXES))
                {
  -                     
m_stylesheet.processExcludeResultPrefixes(atts.getValue(i), 
m_constructionContext);
  +                     
m_stylesheet.processExcludeResultPrefixes(m_constructionContext, 
atts.getValue(i));
                }
                else if(equals(aname, 
Constants::ATTRNAME_EXTENSIONELEMENTPREFIXES))
                {
  @@ -1126,7 +1126,7 @@
   
                                ExtensionNSHandler* const       nsh = new 
ExtensionNSHandler(extns);
   
  -                             m_stylesheet.addExtensionNamespace(extns, nsh);
  +                             
m_stylesheet.addExtensionNamespace(m_constructionContext, extns, nsh);
                        }
                }
                else if(equals(aname, Constants::ATTRNAME_ID))
  
  
  
  1.64      +20 -4     xml-xalan/c/src/XSLT/StylesheetRoot.cpp
  
  Index: StylesheetRoot.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetRoot.cpp,v
  retrieving revision 1.63
  retrieving revision 1.64
  diff -u -r1.63 -r1.64
  --- StylesheetRoot.cpp        24 Sep 2002 06:57:42 -0000      1.63
  +++ StylesheetRoot.cpp        26 Sep 2002 01:38:16 -0000      1.64
  @@ -730,6 +730,8 @@
                        StylesheetExecutionContext&             
executionContext,
                        KeyTablesTableType&                     theKeysTable) 
const
   {
  +     assert(nodelist.empty() == true || nodelist.getDocumentOrder() == true);
  +
        if(m_needToBuildKeysTable == true)
        {
                assert(m_keyDeclarations.empty() == false);
  @@ -739,9 +741,16 @@
   
                if (i != theKeysTable.end())
                {
  -                     const NodeRefListBase&  nl = 
(*i).second->getNodeSetByKey(qname, ref);
  +                     const MutableNodeRefList&       nl = 
(*i).second->getNodeSetByKey(qname, ref);
   
  -                     nodelist.addNodesInDocOrder(nl, executionContext);
  +                     if (nodelist.empty() == true)
  +                     {
  +                             nodelist = nl;
  +                     }
  +                     else
  +                     {
  +                             nodelist.addNodesInDocOrder(nl, 
executionContext);
  +                     }
                }
                else
                {
  @@ -754,9 +763,16 @@
   
                        theKeysTable[doc] = kt;
   
  -                     const NodeRefListBase&  nl = kt->getNodeSetByKey(qname, 
ref);
  +                     const MutableNodeRefList&       nl = 
kt->getNodeSetByKey(qname, ref);
   
  -                     nodelist.addNodesInDocOrder(nl, executionContext);
  +                     if (nodelist.empty() == true)
  +                     {
  +                             nodelist = nl;
  +                     }
  +                     else
  +                     {
  +                             nodelist.addNodesInDocOrder(nl, 
executionContext);
  +                     }
                }
        }
   }
  
  
  

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

Reply via email to