Factory to setup and wire tokenization and validation components for SGML parsing.

Acts as, and incorporates, Recordhandler and constructs Tokenizer, Markdown, Validator, and Linkhandler objects. Sgmldecl, Docinfo, Markupdefinitions, Entitydefinitions, Outputhandler, Recordmanager, Errorhandler, Markupencoder, and SystemSpecificEntityResolver must be supplied from outside.

Implements Recordhandler, Recordmanager, Saxeventmanager, Confighandler.

Constructor

new Chain()

Name Description
disable_referential_attributes Configuration value propagated to attributechecker instances constructed from here.
recordmanager Recordmanager as supplied via constructor or set otherwise.

Name Description
configure Configures embedded processing components.
configure_for_general_template Configures embedded tokenizer for processing a transcluded general template.
configure_for_general_template_with_implied_system_specific_link_process Configures embedded Tokenizer for processing a transcluded general template, with activating and implying (forcing) the given system-specific link process.
configure_for_simple_template Configures embedded Tokenizer and Validator for processing a transcluded simple template.
configure_for_web Configures embedded components as appropriate for general web server (SGML to HTML renderer) use.
configure_link_pipeline Portion of configuration setup code factored-out from configure() in order to being able to call it as part of link pipeline determination from the target doctype.
end_prolog Callback implementation of Confighandler.
end_records Called after the last record has been fed.
is_pausing_events Delegates is_pausing_events() to saxeventmanager/chainmanager.
is_pausing_records Delegates is_pausing_records() to recordmanager/chainmanager.
parse_content To be called as last thing (for sync) or on I/O completion (for async) by custom/provided prologhandler.
pause_events Delegates pause_events() to saxeventmanager/chainmanager.
pause_records Delegates pause_records() to recordmanager/chainmanager.
push_text Delegates push_text() to recordmanager/chainmanager.
record
reset Resets internal state.
resume_events Delegates resume_events() to saxeventmanager/chainmanager.
resume_records Delegates resume_records() to recordmanager/chainmanager.
set_debug_emit_ctx_token Propagates a processing context prefix token for SAX event tracing/debugging on to embedded components to appear as event source context in debugEmit messages.
start_records No-op/pro-forma implementation of start_records().

Member Details

configure()

Configures embedded processing components.

configure_for_general_template(enable_lax_templates, external_subset_sysid, target_document_type_name)

Configures embedded tokenizer for processing a transcluded general template.

For general templates, markup definitions aren't pre-populated. Instead, these are re-parsed from a synthetic DTD file that the calling environment produces. The calling environments puts that DTD file into the context system_specific_entity_path directory and the templating sub-context expects a DTD file by a name derived from the document element there.

Parameters

Name Type Description
enable_lax_templates

if false-y, sets options to enforce strict templates

external_subset_sysid

must contain a system identifier for the external subset to enforce in the template if enable_lax_templates is not false-y; this is expected to be a resolved external subset identifier rather than a system identifier relative to that of the target DTD of the transcluding instance)

target_document_type_name String

the expected result document type name/document element to be configured into Tokenizer; causes Tokenizer to determine link process names to activate by target document type name

Configures embedded Tokenizer for processing a transcluded general template, with activating and implying (forcing) the given system-specific link process.

Only used on JavaScript targets.

Parameters

Name Type Description
enable_lax_templates

if false-y, sets options to enforce strict templates

external_subset_sysid String

must contain a system identifier for the external subset to enforce in the template if enable_lax_templates is not false-y (this is expected to be the resolved (ie. not relative to the context identifier as of locator) external subset identifier of the target DTD of the transcluding instance)

system_specific_implied_lpd_names String

the link processes to activate as a CSV-string; the embedded tokenizer is configured to assume a system-specific link declaration with the given name is present, even if not actually declared in the document prolog

system_specific_implied_lpd_source_document_type_names String

the source document types, if any, of the respective entry in system_specific_implied_lpd_names

system_specific_implied_lpd_result_document_type_names String

the result document types, if any, of the respective entry in system_specific_implied_lpd_names

target_document_type_name String

the expected result document type name/document element to be configured into Tokenizer; causes Tokenizer to determine link process names to activate by target document type name

configure_for_simple_template()

Configures embedded Tokenizer and Validator for processing a transcluded simple template.

Specifically, the wrapped Validator is configured to access document metadata in the specified doctype name and expect the specified document_element_name. Doctype name and expected document element typically will be different when reusing markupdefinitions in a sub-processing context: expected_document_element_name is the name of the element on which a template expansion is applied whereas doctype_for_markupdefinitions_lookup is the name of the master context's document element. and used for looking up markup definitions.

Note that Tokenizer isn't pre-configured with the document type name of the invoking instance; rather, Tokenizer is configured to merely expect <!doctype ... system> or no prolog at all.

configure_for_web()

Configures embedded components as appropriate for general web server (SGML to HTML renderer) use.

Configures

  • server-side SGML link element generation: activates HTMLServersideSGMLFilter

  • deferred prolog serialization: configures embedded Tokenizer to defer dispatch of document prolog (DTDHandler) events until the first document content event is processed.

Used in top-level web request processing contexts to

  • (add markup to) advertise server-side SGML processing/rendering support

  • support reporting HTTP error status codes based on document prolog errors (as a limited facility to reflect processing errors in HTTP responses without introducing full output buffering, ie. to avoid sending HTTP 2xx responses on prolog errors).

  • enforce restriction wrt. parameter entity expansion in entity declarations

Portion of configuration setup code factored-out from configure() in order to being able to call it as part of link pipeline determination from the target doctype.

Parameters

Name Type Description
active_lpd_names Object.<integer.string>

0-based array of link processes to activate

disable_referential_attributes :string

Configuration value propagated to attributechecker instances constructed from here.

end_prolog()

Callback implementation of Confighandler.

Invoked by Tokenizer after having determined a link chain from a user-requested target document to produce. Invokes (re-)configuration of linkhandlers.

end_records()

Called after the last record has been fed.

See:
Recordhandler#end_records
is_pausing_events()

Delegates is_pausing_events() to saxeventmanager/chainmanager.

is_pausing_records()

Delegates is_pausing_records() to recordmanager/chainmanager.

parse_content()

To be called as last thing (for sync) or on I/O completion (for async) by custom/provided prologhandler.startContent() implementation.

See:
prologhandler#startContent
pause_events()

Delegates pause_events() to saxeventmanager/chainmanager.

pause_records()

Delegates pause_records() to recordmanager/chainmanager.

Needed as "proxy" so that Tokenizer can portably invoke pause_records() (ie. Chain receives a recordhandler via property rather than Chain constructor).

push_text()

Delegates push_text() to recordmanager/chainmanager.

record(line)

Parameters

Name Type Description
line string

the record being fed to the Recordhandler.

See:
Recordhandler#record
recordmanager :Recordmanager

Recordmanager as supplied via constructor or set otherwise.

Note (see also pause_records()):

  • in js impl, won't receive recordmanager from outside until Tokenizer has been constructed
  • in awk impl, recordmanager is treated as constructor-parameter-equivalent "named property"
  • also used as saxeventmanager
reset()

Resets internal state.

resume_events()

Delegates resume_events() to saxeventmanager/chainmanager.

resume_records()

Delegates resume_records() to recordmanager/chainmanager.

See comment on pause_records()

set_debug_emit_ctx_token()

Propagates a processing context prefix token for SAX event tracing/debugging on to embedded components to appear as event source context in debugEmit messages.

start_records()

No-op/pro-forma implementation of start_records(). pause_records is invoked on a record source directly.

See:
Recordmanager#start_records