TEIC / atop

Another TEI ODD Processor
Other
9 stars 2 forks source link

Clarify how to obtain a QName from an elementSpec #6

Closed dmj closed 10 months ago

dmj commented 2 years ago

The <elementSpec> documents the structure, content, and purpose of a single element type. An XML element has a name which is a QName consisting of a possibly empty namespace URI, an optional prefix and a local name. The QName of a specified element is obtained as followed:

  1. The namespace URI is 'http://www.tei-c.org/ns/1.0' unless specified otherwise in the @ns attribute.
  2. The local name is specified by the @ident attribute.

The QName of a specified element thus can be constructed as follows:

QName( (@ns, 'http://www.tei-c.org/ns/1.0')[1], @ident)

sydb commented 2 years ago

Actually, if there is an <altIdent> (or <altIdent>s) that gets grabbed as the local name. So something like QName( ( @ns, ''http://www.tei-c.org/ns/1.0')[1], ( child::tei:altIdent[ lang( $currentLanguage ) ], @ident )[1] ).

sydb commented 2 years ago

Except that we have just decided that a pre-processing step should ensure that there is only 1 <altIdent> (of the proper language) child of any given <*Spec> element, or only 1 that is annotated in some way that tells processor to use it. Thus: QName( ( @ns, ''http://www.tei-c.org/ns/1.0')[1], ( child::tei:altIdent[ WHATEVER ], @ident )[1] ), where [ WHATEVER ] is not needed if we decide on only 1, or is [ @atop:useMe eq 'true'] or whatever.

dmj commented 2 years ago

To summarize the reasoning pro pre-processor: The altIdent supplies the recommended XML name for an element, class, attribute, etc. in some language. An elementSpec can have zero or more altIdent elements. When transpiling ODD to RNG we do not know which one to use or (!) if we should use altIdent over @‍ident at all.

For the transpiler we might define the following rules:

-or-

martindholmes commented 2 years ago

@sydb Is the pre-processing step that eliminates unwanted altIdents for other languages part of the creation of the processedODD? If so, aren't we going against what Council recommended wrt languages, that we preserve all language versions through the entire process up to the RNG generation?

dmj commented 2 years ago

@martindholmes ATOP will have two steps: a) process the source ODD to create a fully functional ODD w/ all external references resolved and b) transpile this ODD to a RelaxNG grammar. Removing ambiguities is the first part of the second step.

@all: What about the @ns attribute of the containing schemaSpec?

Does

<schemaSpec ns="http://example.com/ns">
  <elementSpec ident="foobar"/>
</schemaSpec>

mean that the namespace URI of the element 'foobar' is 'http://example.com/ns'? In other words: Does an elementSpec inherit the @ns from an ancestor schemaSpec?

martindholmes commented 2 years ago

@dmj That's what I meant: the ambiguity fixes take place as part of a first pass in the second phase.

One reason I would like us to clarify our nomenclature is to make it easier to talk about these things:

https://github.com/TEIC/atop/wiki/Terminology

sydb commented 2 years ago

See TEIC/TEI#2285.

martindholmes commented 10 months ago

@sydb, @HelenaSabel and I 2023-12-06: We see the current implementation of atop:get-element-qname() as correct and fully functional in the context of transpilation. However, we're now wondering how this bears on the question of how we decide when a downstream elementSpec constitutes a modification of an upstream one. Is it:

  1. When the @ident and the effective namespace are identical; or
  2. Whenever the @ident attribute matches.

It appears that the current Stylesheets require no. 2; that means that @ident is crucial and the only thing which matches a downstream modification to an upstream declaration is that attribute. This means that you can't use a modification to change the namespace of an element. But presumably nobody has ever tried to do this.