[oXygen-user] oXygen attribute dropdowns and Dynamic value lists from TEI generated schemas

James Cummings james at blushingbunny.net
Sun Oct 28 14:35:29 CDT 2018


Hi there,

In TEI, as many of you know, we write our schemas in the TEI ODD
customisation language and generate schemas in formats such as like Relax
NG, etc. but my question, I think, is really about the way oXygen
interprets Relax NG in providing its helpful dropdown menus, etc.

In oXygen when we have an attribute value that has a data type of anyURI
oXygen helpfully pops up a list of potential values based on listing all
the @xml:id's in the document. The problem, as I'm sure many have
encountered, is that lists all the @xml:id's not those that might make
suitable values for this attribute. Is there a way in the generated Relax
NG to somehow specify that the values are any of the descendant @xml:id's
from a particular XPath within the document (or indeed another document)?

For a use-case what I'm interested in doing in TEI is, for a particular
element customise the allowed values of the @ana attribute (which takes
multiple whitespace-separated anyURI datatype values). We often use this
attribute in TEI to point to a number of other elements including a
taxonomy of arbitrarily-deeply nested categories in the document instance
(or shared commonly between a number of document instances.)  For example:
===
     <taxonomy>
          <category xml:id="MSmaterials">
            <catDesc>A list of Manuscript Materials</catDesc>
            <category xml:id="paper">
              <catDesc>Paper</catDesc>
            </category>
            <category xml:id="parchment">
              <catDesc>Parchment</catDesc>
            </category>
          </category>
          <category xml:id="occupations">
            <catDesc>A list of occupations</catDesc>
            <category xml:id="tinker">
              <catDesc>A tinker</catDesc>
            </category>
            <category xml:id="tailor">
              <catDesc>A tailor</catDesc>
            </category>
            <category xml:id="soldier">
              <catDesc>A soldier</catDesc>
            </category>
            <category xml:id="spy">
              <catDesc>A spy</catDesc>
            </category>
          </category>
        </taxonomy>
===
Here we have two categories (MSmaterials and occupations) with a variety of
sub-categories, but that could go many levels down. When adding the @ana
attribute in oXygen the drop down would give us all of these @xml:ids and
all those elsewhere in the document.

Is there a way manually, or semi-automatically, in the Relax NG to signal
to oXygen that for elementX/@attributeY the drop-down menu in the XML
Editor should only provide @xml:ids from within descendants a particular
element (e.g. //category[@xml:id='occupations'])

In the TEI ODD customisation file, I could, of course, limit it to specific
values.... and generate Relax NG from that. We'd do that with something
like the following (embedded in an elementSpec:
===
  <attDef ident="ana" mode="change">
    <valList mode="add" type="closed">
      <valItem ident="#tinker">
        <desc>A tinker</desc>
      </valItem>
      <valItem ident="#tailor">
        <desc>A tailor</desc>
      </valItem>
      <valItem ident="#soldier">
        <desc>A soldier</desc>
      </valItem>
      <valItem ident="#spy">
        <desc>A spy</desc>
      </valItem>
    </valList>
  </attDef>
===
Which when transformed to a closed value list in Relax NG would mean that I
could choose '#tinker', '#tailor', '#soldier', '#spy' - giving hard-coded
strings that then function as URI fragments. But of course neglects that
the attribute can take multiple values in any order. Someone can reasonably
be both a spy and soldier.

I suppose I could on regenerating the schema, have the processing look up
this <taxonomy> and pull out all the values, and automatically hard-code
them in all possible particular orders, but that, I hope you agree, seems
silly and of course doesn't scale. Also it has the problem of needing to
regenerate the schema every time a new category is added. I could do this
with Schematron, I suppose, i.e. stick in a Schematron rule that says for
elementX/attributeY look up the values in
doc('taxonomy.xml')//category[@xml:id='occuptaions'], or something. But
while that might help with validation, I don't believe oXygen will pick
that up for the dropdown menu.

I have a very vague memory of someone looking working on an extension to
oXygen which did something like this (though I think externally from the
schema). If someone remembers the project I'm forgetting, please do let me
know. If there was a way to signal to oXygen from Relax NG the XPath which
to use to produce the dropdown list, then I can see us adding something
that would produce that signal to TEI ODD processing, and lots of projects
using it. Is this something that is already available, feasible, or
completely ridiculous?

Thanks for any thoughts.

James Cummings
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.oxygenxml.com/pipermail/oxygen-user/attachments/20181028/079b9d6f/attachment.html>


More information about the oXygen-user mailing list