Class ExpandedName
source code
object --+
|
ExpandedName
Represent an expanded name, 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 None
and
that string.
Note that absent namespaces can be represented in two ways: with a
namespace of None
(the name "has no namespace"),
and with a namespace that is an absent namespace (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.
This class allows direct lookup of the named object within a category
by using the category name as an accessor function. That is, if the
namespace of the expanded name en
has a category
'typeDefinition', then the following two expressions are equivalent:
en.typeDefinition()
en.namespace().categoryMap('typeDefinition').get(en.localName())
This class descends from tuple
so that its values can be
used as dictionary keys without concern for pointer equivalence.
|
|
|
namespaceURI(self)
Return the URI of the namespace, or None if the
namespace is absent. |
source code
|
|
|
localName(self)
The local part of the expanded name. |
source code
|
|
|
validateComponentModel(self)
Pass model validation through to namespace part. |
source code
|
|
|
|
|
|
|
|
|
adoptName(self,
name)
Return the input name, except if the input name has no namespace,
return a name that uses the namespace from this name with the local
name from the input name. |
source code
|
|
|
|
|
|
|
|
|
|
|
getAttribute(self,
dom_node)
Return the value of the attribute identified by this name in the
given node. |
source code
|
|
|
nodeMatches(self,
dom_node)
Return True iff the dom node expanded name matches this
expanded name. |
source code
|
|
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__sizeof__ ,
__subclasshook__
|
|
__namespace = None
hash(x)
|
|
__namespaceURI = None
hash(x)
|
|
__localName = None
hash(x)
|
|
__expandedName = None
hash(x)
|
Inherited from object :
__class__
|
Return a tuple consisting of the namespace URI and the local name.
This presents the expanded name as base Python types for persistent
storage. Be aware, though, that it will lose the association of the name
with an absent namespace, if that matters to you.
|
Return a new expanded name in the namespace of this name.
- Parameters:
local_name - The local name portion of an expanded name.
- Returns:
- An instance of ExpandedName.
|
Return the input name, except if the input name has no namespace,
return a name that uses the namespace from this name with the local name
from the input name.
Use this when the XML document has an unqualified name and we're
processing using an absent default namespace.
Warning:
Be careful when using a global name to adopt a name from a local
element: if the local element (with no namespace) has the same
localName as but is different from the global element (with a
namespace), this will improperly provide a namespace when one
should not be present. See the comments in pyxb.binding.basis.element.elementForName.
|
Create an expanded name.
Expected argument patterns are:
-
(
str ) : the local name in an absent namespace
-
( ExpandedName ) : a copy of the given expanded name
-
(
xml.dom.Node ) : The name extracted from
node.namespaceURI and node.localName
-
(
str , str ) : the namespace URI and the
local name
-
( Namespace,
str ) : the namespace and
the local name
-
( ExpandedName,
str ) : the namespace from
the expanded name, and the local name
Wherever str occurs unicode is also
permitted.
- Parameters:
fallback_namespace - Optional Namespace instance to use if the namespace would
otherwise be None. This is only used if it is an absent
namespace.
- Overrides:
object.__init__
|
__str__(self)
(Informal representation operator)
| source code
|
str(x)
- Overrides:
object.__str__
- (inherited documentation)
|
hash(x)
- Overrides:
object.__hash__
- (inherited documentation)
|
Return the value of the attribute identified by this name in the given
node.
- Returns:
- An instance of
xml.dom.Attr , or None if
the node does not have an attribute with this name.
|