Skip to content

customxml

customxml

Custom element classes for the custom XML data store's properties part.

customXml/itemProps1.xml is the sidecar of customXml/item1.xml: it carries the GUID Word identifies the store item by, and the namespaces of the schemas the item claims to conform to. The item itself is arbitrary caller-supplied XML with no element classes of its own.

CT_DatastoreSchemaRef

Bases: BaseOxmlElement

ds:schemaRef element, naming one schema namespace the store item uses.

CT_DatastoreSchemaRefs

Bases: BaseOxmlElement

ds:schemaRefs element, the set of schemas a store item claims to conform to.

CT_DatastoreItem

Bases: BaseOxmlElement

ds:datastoreItem, the root element of a customXml/itemPropsN.xml part.

schema_ref_uris property

schema_ref_uris: tuple[str, ...]

The schema namespaces this item claims, in document order.

new classmethod

new(
    item_id: str, schema_refs: tuple[str, ...] = ()
) -> CT_DatastoreItem

A newly created ds:datastoreItem for item_id naming schema_refs.

Source code in src/docx/oxml/customxml.py
@classmethod
def new(cls, item_id: str, schema_refs: tuple[str, ...] = ()) -> CT_DatastoreItem:
    """A newly created `ds:datastoreItem` for `item_id` naming `schema_refs`."""
    datastoreItem = parse_xml(
        '<ds:datastoreItem %s ds:itemID="%s"/>' % (nsdecls("ds"), item_id)
    )
    if schema_refs:
        schemaRefs = datastoreItem.get_or_add_schemaRefs()
        for uri in schema_refs:
            schemaRefs.add_schemaRef().uri = uri
    return datastoreItem

is_datastore_item

is_datastore_item(element: object) -> bool

True when element is a ds:datastoreItem root element.

Source code in src/docx/oxml/customxml.py
def is_datastore_item(element: object) -> bool:
    """|True| when `element` is a `ds:datastoreItem` root element."""
    return getattr(element, "tag", None) == qn("ds:datastoreItem")