:- use_module(library(sgml)).(can be autoloaded)
- Current file-name. Note that this may be different from the provided file if an external entity is being loaded.
- Line-offset from where the parser started its processing in the file-object.
- Offset from where the parser started its processing in the file-object. See section 6.
- charpos(-Start, -End)
- Character offsets of the start and end of the source processed causing the current call-back. Used in PceEmacs to for colouring text in SGML and XML modes.
- Prolog stream being processed. May be used in the
on_begin, etc. callbacks from sgml_parse/2.
- Return the current dialect used by the parser (
- The event class can be requested in call-back events. It
denotes the cause of the event, providing useful information for syntax
highlighting. Defined values are:
- The code generating this event is explicitely present in the document.
- The current event is caused by the insertion of an omitted tag. This may be a normal event in SGML mode or an error in XML mode.
- The current event (
end) is caused by an element written down using the shorttag notation (
- The current event is caused by the expansion of a shortref. This allows for highlighting shortref strings in the source-text.
- Return the defined document-type (= toplevel element). See also set_sgml_parser/2.
- Return the currently used DTD. See dtd_property/2 for obtaining information on the DTD such as element and attribute properties.
- Returns the stack of currently open elements as a list. The head of this list is the current element. This can be used to determine the context of, for example, CDATA events in call-back mode. The elements are passed as atoms. Currently no access to the attributes is provided.
- Determines which elements may be inserted at the current location. This
information is returned as a list of element-names. If character data is
allowed in the current location,
#pcdatais part of Elements. If no element is open, the doctype is returned.
This option is intended to support syntax-sensitive editors. Such an editor should load the DTD, find an appropriate starting point and then feed all data between the starting point and the caret into the parser. Next it can use this option to determine the elements allowed at this point. Below is a code fragment illustrating this use given a parser with loaded DTD, an input stream and a start-location.
..., seek(In, Start, bof, _), set_sgml_parser(Parser, charpos(Start)), set_sgml_parser(Parser, doctype(_)), Len is Caret - Start, sgml_parse(Parser, [ source(In), content_length(Len), parse(input) % do not complete document ]), get_sgml_parser(Parser, allowed(Allowed)), ...