# Copyright 2009, Peter A. Bigot
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain a
# copy of the License at:
#
#            http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

"""Classes and global objects related to U{XML Namespaces<http://www.w3.org/TR/2006/REC-xml-names-20060816/index.html>}.

Since namespaces hold all referenceable objects, this module also defines the
infrastructure for resolving named object references, such as schema
components.
"""

import pyxb
import os
import fnmatch
import pyxb.utils.utility
import xml.dom
import logging

_log = logging.getLogger(__name__)

class ExpandedName (pyxb.cscRoot):

    """Represent an U{expanded name
    <http://www.w3.org/TR/REC-xml-names/#dt-expname>}, which pairs a
    namespace with a local name.

    Because a large number of local elements, and most attributes, have no
    namespace associated with them, this is optimized for representing names
    with an absent namespace.  The hash and equality test methods are set so
    that a plain string is equivalent to a tuple of C{None} and that string.

    Note that absent namespaces can be represented in two ways: with a
    namespace of C{None} (the name "has no namespace"), and with a namespace
    that is an L{absent namespace <Namespace.CreateAbsentNamespace>} (the name
    "has an absent namespace").  Hash code calculations are done so that the
    two alternatives produce the same hash; however, comparison is done so
    that the two are distinguished.  The latter is the intended behavior; the
    former should not be counted upon.