TEIC / Stylesheets

TEI XSL Stylesheets
232 stars 124 forks source link

failure to handle alternate datatypes only in certain cases #656

Open sydb opened 8 months ago

sydb commented 8 months ago

I have discovered what I think is a very peculiar failure of the Stylesheets to produce (what I think are) proper results in only one precise situation, while producing proper results in lots of similar situations.

My goal was to have an attribute whose possible values come from two different datatypes. We do this twice, in teidata.authority[1] and teidata.probCert. But I found it did not work for me when I was trying to similarly combine two datatypes that were not defined in P5, but rather were defined in my customization ODD.

This led (eventually — this took hours) to a small test ODD (which I will attach to this ticket on my next post[2]).

But to summarize:

Given tstdata.nonsense, defined as

      <valList type="closed">
        <valItem ident="foo"/>
        <valItem ident="bear"/>
        <valItem ident="sna"/>
        <valItem ident="duck"/>
      </valList>

The datatype tstdata.probableNonsense, defined as

      <alternate>
        <dataRef key="teidata.probability"/>
        <dataRef key="tstdata.nonsense"/>
      </alternate>

correctly yields

xsd:double | ("foo" | "bear" | "sna" | "duck")

The datatype tstdata.nonsenseInterval, defined as

      <alternate>
        <dataRef key="tstdata.nonsense"/>
        <dataRef key="teidata.interval"/>
      </alternate>

correctly yields

("foo" | "bear" | "sna" | "duck") | ( xsd:float | ("regular" | "irregular" | "unknown") )

And several other similar cases work just fine. BUT, the datatype tstdata.certainNonsense, defined as

      <alternate>
        <dataRef key="teidata.certainty"/>
        <dataRef key="tstdata.nonsense"/>
      </alternate>

yields

empty

which is clearly not correct.

I wish I could say I understood at least the problem, if not the cause of the problem or a possible solution. But in fact, I do not grok why the Stylesheets only barf on the combination of tstdata.certainNonsense and teidata.certainty and not the others — nor do I know what happens if there are (lord forbid) references to more than 2 datatypes. In any case, it might be because that is the only case where both datatypes are defined directly with a <valList>, but that would be weird because some of the others contain a <valList>, too (even though it is not a direct child of <content>).

Notes [1] Which I still think was a really terrible idea. [2] In case anyone cares, I post the ODD after creating the ticket so that the ODD file can be named after the ticket number.

sydb commented 8 months ago

The file issue_656.zip contains both a customization ODD and the RELAX NG (compact syntax) generated from that ODD using the roma2.sh command with the current dev branch version of both the Stylesheets and P5. (I have not tested what happens if the .rnc file is created by Roma or oXygen or Stylesheets/bin/teitornc.)