Skip to content
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

classSpec @‍generate is ignored in Pure ODD content model #582

Open
dmj opened this issue Oct 21, 2022 · 5 comments
Open

classSpec @‍generate is ignored in Pure ODD content model #582

dmj opened this issue Oct 21, 2022 · 5 comments
Assignees
Labels
priority: high Relatively urgent; Council should revisit routinely. status: blocked Issue cannot be fixed until another issue is fixed (put that issue # in the comments). status: needsDiscussion Council has not yet been able to agree on how to proceed.

Comments

@dmj
Copy link
Contributor

dmj commented Oct 21, 2022

Considere the following schema specification:

<?xml version="1.0" encoding="UTF-8"?>
<TEI xmlns="http://www.tei-c.org/ns/1.0"
     xmlns:rng="http://relaxng.org/ns/structure/1.0">
  <teiHeader>
    <fileDesc>
      <titleStmt>
        <title>Title</title>
      </titleStmt>
      <publicationStmt>
        <p>Publication Information</p>
      </publicationStmt>
      <sourceDesc>
        <p>Information about the source</p>
      </sourceDesc>
    </fileDesc>
  </teiHeader>
  <text>
    <body>
      <schemaSpec ident="schema" start="root">
        <elementSpec ident="root">
          <content>
            <classRef key="content" expand="alternation"/>
          </content>
        </elementSpec>
        <classSpec ident="content" type="model" generate="sequence"/>
        <elementSpec ident="element-1">
          <classes>
            <memberOf key="content"/>
          </classes>
          <content>
            <textNode/>
          </content>
        </elementSpec>
        <elementSpec ident="element-2">
          <classes>
            <memberOf key="content"/>
          </classes>
          <content>
            <textNode/>
          </content>
        </elementSpec>
      </schemaSpec>
    </body>
  </text>
</TEI>

The classRef in the root element's content model asks the transpiler to create an alternation of the class members ("any one member of the class may appear"), the classSpec on the other hand declares that the members of the class are to be provided in sequence.

From my understanding this should result in an error. The stylesheets (Version 4.4.0, Last updated on 19th April 2022, revision ff9cc28b0) seem to ignore the classSpec/@‍generate.

<?xml version="1.0" encoding="utf-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
         xmlns:tei="http://www.tei-c.org/ns/1.0"
         xmlns:teix="http://www.tei-c.org/ns/Examples"
         xmlns:xlink="http://www.w3.org/1999/xlink"
         datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
         ns="http://www.tei-c.org/ns/1.0"><!--
Schema generated from ODD source 2022-10-21T11:51:55Z. .
TEI Edition: Version 4.4.0. Last updated on
        19th April 2022, revision ff9cc28b0
TEI Edition Location: https://www.tei-c.org/Vault/P5/Version 4.4.0/
  
--><!---->
   <sch:ns xmlns:sch="http://purl.oclc.org/dsdl/schematron"
           prefix="tei"
           uri="http://www.tei-c.org/ns/1.0"/>
   <define name="root">
      <element name="root">
         <a:documentation xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"/>
         <choice>
            <ref name="element-1"/>
            <ref name="element-2"/>
         </choice>
      </element>
   </define>
   <define name="element-1">
      <element name="element-1">
         <a:documentation xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"/>
         <text/>
      </element>
   </define>
   <define name="element-2">
      <element name="element-2">
         <a:documentation xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"/>
         <text/>
      </element>
   </define>
   <start>
      <choice>
         <ref name="root"/>
      </choice>
   </start>
</grammar>
@ebeshero
Copy link
Member

Thanks @dmj! We should probably test the behavior of @generate on a sample ODD and its outputs in this context and see what we can do...It might not generate an error, but I'm also wondering under what conditions <classSpec> is ignored or overruled.

@ebeshero ebeshero added the resp: StylesheetsGroup Issue is suitable for the group-learning approach taken in the Stylesheets Coop Working Group. label Oct 31, 2022
@lb42
Copy link
Member

lb42 commented Nov 11, 2022

I agree with you that this is an error which should be detected by the ODD processor

@HelenaSabel HelenaSabel added the status: needsDiscussion Council has not yet been able to agree on how to proceed. label Dec 1, 2022
@sydb
Copy link
Member

sydb commented Dec 1, 2022

I have to admit, at the moment I am not sure I understand the reason for the existence of @generate of <classSpec>. Thus I am wondering (aloud) if we could just drop it, and thus avoid conflicts between it and @expand of <classRef>.

@sydb sydb added the status: blocked Issue cannot be fixed until another issue is fixed (put that issue # in the comments). label Dec 1, 2022
@HelenaSabel HelenaSabel removed the resp: StylesheetsGroup Issue is suitable for the group-learning approach taken in the Stylesheets Coop Working Group. label Dec 1, 2022
@sydb
Copy link
Member

sydb commented Dec 1, 2022

We are considering this blocked until we decide whether or not to keep @generate at all, or to have some constraint that would limit @expand to match @generate, or whatever, which should be discussed in TEI#2369.

@sydb
Copy link
Member

sydb commented Jun 12, 2023

I have been playing around with classes, @generate, and @expand for much of yesterday, and have discovered some horrifying (at least to me) things.

Remember as you read this that although @generate supposedly lists which values of the corresponding @expand are valid, the way that is currently done in our Stylesheets is only the patterns listed on @generate are generated (hence the mildly bizarre name of the attribute).

  • I asserted to the TEI Council two days ago that by default an "alternation" pattern is generated. According to the documentation of <classSpec>, I was wrong: “By default, all variations are permitted.”.
  • But if you actually look at the RELAX NG that is generated by the Stylesheets, some classes have all 6 patterns (the 5 named for the 5 possible values of @generate plus the plain one) and others have only 1 pattern (the plain one, which is the same as "alternation").
  • I am not sure why some have all-generated and some have only the one. But on one test I did I found something interesting. I took a class that had only the one plain pattern generated and added a classes/memberOf/@key="model.global" to it (it had no <classes> at all initially), and suddenly all 6 patterns were generated.
  • I then generated a list of all classes defined with 6 patterns in tei_all, and a list of all <classSpec>s that have a child <classes>; and, correspondingly, a list of all classes defined with 1 pattern in tei_all, and a list of all <classSpec>s that do not have a child <classes>. While there are many classes in common in each of those pairs, they are not even close to the same lists. Sigh.
  • FURTHERMORE, I was doing all this because I had noticed that the @generate was being ignored, which is why I am writing all this on this ticket.

My take on all this is that

  1. Whether we drop @generate as useless, or keep it as an extra internal semantic check on an ODD, we need to fix the Stylesheets so that all 6 patterns are always generated unless we keep @generate and it explicitly says otherwise.
  2. This is pretty high priority, because it is blocking my work on TEI ticket 2214.

Note-to-self
Commands used:

$ egrep '^model\.[A-Za-z0-9._-]+\s*=' Exemplars/tei_all.rnc | perl -pe 's,\s*=.*$,,; s,_.*$,,;' | rank | egrep ' 1 ' | sort | perl -pe 's,^\s+1 ,,;'  > /tmp/classes_only_1.txt
$ egrep '^model\.[A-Za-z0-9._-]+\s*=' Exemplars/tei_all.rnc | perl -pe 's,\s*=.*$,,; s,_.*$,,;' | rank | egrep ' 6 ' | sort | perl -pe 's,^\s+6 ,,;'  > /tmp/classes_all_6.txt
$ xsel -t -m "//t:classSpec[@type='model'][ not( t:classes ) ]" -v "@ident" -n p5subset.xml | sort > /tmp/classes_sans_classes.txt
$ xsel -t -m "//t:classSpec[@type='model'][ t:classes ]" -v "@ident" -n p5subset.xml | sort > /tmp/classes_with_classes.txt

@sydb sydb added the priority: high Relatively urgent; Council should revisit routinely. label Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: high Relatively urgent; Council should revisit routinely. status: blocked Issue cannot be fixed until another issue is fixed (put that issue # in the comments). status: needsDiscussion Council has not yet been able to agree on how to proceed.
Projects
None yet
Development

No branches or pull requests

5 participants