# Architectural Form Processing

The Hytime standard (ISO/IEC 10744) introduced the concept of architectural forms. This document assumes you are already familiar with this concept. HyTime 2nd Edition generalizes this, and makes it possible to have an architecture engine which can perform architectural form processing for arbitrary architectures. SP includes such an architecture engine.

Non-markup sensitive applications built using SP now support architectural form processing using the `-A archname` option. When this option is specified, the document will be validated against all declared base architectures, and the output will be for the architectural document for that architecture: the element types, notations and attributes will be those defined in the meta-DTD.

Although spam does not support the `-A` option because it works with the markup of your document, sgmlnorm does.

## Architectural Support Attributes

To use the `-A` option with a document, you must add

- an architecture base declaration for `archname`,
- a notation declaration and associated attribute definition list declaration for `archname`; this is called the architecture notation declaration.

An architecture base declaration is a processing instruction of the form:

    <?IS10744 ArcBase archname>

The processing instruction is recognized either in the DTD or in an active LPD.

The architecture notation declaration and associated attribute definition list declaration serve to declare a number of architectural support attributes which control the architecture engine. The value for each architecture support attribute is taken from the default value, if any, specified for that attribute in the attribute definition list declaration. It is an error to declare an architecture support attribute as `#REQUIRED`.

The following architectural support attributes are recognized:

`ArcDTD`
  The name of an external entity that contains the meta-DTD. This attribute is required. If the name starts with the PERO delimiter `%`, the entity is a parameter entity, otherwise it is a general entity.
`ArcQuant`
  A list of tokens that looks like what follows `QUANTITY SGMLREF` in the quantity set section of an SGML declaration. The quantities used for parsing the meta-DTD and validating the architectural document will be the maximum of the quantities in the document's concrete syntax and the quantities specified here.
`ArcDocF`
  The name of the document element type in the meta-DTD. This would be `HyDoc` for HyTime. This defaults to `archname`.
`ArcFormA`
  The name of the attribute that elements use to specify the corresponding element type, if any, in the meta-DTD. Data entities also use this attribute to specify the corresponding notation in the meta-DTD. This would be `HyTime` for HyTime. This defaults to `archname`.
`ArcNamrA`
  The name of the attribute that elements use to specify substitutes for the names of attributes in the meta-DTD. A value of `#DEFAULT` is allowed for a substitute name; this inhibits mapping of an attribute to an architectural attribute, but specifies that the value of the architectural attribute should be defaulted rather than taken from the value of another attribute in the document. For HyTime the value of this attribute would be `HyNames`. By default no attribute name substitutition is done.
`ArcSuprA`
  The name of an attribute that elements may use to suppress processing of their descendants. This attribute is not recognized for data entities. The value of the attribute must be one of the following tokens:
  `sArcAll`
    Completely suppress all architectural processing of descendants. It is not possible to restore architectural processing for a descendant.
  `sArcForm`
    Suppress processing of the `ArcFormA` attribute of all descendants of this element, except for those elements that have a non-implied `ArcSuprA` attribute.
  `sArcNone`
    Don't suppress architectural processing for the descendants of this element.

  The value may also be implied, in which case the state of architectural processing is inherited.

  If an element has an ArcSuprA attribute that was processed, its ArcFormA attribute will always be processed. Otherwise its ArcFormA attribute will be processed unless its closest ancestor that has a non-implied value for the ArcSuprA attribute suppressed processing of the ArcFormA attribute. An element whose ArcFormA attribute is processed will not be treated as architectural if it has an implied value for the ArcFormA attribute.

`ArcSuprF`
  The name of the element type in the meta-DTD that suppresses architectural processing in the same manner as does the `sHyTime` form in HyTime. By default, no element type does. This behaves like an element with an `ArcSuprA` attribute of `sArcForm`. The element type should be declared in the meta-DTD. You should not specify a value for this attribute if you specified a value for the `ArcSuprA` attribute.

  This is a non-standardized extension.

`ArcIgnDA`
  The name of an attribute that elements may use to control whether data is ignored. The value of the attribute must be one of the following values:
  `nArcIgnD`
    Data is not ignored. It is an error if data occurs where not allowed by the meta-DTD.
  `cArcIgnD`
    Data is conditionally ignored. Data will be ignored only when it occurs where the meta-DTD does not allow it.
  `ArcIgnD`
    Data is always ignored.

  The value may also be implied, in which case the state of architectural processing is inherited. If no the document element has no value specified, `cArcIgnD` will be used.

`ArcBridF`
  The name of a default element type declared in a meta-DTD, to which elements in the document should be automatically mapped if they have an ID and would not otherwise be considered architectural. This would be `HyBrid` for HyTime. If your meta-DTD declares IDREF attributes, it will usually be appropriate to specify a value for `ArcBridF`, and to declare an ID attribute for that form in your meta-DTD.
`ArcDataF`
  The name of a default notation declared in the meta-DTD, to which the external data entities in the document should be automatically mapped if they would not otherwise be considered architectural. If this attribute is defined, then general entities will be automatically architectural: any external data entity whose notation cannot otherwise be mapped into a notation in the meta-DTD will be automatically treated as an instance of the `ArcDataF` notation. This would be `data` for HyTime. If your meta-DTD declares entity attributes, it will usually be appropriate to specify a value for `ArcDataF` even if your meta-DTD declares no data attributes for the notation.
`ArcAuto`
  This must have one of the following values:
  `ArcAuto`
    If an element does not have an `ArcFormA` attribute and the meta-DTD defines an element type with the same name as the element's type, the element will be automatically treated as being an instance of the meta-type. This rule does not apply to the document element type; this is automatically treated as being an instance of the meta-DTD's document element type. Note that this automatic mapping is prevented if the element has an `ArcFormA` attribute with an implied value. It is also prevented if processing of the `ArcFormA` attribute is suppressed. This applies equally to the notations of external data entities. The default element or notation specified with the `ArcBridF` or `ArcDfltN` attribute is only considered after the mapping specified by `ArcAuto`.
  `nArcAuto`
    Automatic mapping is not performed.

  The default value is `ArcAuto`.

`ArcOptSA`
  A list of names of architectural support attributes, each of which is interpreted as a list of parameter entities to be defined with a replacement text of `INCLUDE` when parsing the meta-DTD. The default value is `ArcOpt`.

## Meta-DTDs

A meta-DTD is allowed to use the following extensions:

- a single element type or notation is allowed to be an associated element type or associated notation name for multiple attribute definition lists.
- `#ALL` can be used as an associated element type or associated notation name in an attribute definition list to define attributes for all element types or notations in the meta-DTD

Before any of these extensions can be used, the meta-DTD must include a declaration

    <!AFDR "ISO/IEC 10744:1997">

This declaration should only be included if the extensions are used.

In all other respects a meta-DTD must be a valid SGML DTD.

A declared value of ENTITY for an attribute in a meta-DTD means that the value of the attribute must be an entity declared in the (non-meta) DTD that is architectural. An external data entity is architectural only if its notation can be mapped into a notation in the meta-DTD. All other kinds of data entities and subdoc entities are automatically architectural.

An IDREF attribute in the meta-document must have a corresponding ID in the meta-document. An attribute with a declared value of ID in the document will be automatically mapped to an attribute with a declared value of ID in the meta-DTD.

A declared value of NOTATION in the meta-DTD means that the value of the attribute must have one the values specified in the name group and that it must be a notation in the meta-DTD. (Perhaps if the attribute also has a declared value of NOTATION in the non-meta-DTD, the value should be mapped in a similar way to the notation of an external data entity.)

## Differences from HyTime

There are a number of differences from how architectural processing is defined in the pre-Corringendum version of the HyTime standard.

- The `ArcNamrA` and `ArcFormA` attributes are not part of the meta-DTD. Rather they are used by the architecture engine in deriving the meta-document that is validated against the meta-DTD.
- The `use:` conventional comment is not recognized. Instead a single element type is allowed to be an associated element type for multiple attribute definition lists.
- The notation and data attributes of an external data entity are treated just like the element type and attributes of an element. The notation of an external data entity is mapped into a notation in the meta-DTD and the data attributes of the entity are mapped onto attributes defined for the meta-DTD notation.
- `#FIXED` has the same meaning in a meta-DTD that it does in a regular DTD: the value of the attribute must be the same as the default value of the attribute specified in the meta-DTD.

## Specifying architectural processing with an LPD

Link attributes defined by an implicit link process are treated in the same way as non-link attributes. The only complication is that SGML allows link attributes to have the same name as non-link attributes. If there is a link attribute and a non-link attribute with the same name, the architecture engine will only look at the link attribute, even if the value of the link attribute is implied. The only exception is the `ArcNamrA` attribute: the architecture engine will use both the link attribute and the non-link attribute, but the substitute names in the value of the non-link attribute cannot refer to link attribute names.

The `-A archname` option automatically activates any link type `archname`.

The architecture notation declaration and associated attribute definition list declaration are allowed in the LPD. Although the productions of ISO 8879 do not allow a notation declaration in a link type declaration subset, it is clearly the intent of the standard that they be allowed. You can use a `-wlpd-notation` option to disallow them.

## Derived architectures

A meta-DTD can have one or more base architectures in the same way as a normal DTD. Multiple `-A` options can be used to exploit this. For example,

    -A arch1 -A arch2

will perform architectural processing on the source document to produce an architectural document conforming to the architecture `arch1` declared in the source document, and will then perform architectural processing on this architectural document to produce an architectural document conforming to the `arch2` architecture declared in `arch1`'s meta-DTD.

A document that is validated against a meta-DTD will automatically be validated against any base architectures of that meta-DTD.

## Unimplemented features

The following features from the AFDR specification in HyTime 2nd edition are not yet implemented:

- use of `#MAPTOKEN` in the architectural attribute renamer.