Skip to content

Commit bc6be00

Browse files
committed
Docs: clarify DocumentType identifiers
1 parent 6920036 commit bc6be00

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

‎Doc/library/xml.dom.rst‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -453,14 +453,24 @@ following attributes:
453453

454454
.. attribute:: DocumentType.publicId
455455

456-
The public identifier for the external subset of the document type definition.
457-
This will be a string or ``None``.
456+
The public identifier for the external subset of the document type definition,
457+
or ``None`` if the ``DOCTYPE`` declaration does not specify one. A ``PUBLIC``
458+
``DOCTYPE`` declaration always has both a public and a system identifier.
458459

459460

460461
.. attribute:: DocumentType.systemId
461462

462-
The system identifier for the external subset of the document type definition.
463-
This will be a URI as a string, or ``None``.
463+
The system identifier for the external subset of the document type definition,
464+
or ``None`` if the ``DOCTYPE`` declaration does not specify one. A ``SYSTEM``
465+
``DOCTYPE`` declaration has a system identifier but no public identifier.
466+
The system identifier is a URI as a string.
467+
468+
For a parsed XML document, ``publicId`` and ``systemId`` correspond to the
469+
external identifier in the ``DOCTYPE`` declaration: both are non-``None`` for
470+
a ``PUBLIC`` declaration, only ``systemId`` is non-``None`` for a ``SYSTEM``
471+
declaration, and both are ``None`` when there is no external identifier.
472+
:meth:`DOMImplementation.createDocumentType` does not validate the identifiers,
473+
so programmatically created objects may have other combinations.
464474

465475

466476
.. attribute:: DocumentType.internalSubset

0 commit comments

Comments
 (0)