New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ODD processing and custom attributes (of existing names) #237

Open
pdaengeli opened this Issue Mar 9, 2017 · 6 comments

Comments

Projects
None yet
4 participants
@pdaengeli
Copy link

pdaengeli commented Mar 9, 2017

The stylesheets (ODD to RNG) seem in some cases to produce output that is invalid. This happens when trying to create attributes in a custom namespace, that already exist with the same local-name in the tei namespace (e.g. @n, @type, @target, @unit, @source; it works for others such as @subtype or @select).

I get the following two types of errors:

  • duplicate attribute "unit" (for e.g. @unit)
  • reference to undefined pattern "tei_att.global.attribute.n" (for e.g. @n)

Is this an intentional limitation? Shouldn't non-TEI namespaces have full autonomy?

Or am I approaching this the wrong way?
I tried with:

<classSpec ident="att.global" type="atts" mode="change" module="tei">

    <attList>

        <attDef ident="n" ns="http://www.cceh.uni-koeln.de/hal/ns/1.0">

            <desc>The 'hal:n' attribute stores legacy information to keep track of the origin of the text value of its parent element.</desc>

            <datatype>

                <rng:text/>

            </datatype>

        </attDef>

    </attList>
</classSpec>

which led to the errors mentioned above, but also with <attDef ident="hal:n" ns="http://www.cceh.uni-koeln.de/hal/ns/1.0">, which in fact allowed to define any attribute, however the namespace prefix was undefined in the output.

Some hints on how to set up such attributes (of the same name but in a custom namespace) in an ODD specification would be appreciated. I couldn't find much information on this (other than the inclusion of externally defined namespaces such as svg).

@martindholmes

This comment has been minimized.

Copy link
Contributor

martindholmes commented Mar 9, 2017

One minor point: regular TEI attributes are not in the TEI namespace, they're in the empty namespace. By definition, all unprefixed attributes are in the empty namespace; they don't inherit the namespace of their parent element. That's an XML thing, not a TEI thing.

@pdaengeli

This comment has been minimized.

Copy link

pdaengeli commented Mar 9, 2017

Ok, that makes sense. But an attribute in a namespace should generally be able to co-exist with an unqualified one of the same local-name, shouldn't it?

@jamescummings

This comment has been minimized.

Copy link
Member

jamescummings commented Mar 10, 2017

@pdaengeli Definitely an attribute in a namespace with the same local name should be able to co-exist with an unqualified one with the same local-name. I'll try to do some tests today to see if I can duplicate the bug.

@lb42

This comment has been minimized.

Copy link
Member

lb42 commented Mar 10, 2017

I can confirm that I can replicate this bug/feature of the stylesheets. If you add a non-TEI element with the same name as an existing TEI element, you can use the attribute @Prefix on <elementSpec> to ensure that the pattern generated from the name in the RelaxNG remains unique. But there is no analogous facility for attributes, partly because TEI attributes don't belong to any namespace (as Martin points out), partly because nobody thought of providing it. You could of course just call your new attribute "notN" or something to show that it's different.

@jamescummings

This comment has been minimized.

Copy link
Member

jamescummings commented Mar 10, 2017

Just to say that I can confirm this as well. I added some new attributes to the TEI element using the tei_math.odd exemplar as a starting point (since I wanted something that worked using another namespace already. ;-) ) Adding a new attribute in another namespace of course worked fine. Adding a new attribute in another namespace that has the same local-name as an existing TEI element did not work.

The ODD I used is: https://gist.github.com/jamescummings/155429676474d9416b8251c717776657

And the define element in the RNG it produced was:

 <define name="tei_TEI">
      <element name="TEI">
         <a:documentation xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0">(TEI document) contains a single TEI-conformant document, combining a single TEI header with one or more members of the model.resourceLike class. Multiple TEI elements may be combined to form a teiCorpus element. [4. Default Text Structure 15.1. Varieties of Composite Text]</a:documentation>
         <group>
            <ref name="tei_teiHeader"/>
            <oneOrMore>
               <ref name="tei_model.resourceLike"/>
            </oneOrMore>
         </group>
         <ns xmlns="http://purl.oclc.org/dsdl/schematron"
             prefix="tei"
             uri="http://www.tei-c.org/ns/1.0"/>
         <ns xmlns="http://purl.oclc.org/dsdl/schematron"
             prefix="xs"
             uri="http://www.w3.org/2001/XMLSchema"/>
         <ns xmlns="http://purl.oclc.org/dsdl/schematron"
             prefix="rng"
             uri="http://relaxng.org/ns/structure/1.0"/>
         <ref name="tei_att.global.attribute.xmlid"/>
         <ref name="tei_att.global.attribute.xmllang"/>
         <ref name="tei_att.global.attribute.xmlbase"/>
         <ref name="tei_att.global.attribute.xmlspace"/>
         <ref name="tei_att.global.rendition.attribute.rend"/>
         <ref name="tei_att.global.rendition.attribute.style"/>
         <ref name="tei_att.global.rendition.attribute.rendition"/>
         <ref name="tei_att.global.responsibility.attribute.cert"/>
         <ref name="tei_att.global.responsibility.attribute.resp"/>
         <ref name="tei_att.global.source.attribute.source"/>
         <ref name="tei_att.typed.attributes"/>
         <optional>
            <attribute name="n" ns="http://www.w3.org/1998/Math/MathML">
               <a:documentation xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"/>
               <choice>
                  <value>NValue</value>
                  <a:documentation xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0">NValue</a:documentation>
               </choice>
            </attribute>
         </optional>
         <optional>
            <attribute name="blort" ns="http://www.w3.org/1998/Math/MathML">
               <a:documentation xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"/>
               <choice>
                  <value>foo</value>
                  <a:documentation xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0">foo</a:documentation>
               </choice>
            </attribute>
         </optional>
         <optional>
            <attribute name="n" ns="http://www.w3.org/1998/Math/MathML">
               <a:documentation xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"/>
               <choice>
                  <value>NValue</value>
                  <a:documentation xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0">NValue</a:documentation>
               </choice>
            </attribute>
         </optional>
         <optional>
            <attribute name="version">
               <a:documentation xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0">specifies the major version number of the TEI Guidelines against which this document is valid.</a:documentation>
               <data type="token">
                  <param name="pattern">[\d]+(\.[\d]+){0,2}</param>
               </data>
            </attribute>
         </optional>
         <empty/>
      </element>
   </define>

Where you can see there are two optional/attribute elements for n attribute in the mathml namespace. For some reason our processing is doing its job twice here.

However, I note that if I delete this additional optional element for the mathml:n attribute, it doesn't suddenly let me use the TEI global n attribute here. So two things are wrong I think.

@jamescummings jamescummings added the bug label Mar 10, 2017

@pdaengeli

This comment has been minimized.

Copy link

pdaengeli commented Mar 10, 2017

Thank you for testing, @jamescummings and @lb42.

Perhaps the problem pointed out by @lb42 is related to mode="add". I left this out in my ODD (which is very close to this gist) following a hint on TEI-L by Sebastian Rahtz from long ago: https://listserv.brown.edu/archives/cgi-bin/wa?A2=TEI-L;95cce31d.0605

Did you also try this with @subtype or @select? Other than @n they don't seem to clash (both using Lou's and my example).

For my actual use case I'll use @hal:desc, which is unproblematic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment