ns
ns
¶
Namespace-related objects.
NamespacePrefixedTag
¶
Bases: str
Value object that knows the semantics of an XML tag having a namespace prefix.
Source code in src/docx/oxml/ns.py
local_part
property
¶
The local part of this tag.
E.g. "foobar" is returned for tag "f:foobar".
nsmap
property
¶
Single-member dict mapping prefix of this tag to it's namespace name.
Example: {"f": "http://foo/bar"}. This is handy for passing to xpath calls
and other uses.
nspfx
property
¶
The namespace-prefix for this tag.
For example, "f" is returned for tag "f:foobar".
nsuri
property
¶
The namespace URI for this tag.
For example, "http://foo/bar" would be returned for tag "f:foobar" if the "f" prefix maps to "http://foo/bar" in nsmap.
is_strict_ooxml_tag
¶
is_strict_ooxml_tag(tag: object) -> bool
True if tag is a Clark-notation tag name in an ISO Strict namespace.
False for anything that is not a string tag, which covers lxml's comment and processing-instruction elements.
Source code in src/docx/oxml/ns.py
nsdecls
¶
Namespace declaration including each namespace-prefix in prefixes.
Handy for adding required namespace declarations to a tree root element.
Source code in src/docx/oxml/ns.py
nspfxmap
¶
Subset namespace-prefix mappings specified by nspfxs.
Any number of namespace prefixes can be supplied, e.g. namespaces("a", "r", "p").
qn
cached
¶
Stands for "qualified name".
This utility function converts a familiar namespace-prefixed tag name like "w:p"
into a Clark-notation qualified tag name for lxml. For example, qn("w:p") returns
"{http://schemas.openxmlformats.org/wordprocessingml/2006/main}p".
Memoized; nsmap is a fixed table and this is called for every element access.