# Automatic transformation of XML namespaces/User options

User option can specify either:
* to validate an XML document;
* to run the pipeline (see below) of transformations.
The following user options are supplied for both pipeline and validation:
* the source XML document;
* a (possibly empty) ordered set of RDF files (RDF files which are downloaded before main loop);
* whether to do recursive download;
* (if recursive download is on) recursive retrieval order: an ordered subset of the three-element set {script sources, script targets, workflow targets};
* whether to abort processing an RDF file if there is any error in it. (Implementation node: It is easier to program when this option is false.)
* a list of nonempty lists whose members are retrieval methods (for example, a mapping from a namespace to a local file, retrieval from the namespace URL, etc.)
If the pipeline should be run, receive also the following user options:
* the RDF file with a workflow (see below);
* either the workflow URL (see below);
* What to do if after running an automatic transformation there are elements or attributes which are not in the target namespaces of the transformer: ignore (and leave these elements and attributes as it), erase these elements and attributes, or fail with an error.
* universal precedence (an RDF resource which specifies a set of transformers which may be applied even if the destination namespace does not match). Example: transformer for XInclude may have no target namespaces but be applied nevertheless if the universal precedence is low enough.
* Script and transformer classes (see the example below).
If the validation should be run, receive also the following user options:
* Deep-first or breadth first validation.
* Whether presence of unknown namespaces makes the document invalid.
If recursive download is on, it also should be specified whether to search depth-first or breadth-first.
The user specifies whether to prefer a transformer in the RDF describing the source namespace or in the RDF describing the target namespace. This influences only what (and in what order) RDF resources are loaded. After an RDF is loaded it is subject to “first loaded” rule below.
RDFs loaded earlier take precedence over RDFs loaded later. (Note: This facilitates uniformity of transformations and validations in the sense that different transformers and validation rules are not applied to the same namespaces.)
Note that objects IRI in user options should be paired with the IRI of the RDF file where it is defined. (Thus we resolve the case if the same IRI is used in two or more different RDF files.)

## Script and transformer classes

Script and transformer classes are specified for pairs of namespaces (see the example below).
Script class definition specifies either a particular script or a class of scripts. Likewise for transformers.
Remark: It is OK to specify either a script or a class, because a class of scripts cannot be a script. (Can we prove it?)
TODO: In a below chapter specify how these are used. Also specify how belonging to a class is determined.

## Workflow
### RDF grammar trees

* :Transformer
** 1..1 :source
** 1..1 :object
* :Script
** 1..1 :source
** 1..1 :object
* :Auto
** 1..* :url
It is erroneous for a single object to be of more than one of the following classes: :Transformer, :Script, :Auto.
For a single object it must be specified no more than one :workflow predicate. The subject of the :workflow predicate must be a list whose elements are :Transformer, :Script, or :Auto.
Any validity errors in workflow are fatal.
It is recommended that instead of a workflow, we can just specify a set of IRIs (namespaces). In this case the workflow consists of one automatic transformation with the specified target namespaces.

### Semantic

It is meant to process giving the source XML document to the first element of the workflow list, the result to the second element of the workflow list, and so on till the last element of the workflow list.
A workflow list can refer to a transformation (meaning to use a script of this transformation which the implementation chooses), to a particular script, or to an automatic transformation with a given set of destination URLs.
See below in this specification about meanings of scripts, transformations, and automatic transformation.
If there is given no user option about which workflow to use, the workflow represented by the object :defaultWorkflow is used, if it is available. If it is not specified which workflow to use and there are no :defaultWorkflow object, it is a fatal error.