Guessing 'list' attribute for heterogeneous lists
XML serialization
See DomLexicalProcessor.isList(..)
method:
-
If list attribute is explicitly specified, it is used.
-
If type is explicitly specified, then
-
if it’s unknown, then "no list" is assumed;
-
if it’s namespace-qualified, then the presence of list attribute is taken from the definition;
-
if it’s unqualified, and there’s at least on definition has no list attribute, then "no list" is assumed.
-
-
If type is not explicitly specified, we try to look up definition based on element name. If there’s no possible match with a list attribute, then "no list" is assumed.
So, in doubt (unqualified type name with all definitions having the list attribute or element name with at least one definition having the list attribute) we look at the content. We conclude it is a heterogeneous list if:
-
no application attributes are present,
-
and all child elements are compatible, that means they share a common "substitution head" root (and are marked as heterogeneousListItem in the schema).
Overall design considerations here are:
-
"non-list is mistakenly recognized as a heterogeneous list" → this is a BIG PROBLEM. Must be avoided.
-
"heterogeneous list is not recognized as such" → this is only a minor problem, because it is always fixable by manually putting 'list=true' in the serialized XML. However, it must not occur too often / regularly.
JSON/YAML serialization
In this case we know that we deal with heterogeneous lists when "@element" directive is present. This directive can be currently used only for heterogeneous lists and it must be present on all heterogeneous list items. Otherwise the results are unpredictable (but must probably explicit error will be raised).