make "spec-in-module" test less confusing#2900
Conversation
that which was recommended on issue #2898
jamescummings
left a comment
There was a problem hiding this comment.
I have not tested this rule, but the XPath looks good to me. (And the logic behind it seems to make sense, though I did have to read the very helpful note three times.)
|
@sydb If I'm understanding correctly, the last test is the one most likely to fire for most well-formed customizations:
so wouldn't it make sense to put that one first, to avoid having to evaluate the others? (I'm assuming there's no intervening optimization taking place somewhere.) |
|
Short answer, @martindholmes, is I have no idea. That is, no idea which way might be more efficient. But in my brain it is easier to figure it out if the steps are “First, see if it even makes sense to test; then, if so, do this test”. In truth, I think of <sch:rule context="( tei:elementSpec[@module] | tei:classSpec[@module] | tei:macroSpec[@module] )[
( ancestor::tei:schemaSpec | ancestor::tei:TEI | ancestor::tei:teiCorpus )
and
( //tei:moduleSpec | //tei:moduleRef ) ]">
<sch:assert test="( //tei:moduleSpec/@ident | //tei:moduleRef/@key ) = current()/@module">
Specification <sch:value-of select="@ident"/>: the value of the module attribute
("<sch:value-of select="@module"/>") should correspond to an existing module, via a
moduleSpec or moduleRef</sch:assert>
</sch:rule>That is, put all the conditions in P.S. I think it even makes the explanatory comment simpler, but not sure, I have not written it yet. 😄 |
|
I have now re-written to the new “all the logic about whether we should be looking to see if the module is defined or not in the |
martindholmes
left a comment
There was a problem hiding this comment.
Just a quibble, but could I ask for a period at the end of the sch:assert? We haven't been consistent in this in the spec files, but we should be. If it's a full sentence, it should end with a period. I should do a trawl through the rest of our Schematron and standardize this.
Done. |
|
@sydb I think by now we have most of us agreeing with the logic and syntax, but I am wondering if we actually tested it on an actual ODD in the wild? I think I could do so this afternoon and if it works, just merge this... |
|
Good question, @ebeshero. I do not know if I have ever seen this error either before or after my change. Hang on, I will try testing it (both in dev branch and this branch) against all the ODDs in the ATOP collection … |
|
(You wanna a build a test ODD file that should fail this test?) |
|
Yes--that's what I was thinking... Also, I've just been testing the branch and so far all's well there. |
|
Ha! |
|
Well! On the strength of that beautiful testing, I'm just going ahead and merge this branch! :-D |
Replace the
<constraint>"spec-in-module" with that which was recommended on issue #2898.