zme1 / toscana

A repository to house research and web development for the Lega Toscana project, led by professor Lina Insana (Spring 2018) and professor Lorraine Denman (Fall 2018), and with consultation from members of the DH Advanced Praxis group at the University of Pittsburgh at Greensburg.
http://toscana.newtfire.org
3 stars 1 forks source link

Customizing with non-TEI attributes #50

Closed zme1 closed 6 years ago

zme1 commented 6 years ago

I've been reading through Chapter 23 of the TEI guidelines on customization, and in particular the section on generating non-TEI attributes. I adapted the reading and examples to try adding a home-brewed attribute of mine into my ODD file, and I was met with an angry red square. A snippet of my code (also pushed to the master branch) is below

<elementSpec ident="w" mode="change" module="analysis">
          <attList>
            <attDef ident="gender" ns="http://toscana.newtfire.org" mode="add" usage="rec">
              <desc>This attribute identifies the gender of any anglicisms that are nouns.</desc>
              <datatype>
                <dataRef key="teidata.word"/>
              </datatype>
              <valList type="closed">
                <valItem ident="m"/>
                <valItem ident="f"/>
              </valList>
            </attDef>
          </attList>
        </elementSpec>

The thing I may have gotten incorrect is the datatype declaration. I'm not certain if the datatype declaration is even obligatory (although my corpus was flagged without it in the ODD as well), and I'm trying to find an accommodating datatype in the event that it is. Aside from that, this schema writing is really no different than what I've written in the past -- the only differences being a new namespace, and potentially a declared datatype. The w element processes just fine in my corpus file; it only flags them when the attribute is added. @ebeshero Do you have any hints or examples as far as building new attributes are concerned?

zme1 commented 6 years ago

If you can't figure out what the problem is after looking and looking, it's probably.....

.....drumroll.....

A namespace issue!

Stay tuned...

zme1 commented 6 years ago

@ebeshero I cracked it! Huzzah! I declared the Toscana namespace for these non-TEI attributes, but I didn't embed that namespace into my corpus file, so it had nothing to "validate against" -- although it seems like the TEI guidelines describe these custom "namespaces" as empty anyhow...

In any case, I added an attribute to the teiCorpus opening tag: @xmlns:tos="http://toscana.newtfire.org". Now, with the use of that prefix with any of my customized attributes, the green square returns! @ebeshero would you mind telling me if this seems to be the correct way to address this when you see this?

zme1 commented 6 years ago

PS. I also removed the @dataRef attribute. Since I'm not using any of the TEI data types, I don't think it makes sense to have it in there.

ebeshero commented 6 years ago

Huzzah! I will take a look soon--probably after my talk tomorrow AM

Sent from my iPhone

On Sep 12, 2018, at 8:33 AM, zme1 notifications@github.com wrote:

PS. I also removed the @dataRef attribute. Since I'm not using any of the TEI data types, I don't think it makes sense to have it in there.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

zme1 commented 6 years ago

@ebeshero Alas, I've encountered new namespace declaration problems. I'm currently writing Schematron rules to link a handful of related attribute values (@tos:preserve, @tos:eng, and @tos:char). When I process my ODD file with Schematron constraints that require specific combinations of these values, my error message reads:

"F [ISO Schematron] Namespace prefix 'tos' has not been declared"

To try to remedy this, I entered the Toscana namespace with the tos prefix in my TEI root element of the ODD file (alongside the tei, sch, and rng namespace declarations), but that did not validate the ODD. I also tried writing an inline namespace declaration on the <sch:rule> element, but that also didn't seem to help. I'm uncertain as to where else this error message could be referring. I've pasted a copy of one of my schematron rules below:

<constraintSpec ident="preserve-eng" scheme="schematron">
          <constraint>
            <sch:rule xmlns:sch="http://purl.oclc.org/dsdl/schematron" xmlns:tos="http://toscana.newtfire.org"
              context="tei:w[@tos:preserve='y']">
              <sch:assert test="@tos:eng">If there are non-Italian characters preserved in an anglicism,
                you must specify whether it's an un-Italian character ('y'), or an ungrammatical sequence of letters ('n').</sch:assert>
            </sch:rule>
          </constraint>
        </constraintSpec>
zme1 commented 6 years ago

@ebeshero I found my error... instead of declaring the namespace in my sch:rule element, I needed to write in a separate sch:ns element directly inside my constraint element like the one below:

<sch:ns uri="http://toscana.newtfire.org" prefix="tos"/>

Many thanks, @ebeshero, your rubber duck mentoring is doing wonders for me this week!!

ebeshero commented 6 years ago

@zme1 Sorry for not being alert enough at the ends of my days in Tokyo to properly track this--I was jet-lagged while there, and now I'm jet-lagged back home--the 12-hour time difference is literally the difference between night and day. Anyway, I'm glad you got this working--but I am also wondering why / whether it is necessary to move the TEI attributes into your project namespace. Generally speaking, it's best to avoid doing this because it potentially renders your project inconsistent with the TEI. That is, you ought to have a good reason for it. From what I can see, you're just customizing which attributes appear on which elements, and your use of these attributes isn't exactly different from the TEI's--is it? Can you explain why this namespacing is necessary?

ebeshero commented 6 years ago

@zme1 Okay, granted @tos:eng doesn't seem to have a TEI equivalent. But see my earlier post: Is there an easier way to track this information with just one or two attributes?