dbertoni    01/08/13 10:08:02

  Modified:    c/src/XPath XPath.cpp XPathEnvSupport.hpp
                        XPathExecutionContext.hpp
                        XPathExecutionContextDefault.cpp
                        XPathExecutionContextDefault.hpp
  Added:       c/src/XPath XalanQName.cpp XalanQName.hpp
                        XalanQNameByReference.cpp XalanQNameByReference.hpp
                        XalanQNameByValue.cpp XalanQNameByValue.hpp
  Log:
  Fixed QName collisions with Xerces.
  
  Revision  Changes    Path
  1.61      +2 -5      xml-xalan/c/src/XPath/XPath.cpp
  
  Index: XPath.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPath.cpp,v
  retrieving revision 1.60
  retrieving revision 1.61
  diff -u -r1.60 -r1.61
  --- XPath.cpp 2001/07/21 05:35:15     1.60
  +++ XPath.cpp 2001/08/13 17:08:01     1.61
  @@ -78,7 +78,7 @@
   
   #include "FoundIndex.hpp"
   #include "MutableNodeRefList.hpp"
  -#include "QNameByReference.hpp"
  +#include "XalanQNameByReference.hpp"
   #include "SimpleNodeLocator.hpp"
   #include "XLocator.hpp"
   #include "XPathException.hpp"
  @@ -914,10 +914,7 @@
   
        const XObject&  varName = m_expression.m_tokenQueue[m_expression.m_opMap[opPos 
+ 3]];
   
  -     const QNameByReference  qname(ns.str(),
  -                                                               varName.str());      
 
  -
  -     return executionContext.getVariable(qname);
  +     return executionContext.getVariable(XalanQNameByReference(ns.str(), 
varName.str()));
   }
   
   
  
  
  
  1.16      +1 -1      xml-xalan/c/src/XPath/XPathEnvSupport.hpp
  
  Index: XPathEnvSupport.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathEnvSupport.hpp,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- XPathEnvSupport.hpp       2001/07/18 04:26:54     1.15
  +++ XPathEnvSupport.hpp       2001/08/13 17:08:01     1.16
  @@ -94,7 +94,7 @@
   class XalanDocument;
   class XalanElement;
   class XalanNode;
  -class QName;
  +class XalanQName;
   
   
   
  
  
  
  1.42      +2 -2      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.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- XPathExecutionContext.hpp 2001/07/18 04:26:54     1.41
  +++ XPathExecutionContext.hpp 2001/08/13 17:08:01     1.42
  @@ -87,7 +87,7 @@
   
   class XalanDecimalFormatSymbols;
   class PrefixResolver;
  -class QName;
  +class XalanQName;
   class XLocator;
   class XMLURL;
   class XObject;
  @@ -640,7 +640,7 @@
         * @return pointer to an XObject if the variable was found, 0 if it was not
         */
        virtual const XObjectPtr
  -     getVariable(const QName&        name) = 0;
  +     getVariable(const XalanQName&   name) = 0;
   
        /**
         * Retrieve the resolver for namespaces.
  
  
  
  1.41      +2 -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.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- XPathExecutionContextDefault.cpp  2001/07/18 04:26:54     1.40
  +++ XPathExecutionContextDefault.cpp  2001/08/13 17:08:01     1.41
  @@ -81,7 +81,7 @@
   #include "FoundIndex.hpp"
   #include "XObjectFactory.hpp"
   #include "ResultTreeFrag.hpp"
  -#include "QName.hpp"
  +#include "XalanQName.hpp"
   #include "XPathEnvSupport.hpp"
   
   
  @@ -388,7 +388,7 @@
   
   
   const XObjectPtr
  -XPathExecutionContextDefault::getVariable(const QName&       name)
  +XPathExecutionContextDefault::getVariable(const XalanQName&          name)
   {
        assert(m_xobjectFactory != 0);
   
  
  
  
  1.37      +1 -1      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.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- XPathExecutionContextDefault.hpp  2001/07/18 04:26:54     1.36
  +++ XPathExecutionContextDefault.hpp  2001/08/13 17:08:01     1.37
  @@ -264,7 +264,7 @@
                        MutableNodeRefList&             nodelist);
   
        virtual const XObjectPtr
  -     getVariable(const QName&        name);
  +     getVariable(const XalanQName&   name);
   
        virtual const PrefixResolver*
        getPrefixResolver() const;
  
  
  
  1.1                  xml-xalan/c/src/XPath/XalanQName.cpp
  
  Index: XalanQName.cpp
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xalan" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.ibm.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  // Class header file...
  #include "XalanQName.hpp"
  
  
  
  #include <Include/STLHelper.hpp>
  
  
  
  #include <PlatformSupport/DOMStringHelper.hpp>
  #include <PlatformSupport/XalanUnicode.hpp>
  
  
  
  #include <DOMSupport/DOMServices.hpp>
  
  
  
  const XalanDOMString  XalanQName::s_emptyString;
  
  
  
  const XalanDOMString*
  XalanQName::getNamespaceForPrefix(
                        const NamespaceVectorType&      namespaces,
                        const XalanDOMString&           prefix,
                        bool                                            reverse)
  {
        const XalanDOMString*   nsURI = 0;
  
        if(::equals(prefix, DOMServices::s_XMLString))
        {
                nsURI = &DOMServices::s_XMLNamespaceURI;
        }
        else if (::equals(prefix, DOMServices::s_XMLNamespace))
        {
                nsURI = &DOMServices::s_XMLNamespacePrefixURI;
        }
        else
        {
                if (reverse)
                {
                        for(int j = namespaces.size()-1; j >= 0; j--)
                        {
                                const NameSpace&        ns = namespaces[j];
  
                                const XalanDOMString&   thisPrefix = ns.getPrefix();
  
                                if(::equals(prefix, thisPrefix))
                                {
                                        nsURI = &ns.getURI();
  
                                        break;
                                }
                        }
                }
                else
                {
                        for(unsigned int j = 0; j < namespaces.size(); j++)
                        {
                                const NameSpace&        ns = namespaces[j];
  
                                const XalanDOMString&   thisPrefix = ns.getPrefix();
  
                                if(::equals(prefix, thisPrefix))
                                {
                                        nsURI = &ns.getURI();
  
                                        break;
                                }
                        }
                }
        }
  
        return nsURI;
  }
  
  
  
  const XalanDOMString*
  XalanQName::getNamespaceForPrefix(
                        const NamespacesStackType&      nsStack,
                        const XalanDOMString&           prefix,
                        bool                                            reverse)
  {
        const XalanDOMString*   nsURI = 0;
  
        const int depth = nsStack.size();
  
        for(int i = depth-1; i >= 0; i--)
        {
                const NamespaceVectorType&      namespaces = nsStack[i];
  
                nsURI = getNamespaceForPrefix(namespaces, prefix, reverse);
  
                if (nsURI != 0)
                        break;
        }
  
        return nsURI;
  }
  
  
  
  const XalanDOMString*
  XalanQName::getPrefixForNamespace(
                        const NamespaceVectorType&      namespaces,
                        const XalanDOMString&           uri,
                        bool                                            /* reverse */)
  {
        const XalanDOMString*   thePrefix = 0;
  
        for(int j = namespaces.size()-1; j >= 0; j--)
        {
                const NameSpace&                ns = namespaces[j];
                const XalanDOMString&   thisURI = ns.getURI();
  
                if(::equals(uri, thisURI))
                {
                        thePrefix = &ns.getPrefix();
  
                        break;
                }
        }
  
        return thePrefix;
  }             
  
  
  
  const XalanDOMString*
  XalanQName::getPrefixForNamespace(
                        const NamespacesStackType&      nsStack,
                        const XalanDOMString&           uri,
                        bool                                            reverse)
  {
        const XalanDOMString*   thePrefix = 0;
  
        const int               depth = nsStack.size();
  
        if (reverse)
        {
                for(int i = depth-1; i >= 0; i--)
                {
                        const NamespaceVectorType&      namespaces = nsStack[i];
  
                        thePrefix = getPrefixForNamespace(namespaces, uri, reverse);
  
                        if (thePrefix != 0)
                                break;
                }
        }
        else
        {
                for(int i = 0; i < depth; i++)
                {
                        const NamespaceVectorType&      namespaces = nsStack[i];
  
                        thePrefix = getPrefixForNamespace(namespaces, uri, reverse);
  
                        if (thePrefix != 0)
                                break;
                }
        }
  
        return thePrefix;
  }
  
  
  
  1.1                  xml-xalan/c/src/XPath/XalanQName.hpp
  
  Index: XalanQName.hpp
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xalan" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.ibm.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  #if !defined(XALANQNAME_HEADER_GUARD_1357924680)
  #define XALANQNAME_HEADER_GUARD_1357924680
  
  
  
  // Base header file.  Must be first.
  #include <XPath/XPathDefinitions.hpp>
  
  
  
  #include <deque>
  
  
  
  #include <XalanDOM/XalanDOMString.hpp>
  
  
  
  #include <PlatformSupport/DOMStringHelper.hpp>
  
  
  
  #include <XPath/NameSpace.hpp>
  
  
  
  class XalanElement;
  class PrefixResolver;
  class XPathEnvSupport;
  
  
  
  /**
   * Class to represent a qualified name: "The name of an internal XSLT object, 
   * specifically a named template (see [7 Named Templates]), a mode (see [6.7 
Modes]), 
   * an attribute set (see [8.1.4 Named Attribute Sets]), a key (see [14.2 Keys]), 
   * a locale (see [14.3 Number Formatting]), a variable or a parameter (see 
   * [12 Variables and Parameters]) is specified as a QName. If it has a prefix, 
   * then the prefix is expanded into a URI reference using the namespace declarations 
   * in effect on the attribute in which the name occurs. The expanded name 
   * consisting of the local part of the name and the possibly null URI reference 
   * is used as the name of the object. The default namespace is not used for 
   * unprefixed names."
   */
  class XALAN_XPATH_EXPORT XalanQName
  {
  public:
  
  #if defined(XALAN_NO_NAMESPACES)
        typedef deque<NameSpace>                                        
NamespaceVectorType;
        typedef deque<NamespaceVectorType>                      NamespacesStackType;
  #else
        typedef std::deque<NameSpace>                           NamespaceVectorType;
        typedef std::deque<NamespaceVectorType>         NamespacesStackType;
  #endif
  
        /**
         * Construct an empty XalanQName.
         *
         */
        explicit
        XalanQName()
        {
        }
  
        virtual
        ~XalanQName()
        {
        }
  
        /**
         * Retrieve the local part of qualified name.
         * 
         * @return local part string
         */
        virtual const XalanDOMString&
        getLocalPart() const = 0;
  
        /**
         * Retrieve the namespace of qualified name.
         * 
         * @return namespace string
         */
        virtual const XalanDOMString&
        getNamespace() const = 0;
  
        /**
         * Whether the qualified name is empty.
         * 
         * @return true if namespace and local part are both empty
         */
        bool
        isEmpty() const
        {
                return ::isEmpty(getNamespace()) && ::isEmpty(getLocalPart());
        }
  
        /**
         * Override equals and agree that we're equal if the passed object is a
         * string and it matches the name of the arg.
         * 
         * @param theRHS namespace to compare
         * @return true if namespace and local part are both empty
         */
        bool
        equals(const XalanQName&                theRHS) const
        {
                // Note that we do not use our member variables here.  See
                // class QNameReference for details...
                return ::equals(getLocalPart(), theRHS.getLocalPart()) &&
                           ::equals(getNamespace(), theRHS.getNamespace());
        }
  
        /**
         * Get the namespace from a prefix by searching a vector of namespaces.
         *
         * @param namespaces vector of namespaces to search
         * @param prefix     namespace prefix to find
         * @param reverse    true to search vector from last to first, default true
         * @return pointer to the string value if found, otherwise null.
         */
        static const XalanDOMString*
        getNamespaceForPrefix(
                        const NamespaceVectorType&      namespaces,
                        const XalanDOMString&           prefix,
                        bool                                            reverse = 
true);
  
        /**
         * Get the namespace from a prefix by searching a stack of namespace
         * vectors.
         *
         * @param nsStack stack of namespace vectors to search
         * @param prefix  namespace prefix to find
         * @param reverse true to search vector from last to first, default true
         * @return pointer to the string value if found, otherwise null.
         */
        static const XalanDOMString*
        getNamespaceForPrefix(
                        const NamespacesStackType&      nsStack,
                        const XalanDOMString&           prefix,
                        bool                                            reverse = 
true);
  
        /**
         * Get the prefix for a namespace by searching a vector of namespaces.
         *
         * @param namespaces vector of namespaces to search
         * @param uri        URI string for namespace to find
         * @param reverse    true to search vector from last to first, default true
         * @return pointer to the string value if found, otherwise null.
         */
        static const XalanDOMString*
        getPrefixForNamespace(
                        const NamespaceVectorType&      namespaces,
                        const XalanDOMString&           uri,
                        bool                                            reverse = 
true);
  
        /**
         * Get the prefix for a namespace by searching a stack of namespace
         * vectors.
         *
         * @param nsStack stack of namespace vectors to search
         * @param uri     URI string for namespace to find
         * @param reverse true to search vector from last to first, default true
         * @return pointer to the string value if found, otherwise null.
         */
        static const XalanDOMString*
        getPrefixForNamespace(
                        const NamespacesStackType&      nsStack,
                        const XalanDOMString&           uri,
                        bool                                            reverse = 
true);
  
  protected:
  
        static const XalanDOMString             s_emptyString;
  };
  
  
  
  inline bool
  operator==(
                        const XalanQName&       theLHS,
                        const XalanQName&       theRHS)
  {
        return theLHS.equals(theRHS);
  }
  
  
  
  inline bool
  operator!=(
                        const XalanQName&       theLHS,
                        const XalanQName&       theRHS)
  {
        return !(theLHS == theRHS);
  }
  
  
  
  inline bool
  operator<(
                        const XalanQName&       theLHS,
                        const XalanQName&       theRHS)
  {
        if (theLHS.getNamespace() < theRHS.getNamespace())
        {
                return true;
        }
        else if (equals(theLHS.getNamespace(), theRHS.getNamespace()))
        {
                return theLHS.getLocalPart() < theRHS.getLocalPart();
        }
        else
        {
                return false;
        }
  }
  
  
  
  #endif        // XALANQNAME_HEADER_GUARD_1357924680
  
  
  
  1.1                  xml-xalan/c/src/XPath/XalanQNameByReference.cpp
  
  Index: XalanQNameByReference.cpp
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xalan" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.ibm.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  // Class header file...
  #include "XalanQNameByReference.hpp"
  
  
  
  XalanQNameByReference::XalanQNameByReference() :
        XalanQName(),
        m_namespace(&s_emptyString),
        m_localpart(&s_emptyString)
  {
  }
  
  
  
  XalanQNameByReference::XalanQNameByReference(
                        const XalanDOMString&   theNamespace,
                        const XalanDOMString&   theLocalPart) :
        XalanQName(),
        m_namespace(&theNamespace),
        m_localpart(&theLocalPart)
  {
  }
  
  
  
  XalanQNameByReference::XalanQNameByReference(const XalanQName&        theQName) :
        XalanQName(),
        m_namespace(&theQName.getNamespace()),
        m_localpart(&theQName.getLocalPart())
  {
  }
  
  
  
  XalanQNameByReference::~XalanQNameByReference()
  {
  }
  
  
  
  const XalanDOMString&
  XalanQNameByReference::getLocalPart() const
  {
        assert(m_localpart != 0);
  
        return *m_localpart;
  }
  
  
  
  const XalanDOMString&
  XalanQNameByReference::getNamespace() const
  {
        assert(m_namespace != 0);
  
        return *m_namespace;
  }
  
  
  
  1.1                  xml-xalan/c/src/XPath/XalanQNameByReference.hpp
  
  Index: XalanQNameByReference.hpp
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xalan" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.ibm.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  #if !defined(XALANQNAMEBYREFERENCE_HEADER_GUARD_1357924680)
  #define XALANQNAMEBYREFERENCE_HEADER_GUARD_1357924680
  
  
  
  // Base header file.  Must be first.
  #include <XPath/XPathDefinitions.hpp>
  
  
  
  // Base class header file...
  #include <XPath/XalanQName.hpp>
  
  
  
  class XALAN_XPATH_EXPORT XalanQNameByReference : public XalanQName
  {
  public:
  
        /**
         * Construct an empty XalanQNameByReference.
         */
        explicit
        XalanQNameByReference();
  
        /**
         * Construct a XalanQNameByReference, with the supplied namespace and local 
part.
         * The instance keeps only a _reference_ to the string, to avoid making a
         * copy.
         *
         * @param theNamespace namespace string
         * @param theLocalPart local part string
         */
        XalanQNameByReference(
                        const XalanDOMString&   theNamespace,
                        const XalanDOMString&   theLocalPart);
  
        /**
         * Construct a XalanQNameByReference, from the supplied XalanQName.  The 
instance
         * keeps only a _reference_ to the string, to avoid making a copy.
         *
         * @param theQName The source QName
         */
        XalanQNameByReference(const XalanQName&         theQName);
  
        virtual
        ~XalanQNameByReference();
  
        /**
         * Retrieve the local part of qualified name.
         * 
         * @return local part string
         */
        virtual const XalanDOMString&
        getLocalPart() const;
  
        /**
         * Retrieve the namespace of qualified name.
         * 
         * @return namespace string
         */
        virtual const XalanDOMString&
        getNamespace() const;
  
  private:
  
        // OK, we said reference, but using pointers
        // allows for copy and assignment semantics.
        const XalanDOMString*   m_namespace;
  
        const XalanDOMString*   m_localpart;
  };
  
  
  
  #endif        // XALANQNAMEBYREFERENCE_HEADER_GUARD_1357924680
  
  
  
  1.1                  xml-xalan/c/src/XPath/XalanQNameByValue.cpp
  
  Index: XalanQNameByValue.cpp
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xalan" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.ibm.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  // Class header file...
  #include "XalanQNameByValue.hpp"
  
  
  
  #include <PlatformSupport/PrefixResolver.hpp>
  #include <PlatformSupport/XSLException.hpp>
  
  
  
  #include <DOMSupport/DOMServices.hpp>
  #include <DOMSupport/DOMSupport.hpp>
  
  
  
  #include "ElementPrefixResolverProxy.hpp"
  
  
  
  XalanQNameByValue::XalanQNameByValue() :
        XalanQName(),
        m_namespace(),
        m_localpart()
  {
  }
  
  
  
  XalanQNameByValue::XalanQNameByValue(const XalanQNameByValue& theSource) :
        XalanQName(),
        m_namespace(theSource.m_namespace),
        m_localpart(theSource.m_localpart)
  {
  }
  
  
  
  XalanQNameByValue::XalanQNameByValue(const XalanQName&        theSource) :
        XalanQName(),
        m_namespace(theSource.getNamespace()),
        m_localpart(theSource.getLocalPart())
  {
  }
  
  
  
  XalanQNameByValue::XalanQNameByValue(
                        const XalanDOMString&   theNamespace,
                        const XalanDOMString&   theLocalPart) :
        XalanQName(),
        m_namespace(theNamespace),
        m_localpart(theLocalPart)
  {
  }
  
  
  
  XalanQNameByValue::XalanQNameByValue(
                        const XalanDOMString&           qname,
                        const NamespacesStackType&      namespaces) :
        m_namespace(),
        m_localpart()
  {
        initialize(c_wstr(qname), namespaces);
  }
  
  
  
  XalanQNameByValue::XalanQNameByValue(
                        const XalanDOMChar*                     qname,
                        const NamespacesStackType&      namespaces) :
        m_namespace(),
        m_localpart()
  {
        assert(qname != 0);
  
        initialize(qname, namespaces);
  }
  
  
  
  XalanQNameByValue::XalanQNameByValue(
                        const XalanDOMString&   qname,
                        const XalanElement*             namespaceContext,
                        const XPathEnvSupport&  envSupport,
                        const DOMSupport&               domSupport) :
        m_namespace(),
        m_localpart()
  {
        ElementPrefixResolverProxy      theProxy(namespaceContext, envSupport, 
domSupport);
  
        resolvePrefix(qname, theProxy);
  }
  
  
  
  XalanQNameByValue::XalanQNameByValue(
                        const XalanDOMString&   qname,
                        const PrefixResolver&   theResolver) :
        m_namespace(),
        m_localpart()
  {
        resolvePrefix(qname, theResolver);
  }
  
  
  
  XalanQNameByValue::~XalanQNameByValue()
  {
  }
  
  
  
  const XalanDOMString&
  XalanQNameByValue::getLocalPart() const
  {
        return m_localpart;
  }
  
  
  
  const XalanDOMString&
  XalanQNameByValue::getNamespace() const
  {
        return m_namespace;
  }
  
  
  
  void
  XalanQNameByValue::initialize(
                        const XalanDOMChar*                     qname,
                        const NamespacesStackType&      namespaces)
  {
        const unsigned int      indexOfNSSep = indexOf(qname, XalanUnicode::charColon);
  
        if(indexOfNSSep < length(qname))
        {
                const XalanDOMString            prefix = substring(qname, 0, 
indexOfNSSep);
  
                if(::equals(prefix, DOMServices::s_XMLNamespace))
                        return;
  
                const XalanDOMString* const             theNamespace = 
                                getNamespaceForPrefix(namespaces, prefix);
  
                if(theNamespace == 0 || 0 == length(*theNamespace))
                {
                        throw XSLException(TranscodeFromLocalCodePage("Prefix must 
resolve to a namespace: ") + prefix);
                }
                else
                {
                        m_namespace = *theNamespace;
                }
  
                m_localpart =  substring(qname, indexOfNSSep + 1);
        }
        else
        {
                m_localpart = qname;
        }
  }
  
  
  
  void
  XalanQNameByValue::resolvePrefix(
                        const XalanDOMString&   qname,
                        const PrefixResolver&   theResolver)
  {
        const unsigned int      indexOfNSSep = indexOf(qname, XalanUnicode::charColon);
        const unsigned int      theLength = length(qname);
  
        if(indexOfNSSep < theLength)
        {
                const XalanDOMString    prefix = substring(qname, 0, indexOfNSSep);
  
                if(::equals(prefix, DOMServices::s_XMLString))
                {
                        m_namespace = DOMServices::s_XMLNamespaceURI;
                }
                // The default namespace is not resolved.
                else if(::equals(prefix, DOMServices::s_XMLNamespace))
                {
                        return;
                }
                else
                {
                        const XalanDOMString* const             theNamespace =
                                theResolver.getNamespaceForPrefix(prefix);
  
                        if (theNamespace != 0)
                        {
                                m_namespace = *theNamespace;
                        }
                }  
  
                if(0 == length(m_namespace))
                {
                        throw XSLException(TranscodeFromLocalCodePage("Prefix must 
resolve to a namespace: ") + prefix);
                }
        }
        else
        {
                // $$$ ToDo: error or warning...
        }
  
        m_localpart = indexOfNSSep == theLength ? qname : substring(qname, 
indexOfNSSep + 1);
  }
  
  
  
  1.1                  xml-xalan/c/src/XPath/XalanQNameByValue.hpp
  
  Index: XalanQNameByValue.hpp
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xalan" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.ibm.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  #if !defined(XALANQNAMEBYVALUE_HEADER_GUARD_1357924680)
  #define XALANQNAMEBYVALUE_HEADER_GUARD_1357924680
  
  
  
  // Base header file.  Must be first.
  #include <XPath/XPathDefinitions.hpp>
  
  
  
  // Base class header file...
  #include <XPath/XalanQName.hpp>
  
  
  
  class DOMSupport;
  
  
  
  class XALAN_XPATH_EXPORT XalanQNameByValue : public XalanQName
  {
  public:
  
        /**
         * Construct an empty XalanQNameByValue.
         */
        explicit
        XalanQNameByValue();
  
        /**
         * Copy constructor.
         *
         * @param theSource The source of the copy.
         */
        XalanQNameByValue(const XalanQNameByValue&      theSource);
  
        /**
         * Construct an instance from another XalanQName.
         *
         * @param theSource The source of the copy.
         */
        explicit
        XalanQNameByValue(const XalanQName&     theSource);
  
        /**
         * Construct a XalanQNameByValue, with the supplied namespace and local part.
         *
         * @param theNamespace namespace string
         * @param theLocalPart local part string
         */
        XalanQNameByValue(
                        const XalanDOMString&   theNamespace,
                        const XalanDOMString&   theLocalPart);
  
        /**
         * Construct a XalanQNameByValue from a string, resolving the prefix using the 
given
         * namespace vector stack. The default namespace is not resolved.
         *
         * @param qname      XalanQName string
         * @param namespaces namespace vector stack to use
         */
        XalanQNameByValue(
                        const XalanDOMString&           qname,
                        const NamespacesStackType&      namespaces);
  
        /**
         * Construct a XalanQNameByValue from a string, resolving the prefix using the 
given
         * namespace vector stack. The default namespace is not resolved.
         *
         * @param qname      XalanQName string
         * @param namespaces namespace vector stack to use
         */
        XalanQNameByValue(
                        const XalanDOMChar*                     qname,
                        const NamespacesStackType&      namespaces);
  
        /**
         * Construct a XalanQNameByValue from a string, resolving the prefix using the 
given
         * namespace context. The default namespace is not resolved.
         *
         * @param qname XalanQName string
         * @param namespaceContext context object for namespace resolution
         * @param envSupport XPathEnvSupport class instance
         * @param domSupport DOMSupport class instance
         */
        XalanQNameByValue(
                        const XalanDOMString&   qname,
                        const XalanElement*             namespaceContext,
                        const XPathEnvSupport&  envSupport,
                        const DOMSupport&               domSupport);
  
        /**
         * Construct a XalanQNameByValue from a string, resolving the prefix using the 
given
         * prefix resolver. The default namespace is not resolved.
         *
         * @param qname XalanQName string
         * @param theResolver prefix resolver to use
         */
        XalanQNameByValue(
                        const XalanDOMString&   qname,
                        const PrefixResolver&   theResolver);
  
        virtual
        ~XalanQNameByValue();
  
        /**
         * Retrieve the local part of qualified name.
         * 
         * @return local part string
         */
        virtual const XalanDOMString&
        getLocalPart() const;
  
        /**
         * Retrieve the namespace of qualified name.
         * 
         * @return namespace string
         */
        virtual const XalanDOMString&
        getNamespace() const;
  
  private:
  
        void
        initialize(
                        const XalanDOMChar*                     qname,
                        const NamespacesStackType&      namespaces);
  
        void
        resolvePrefix(
                        const XalanDOMString&   qname,
                        const PrefixResolver&   theResolver);
  
        XalanDOMString  m_namespace;
  
        XalanDOMString  m_localpart;
  };
  
  
  
  #endif        // XALANQNAMEBYVALUE_HEADER_GUARD_1357924680
  
  
  

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

Reply via email to