dbertoni    2002/09/20 18:24:21

  Modified:    c/src/XPath NameSpace.hpp XalanQNameByReference.cpp
                        XalanQNameByReference.hpp XalanQNameByValue.cpp
                        XalanQNameByValue.hpp XPath.hpp
                        XPathExecutionContext.hpp
                        XPathExecutionContextDefault.cpp
                        XPathExecutionContextDefault.hpp
  Log:
  Performance tweaks and new functionality.
  
  Revision  Changes    Path
  1.7       +31 -3     xml-xalan/c/src/XPath/NameSpace.hpp
  
  Index: NameSpace.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/NameSpace.hpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- NameSpace.hpp     2 Nov 2000 01:45:58 -0000       1.6
  +++ NameSpace.hpp     21 Sep 2002 01:24:21 -0000      1.7
  @@ -147,8 +147,36 @@
        }
   
        /**
  -      * Equality operator, necessary because DOMString::==()
  -      * has screwy semantics.
  +      * Set the URI for namespace
  +      * 
  +      * @param uri The new uri value
  +      */
  +     void
  +     setURI(const XalanDOMChar*      uri)
  +     {
  +             assert(uri != 0);
  +
  +             m_uri = uri;
  +     }
  +
  +     /**
  +      * Set the URI for namespace
  +      * 
  +      * @param uri The new uri value
  +      * @param len The length of the uri
  +      */
  +     void
  +     setURI(
  +                     const XalanDOMChar*                     uri,
  +                     XalanDOMString::size_type       len)
  +     {
  +             assert(uri != 0);
  +
  +             m_uri.assign(uri, len);
  +     }
  +
  +     /**
  +      * Equality operator
         *
         * @param theRHS namespace to compare
         */
  @@ -163,7 +191,7 @@
   
        XalanDOMString  m_prefix;
   
  -     XalanDOMString  m_uri; // if length is 0, then Element namespace is 
empty.
  +     XalanDOMString  m_uri;
   };
   
   
  
  
  
  1.2       +9 -0      xml-xalan/c/src/XPath/XalanQNameByReference.cpp
  
  Index: XalanQNameByReference.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XalanQNameByReference.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XalanQNameByReference.cpp 13 Aug 2001 17:08:01 -0000      1.1
  +++ XalanQNameByReference.cpp 21 Sep 2002 01:24:21 -0000      1.2
  @@ -79,6 +79,15 @@
   
   
   
  +XalanQNameByReference::XalanQNameByReference(const XalanDOMString&   
theLocalPart) :
  +     XalanQName(),
  +     m_namespace(&s_emptyString),
  +     m_localpart(&theLocalPart)
  +{
  +}
  +
  +
  +
   XalanQNameByReference::XalanQNameByReference(const XalanQName&       
theQName) :
        XalanQName(),
        m_namespace(&theQName.getNamespace()),
  
  
  
  1.3       +9 -0      xml-xalan/c/src/XPath/XalanQNameByReference.hpp
  
  Index: XalanQNameByReference.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XalanQNameByReference.hpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XalanQNameByReference.hpp 14 Sep 2001 20:04:46 -0000      1.2
  +++ XalanQNameByReference.hpp 21 Sep 2002 01:24:21 -0000      1.3
  @@ -92,6 +92,15 @@
                        const XalanDOMString&   theLocalPart);
   
        /**
  +      * Construct a XalanQNameByReference, with the supplied local part.
  +      * The instance keeps only a _reference_ to the string, to avoid making 
a
  +      * copy.
  +      *
  +      * @param theLocalPart local part string
  +      */
  +     XalanQNameByReference(const XalanDOMString&             theLocalPart);
  +
  +     /**
         * Construct a XalanQNameByReference, from the supplied XalanQName.  
The instance
         * keeps only a _reference_ to the string, to avoid making a copy.
         *
  
  
  
  1.7       +130 -23   xml-xalan/c/src/XPath/XalanQNameByValue.cpp
  
  Index: XalanQNameByValue.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XalanQNameByValue.cpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XalanQNameByValue.cpp     6 May 2002 05:26:59 -0000       1.6
  +++ XalanQNameByValue.cpp     21 Sep 2002 01:24:21 -0000      1.7
  @@ -119,7 +119,12 @@
        m_namespace(),
        m_localpart()
   {
  -     initialize(c_wstr(qname), namespaces, locator, fUseDefault);
  +     initialize(
  +             c_wstr(qname),
  +             length(qname),
  +             namespaces,
  +             locator,
  +             fUseDefault);
   }
   
   
  @@ -134,7 +139,12 @@
   {
        assert(qname != 0);
   
  -     initialize(qname, namespaces, locator, fUseDefault);
  +     initialize(
  +             qname,
  +             length(qname),
  +             namespaces,
  +             locator,
  +             fUseDefault);
   }
   
   
  @@ -150,7 +160,11 @@
   {
        ElementPrefixResolverProxy      theProxy(namespaceContext, envSupport, 
domSupport);
   
  -     resolvePrefix(qname, &theProxy, locator);
  +     resolvePrefix(
  +             c_wstr(qname),
  +             length(qname),
  +             &theProxy,
  +             locator);
   }
   
   
  @@ -162,7 +176,11 @@
        m_namespace(),
        m_localpart()
   {
  -     resolvePrefix(qname, theResolver, locator);
  +     resolvePrefix(
  +             c_wstr(qname),
  +             length(qname),
  +             theResolver,
  +             locator);
   }
   
   
  @@ -190,6 +208,74 @@
   
   
   void
  +XalanQNameByValue::set(
  +                     const XalanDOMString&           qname,
  +                     const NamespacesStackType&      namespaces,
  +                     const Locator*                          locator,
  +                     bool                                            
fUseDefault)
  +{
  +     initialize(
  +             c_wstr(qname),
  +             length(qname),
  +             namespaces,
  +             locator,
  +             fUseDefault);
  +}
  +
  +
  +
  +void
  +XalanQNameByValue::set(
  +                     const XalanDOMChar*                     qname,
  +                     const NamespacesStackType&      namespaces,
  +                     const Locator*                          locator,
  +                     bool                                            
fUseDefault)
  +{
  +     assert(qname != 0);
  +
  +     initialize(
  +             qname,
  +             length(qname),
  +             namespaces,
  +             locator,
  +             fUseDefault);
  +}
  +
  +
  +
  +void
  +XalanQNameByValue::set(
  +                     const XalanDOMString&   qname,
  +                     const PrefixResolver*   theResolver,
  +                     const Locator*                  locator)
  +{
  +     resolvePrefix(
  +             c_wstr(qname),
  +             length(qname),
  +             theResolver,
  +             locator);
  +}
  +
  +
  +
  +void
  +XalanQNameByValue::set(
  +                     const XalanDOMChar*             qname,
  +                     const PrefixResolver*   theResolver,
  +                     const Locator*                  locator)
  +{
  +     assert(qname != 0);
  +
  +     resolvePrefix(
  +             qname,
  +             length(qname),
  +             theResolver,
  +             locator);
  +}
  +
  +
  +
  +void
   throwException(
                        const XalanDOMString&   theMessage,
                        const Locator*                  theLocator)
  @@ -210,6 +296,7 @@
   void
   XalanQNameByValue::initialize(
                        const XalanDOMChar*                     qname,
  +                     XalanDOMString::size_type       len,
                        const NamespacesStackType&      namespaces,
                        const Locator*                          locator,
                        bool                                            
fUseDefault)
  @@ -220,19 +307,27 @@
        {
                throwException(TranscodeFromLocalCodePage("A prefix of length 0 
was detected"), locator);
        }
  -     else if(indexOfNSSep < length(qname))
  +     else if(indexOfNSSep < len)
        {
  -             const XalanDOMString    prefix(qname, indexOfNSSep);
  +             // Reserve some space for the local part right now, and
  +             // use it as a temporary for the prefix.
  +             m_localpart.reserve(len);
  +
  +             m_localpart.assign(qname, indexOfNSSep);
  +
  +             if(::equals(m_localpart, DOMServices::s_XMLNamespace))
  +             {
  +                     ::clear(m_localpart);
   
  -             if(::equals(prefix, DOMServices::s_XMLNamespace))
                        return;
  +             }
   
                const XalanDOMString* const             theNamespace = 
  -                             getNamespaceForPrefix(namespaces, prefix);
  +                                     getNamespaceForPrefix(namespaces, 
m_localpart);
   
                if(theNamespace == 0 || 0 == length(*theNamespace))
                {
  -                     throwException(TranscodeFromLocalCodePage("Prefix must 
resolve to a namespace: ") + prefix, locator);
  +                     throwException(TranscodeFromLocalCodePage("Prefix must 
resolve to a namespace: ") + m_localpart, locator);
                }
                else
                {
  @@ -243,10 +338,14 @@
        }
        else
        {
  -             if (fUseDefault == true)
  +             if (fUseDefault == false)
  +             {
  +                     m_namespace.clear();
  +             }
  +             else
                {
                        const XalanDOMString* const             theNamespace = 
  -                                     getNamespaceForPrefix(namespaces, 
s_emptyString);
  +                                             
getNamespaceForPrefix(namespaces, s_emptyString);
   
                        if(theNamespace != 0 && 0 != length(*theNamespace))
                        {
  @@ -262,42 +361,50 @@
   
   void
   XalanQNameByValue::resolvePrefix(
  -                     const XalanDOMString&   qname,
  -                     const PrefixResolver*   theResolver,
  -                     const Locator*                  locator)
  +                     const XalanDOMChar*                     qname,
  +                     XalanDOMString::size_type       theLength,
  +                     const PrefixResolver*           theResolver,
  +                     const Locator*                          locator)
   {
        const XalanDOMString::size_type         indexOfNSSep = indexOf(qname, 
XalanUnicode::charColon);
  -     const XalanDOMString::size_type         theLength = length(qname);
   
        if(indexOfNSSep >= theLength)
        {
  -             m_localpart = qname;
  +             m_localpart.assign(qname, theLength);
  +
  +             ::clear(m_namespace);
        }
        else
        {
  -             const XalanDOMString    prefix(qname, 0, indexOfNSSep);
  +             // Reserve some space for the local part right now, and
  +             // use it as a temporary for the prefix.
  +             m_localpart.reserve(theLength);
  +
  +             m_localpart.assign(qname, indexOfNSSep);
   
  -             if(::equals(prefix, DOMServices::s_XMLString))
  +             if(::equals(m_localpart, DOMServices::s_XMLString))
                {
                        m_namespace = DOMServices::s_XMLNamespaceURI;
                }
                // The default namespace is not resolved.
  -             else if(::equals(prefix, DOMServices::s_XMLNamespace))
  +             else if(::equals(m_localpart, DOMServices::s_XMLNamespace))
                {
  +                     ::clear(m_localpart);
  +
                        return;
                }
                else if (theResolver == 0)
                {
                        throwException(
                                TranscodeFromLocalCodePage("Unable to resolve 
prefix '") +
  -                                     prefix +
  +                                     m_localpart +
                                        TranscodeFromLocalCodePage("'"),
                                locator);
                }
                else
                {
                        const XalanDOMString* const             theNamespace =
  -                             theResolver->getNamespaceForPrefix(prefix);
  +                             theResolver->getNamespaceForPrefix(m_localpart);
   
                        if (theNamespace != 0)
                        {
  @@ -309,11 +416,11 @@
                {
                        throwException(
                                TranscodeFromLocalCodePage("The prefix '") +
  -                                     prefix +
  +                                     m_localpart +
                                        TranscodeFromLocalCodePage("' must 
resolve to a namespace."),
                                locator);
                }
   
  -             m_localpart.assign(qname, indexOfNSSep + 1, theLength - 
(indexOfNSSep + 1));
  +             m_localpart.assign(qname + indexOfNSSep + 1, theLength - 
(indexOfNSSep + 1));
        }
   }
  
  
  
  1.7       +70 -5     xml-xalan/c/src/XPath/XalanQNameByValue.hpp
  
  Index: XalanQNameByValue.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XalanQNameByValue.hpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XalanQNameByValue.hpp     2 Sep 2002 17:55:43 -0000       1.6
  +++ XalanQNameByValue.hpp     21 Sep 2002 01:24:21 -0000      1.7
  @@ -111,7 +111,7 @@
   
        /**
         * Construct a XalanQNameByValue from a string, resolving the prefix 
using the given
  -      * namespace vector stack. The default namespace is not resolved.
  +      * namespace vector stack.
         *
         * @param qname       QName string
         * @param namespaces  namespace vector stack to use
  @@ -126,7 +126,7 @@
   
        /**
         * Construct a XalanQNameByValue from a string, resolving the prefix 
using the given
  -      * namespace vector stack. The default namespace is not resolved.
  +      * namespace vector stack.
         *
         * @param qname       QName string
         * @param namespaces  namespace vector stack to use
  @@ -211,6 +211,69 @@
        }
   
        /**
  +      * Set the local part and namespace URI of a XalanQNameByValue from
  +      * a string, resolving the prefix using the given namespace vector
  +      * stack.
  +      *
  +      * @param qname       QName string
  +      * @param namespaces  namespace vector stack to use
  +      * @param locator     The Locator instance for error reporting, if any
  +      * @param fUseDefault If true, then elements with no prefix will have 
the default namespace URI, if there is one.
  +      */
  +     void
  +     set(
  +                     const XalanDOMString&           qname,
  +                     const NamespacesStackType&      namespaces,
  +                     const Locator*                          locator = 0,
  +                     bool                                            
fUseDefault = false);
  +
  +     /**
  +      * Set the local part and namespace URI of a XalanQNameByValue from
  +      * a string, resolving the prefix using the given namespace vector
  +      * stack.
  +      *
  +      * @param qname       QName string
  +      * @param namespaces  namespace vector stack to use
  +      * @param locator     The Locator instance for error reporting, if any
  +      * @param fUseDefault If true, then elements with no prefix will have 
the default namespace URI, if there is one.
  +      */
  +     void
  +     set(
  +                     const XalanDOMChar*                     qname,
  +                     const NamespacesStackType&      namespaces,
  +                     const Locator*                          locator = 0,
  +                     bool                                            
fUseDefault = false);
  +
  +     /**
  +      * Set the local part and namespace URI of a XalanQNameByValue from
  +      * a string, resolving the prefix using the resolver provided.  The
  +      * default namespace is not resolved.
  +      *
  +      * @param qname       QName string
  +      * @param theResolver prefix resolver to use
  +      * @param locator     The Locator instance for error reporting, if any
  +      */
  +     void
  +     set(
  +                     const XalanDOMString&   qname,
  +                     const PrefixResolver*   theResolver = 0,
  +                     const Locator*                  locator = 0);
  +
  +     /**
  +      * Set the local part and namespace URI of a XalanQNameByValue from
  +      * a string, resolving the prefix using the resolver provided.  The
  +      * default namespace is not resolved.
  +      *
  +      * @param qname       QName string
  +      * @param theResolver prefix resolver to use
  +      * @param locator     The Locator instance for error reporting, if any
  +      */
  +     void
  +     set(
  +                     const XalanDOMChar*             qname,
  +                     const PrefixResolver*   theResolver = 0,
  +                     const Locator*                  locator = 0);
  +     /**
         * Clear the instance.
         */
        void
  @@ -243,15 +306,17 @@
        void
        initialize(
                        const XalanDOMChar*                     qname,
  +                     XalanDOMString::size_type       len,
                        const NamespacesStackType&      namespaces,
                        const Locator*                          locator,
                        bool                                            
fUseDefault);
   
        void
        resolvePrefix(
  -                     const XalanDOMString&   qname,
  -                     const PrefixResolver*   theResolver,
  -                     const Locator*                  locator);
  +                     const XalanDOMChar*                     qname,
  +                     XalanDOMString::size_type       theLength,
  +                     const PrefixResolver*           theResolver,
  +                     const Locator*                          locator);
   
   
        // Data members...
  
  
  
  1.34      +0 -6      xml-xalan/c/src/XPath/XPath.hpp
  
  Index: XPath.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPath.hpp,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- XPath.hpp 5 Sep 2002 01:38:03 -0000       1.33
  +++ XPath.hpp 21 Sep 2002 01:24:21 -0000      1.34
  @@ -488,12 +488,6 @@
   protected:
   
        /**
  -      * createXLocatorHandler.
  -      */
  -     XLocator*
  -     createXLocatorHandler() const;
  -
  -     /**
         * Computes the union of its operands which must be node-sets.
         * @param context The current source tree context node.
         * @param opPos The current position in the m_opMap array.
  
  
  
  1.49      +23 -5     xml-xalan/c/src/XPath/XPathExecutionContext.hpp
  
  Index: XPathExecutionContext.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExecutionContext.hpp,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- XPathExecutionContext.hpp 3 Apr 2002 05:08:34 -0000       1.48
  +++ XPathExecutionContext.hpp 21 Sep 2002 01:24:21 -0000      1.49
  @@ -85,10 +85,10 @@
   
   
   
  +class Locator;
   class XalanDecimalFormatSymbols;
   class PrefixResolver;
   class XalanQName;
  -class XLocator;
   class XMLURL;
   class XObject;
   class XObjectPtr;
  @@ -500,19 +500,37 @@
         * Given a valid element key, return the corresponding node list.
         *
         * @param doc              source document
  -      * @param name             name of the key, which must match the 'name'
  +      * @param name             qname of the key, which must match the 'name'
         *                         attribute on xsl:key
         * @param ref              value that must match the value found by the
         *                         'match' attribute on xsl:key
  -      * @param resolver         resolver for namespace resolution
         * @param nodelist         A node list to contain the nodes found
         */
        virtual void
        getNodeSetByKey(
  -                     XalanNode*                              doc,
  +                     XalanDocument*                  doc,
  +                     const XalanQName&               qname,
  +                     const XalanDOMString&   ref,
  +                     MutableNodeRefList&             nodelist) = 0;
  +
  +     /**
  +      * Given a valid element key, return the corresponding node list.
  +      *
  +      * @param doc              source document
  +      * @param name             name of the key, which must match the 'name'
  +      *                         attribute on xsl:key.  Will be resolved to a
  +      *                         qname using the provided resolver.
  +      * @param ref              value that must match the value found by the
  +      *                         'match' attribute on xsl:key
  +      * @param locator          The Locator to use for error reporting.  Can 
be 0.
  +      * @param nodelist         A node list to contain the nodes found
  +      */
  +     virtual void
  +     getNodeSetByKey(
  +                     XalanDocument*                  doc,
                        const XalanDOMString&   name,
                        const XalanDOMString&   ref,
  -                     const PrefixResolver&   resolver,
  +                     const Locator*                  locator,
                        MutableNodeRefList&             nodelist) = 0;
   
        /**
  
  
  
  1.52      +13 -2     xml-xalan/c/src/XPath/XPathExecutionContextDefault.cpp
  
  Index: XPathExecutionContextDefault.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExecutionContextDefault.cpp,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- XPathExecutionContextDefault.cpp  10 Jul 2002 00:40:24 -0000      1.51
  +++ XPathExecutionContextDefault.cpp  21 Sep 2002 01:24:21 -0000      1.52
  @@ -347,10 +347,21 @@
   
   void
   XPathExecutionContextDefault::getNodeSetByKey(
  -                     XalanNode*                              /* doc */,
  +                     XalanDocument*                  /* doc */,
  +                     const XalanQName&               /* qname */,
  +                     const XalanDOMString&   /* ref */,
  +                     MutableNodeRefList&             /* nodelist */)
  +{
  +}
  +
  +
  +
  +void
  +XPathExecutionContextDefault::getNodeSetByKey(
  +                     XalanDocument*                  /* doc */,
                        const XalanDOMString&   /* name */,
                        const XalanDOMString&   /* ref */,
  -                     const PrefixResolver&   /* resolver */,
  +                     const Locator*                  /* locator */,
                        MutableNodeRefList&             /* nodelist */)
   {
   }
  
  
  
  1.44      +9 -2      xml-xalan/c/src/XPath/XPathExecutionContextDefault.hpp
  
  Index: XPathExecutionContextDefault.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExecutionContextDefault.hpp,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- XPathExecutionContextDefault.hpp  3 Apr 2002 05:08:34 -0000       1.43
  +++ XPathExecutionContextDefault.hpp  21 Sep 2002 01:24:21 -0000      1.44
  @@ -249,10 +249,17 @@
   
        virtual void
        getNodeSetByKey(
  -                     XalanNode*                              doc,
  +                     XalanDocument*                  doc,
  +                     const XalanQName&               qname,
  +                     const XalanDOMString&   ref,
  +                     MutableNodeRefList&             nodelist);
  +
  +     virtual void
  +     getNodeSetByKey(
  +                     XalanDocument*                  doc,
                        const XalanDOMString&   name,
                        const XalanDOMString&   ref,
  -                     const PrefixResolver&   resolver,
  +                     const Locator*                  locator,
                        MutableNodeRefList&             nodelist);
   
        virtual const XObjectPtr
  
  
  

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

Reply via email to