The sgml widget supports editing of conforming XML documents with or
without a DTD. When a document is loaded into the sgml widget (or when
a new document is created with the pcrmnew command), the document
prolog is scanned for an XML declaration of the form
<?xml version="1.0" ...?>.
When an XML declaration is found, the sgml widget enters XML mode. In this mode, the behaviour of the widget is slightly different from the normal behaviour in SGML mode. The following sections describe these differences in more detail.
When the sgml widget discovers an XML declaration at the beginning of a document, it switches to XML mode and processes the remainder of the document in this mode. If a document does not begin with a proper XML declaration, the widget assumes that the document is an SGML document and uses SGML mode for all operations on the document.
| mode | |
| Returns a description of the current widget mode as a proper Tcl list. | |
The current widget mode can be retrievd by using the pcrmmode widget command. The pcrmmode widget command has the general form
and returns a Tcl list with two elements. The first element of the returned list is either XML or SGML, depending on the current mode of the sgml widget.
The second element in the list returned by the mode command is one of the keywords valid or wellformed, depending on whether a DTD was found in the document or not. wellformed means that the document is 'only' a DTDless document that is a well-formed XML document with no explicit description of the available markup. valid means that the document contains (or points to) a DTD that canbe used for validating the document (it does not necessarily mean that the current state of the document instance completely satisfies the validity requirements of the DTD).
The sgml widget can handle DTDless documents only in XML mode since all SGML documents must contain (or point to) a DTD describing the document structure. Hence, the mode command will never return the result SGML wellformed.
![]() |
You can not change the widget mode by means of the mode command. Mode selection happens automatically, depending on the detection of a XML declaration at the beginning of the document prolog. |
Attributes that occur for elements in DTDless documents are silently defined for these elements with a declared value of CDATA and a default value of IMPLIED.