Next / Previous / Contents / TCC Help System / NM Tech homepage

14.2. The DocumentType class

The purpose of this object is to hold the information necessary to output a <!DOCTYPE...> declaration.

The 4Suite implementation does not support the DOM's standard DocumentType interface. This object is simply a container for the .publicId and .systemId attributes, so they are available to the Document constructor if the user wants to use them. The rootGI is also stored away, and if we were picky, we would check it against the rootGI argument passed to the Document constructor, but that's wasted effort—the latter is always used.

xml4create.py
# - - - - -   c l a s s   D o c u m e n t T y p e   - - - - -

class DocumentType:
    """Represents an XML document type.

      State/invariants:
        .rootGI:        [ as passed to constructor ]
        .publicId:      [ as passed to constructor ]
        .systemId:      [ as passed to constructor ]
    """

The constructor is pro-forma.

xml4create.py
# - - -   D o c u m e n t T y p e . _ _ i n i t _ _   - - -

    def __init__ ( self, rootGI, publicId=None, systemId=None ):
        """Constructor for a DocumentType object.

          [ (rootGI is the root element name) and
            (publicId is a public ID as a string or None) and
            (systemId is a system ID as a string) ->
              return a new DocumentType object with those values ]
        """
        self.rootGI  =  rootGI
        self.publicId  =  publicId
        self.systemId  =  systemId