Skip to content

shared

shared

Objects shared by modules in the docx.oxml subpackage.

CT_DecimalNumber

Bases: BaseOxmlElement

Used for <w:numId>, <w:ilvl>, <w:abstractNumId> and several others, containing a text representation of a decimal number (e.g. 42) in its val attribute.

new classmethod

new(nsptagname: str, val: int)

Return a new CT_DecimalNumber element having tagname nsptagname and val attribute set to val.

Source code in src/docx/oxml/shared.py
@classmethod
def new(cls, nsptagname: str, val: int):
    """Return a new ``CT_DecimalNumber`` element having tagname `nsptagname` and
    ``val`` attribute set to `val`."""
    return OxmlElement(nsptagname, attrs={qn("w:val"): str(val)})

CT_OnOff

Bases: BaseOxmlElement

Used for w:b, w:i elements and others.

Contains a bool-ish string in its val attribute, xsd:boolean plus "on" and "off". Defaults to True, so <w:b> for example means "bold is turned on".

CT_String

Bases: BaseOxmlElement

Used for w:pStyle and w:tblStyle elements and others.

In those cases, it containing a style name in its val attribute.

new classmethod

new(nsptagname: str, val: str)

A new CT_String`` element with tagnamensptagnameandvalattribute set toval`.

Source code in src/docx/oxml/shared.py
@classmethod
def new(cls, nsptagname: str, val: str):
    """A new `CT_String`` element with tagname `nsptagname` and `val` attribute set to `val`."""
    elm = cast(CT_String, OxmlElement(nsptagname))
    elm.val = val
    return elm