schematron-quickfix / sqf

Schematron Quick Fixes
25 stars 6 forks source link

Variable lateFix_dXXeYY has not been declared bug #24

Closed yamahito closed 4 years ago

yamahito commented 4 years ago

Hi Folks,

I note the above error in some schemtron I'm writing in oXygen (21.1): looks like a potential bug?

Here is the schematron file:

<?xml version="1.0" encoding="UTF-8"?>
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron"
  xmlns:slide="https://schema.expertml.com/training-slides"  queryBinding="xslt2"
  xmlns:sqf="http://www.schematron-quickfix.com/validator/process">

  <sch:ns uri="https://schema.expertml.com/training-slides" prefix="slide"/>

  <sch:pattern>

    <sch:rule context="*:slide">
      <sch:extends rule="SlideNS"/>
    </sch:rule>

  </sch:pattern>

  <sch:pattern id="abstracts">
    <sch:rule abstract="true" id="SlideNS">
      <sch:assert id="SlideNSa1" test="prefix-from-QName(node-name(.)) eq 'slide'" role="warning" sqf:fix="fixSlideNS">Prefer the 'slide' prefix</sch:assert>   
    </sch:rule>
  </sch:pattern>

  <sqf:fixes>
    <sqf:fix id="fixSlideNS">
      <sqf:description>
        <sqf:title>Replace namespace with slide:</sqf:title>
      </sqf:description>
      <sqf:replace node-type="element" target="slide:{local-name(.)}">
        <sqf:copy-of select="@*"/>
        <sqf:copy-of select="node()"/>
      </sqf:replace>
    </sqf:fix>
  </sqf:fixes>

</sch:schema>

Removing the reference to fixSlideNS in the abstract rule 'fixes' the error message (but makes the whole thing pointless!)

yamahito commented 4 years ago

Are you not allowed to have quick fixes on abstract rules?

yamahito commented 4 years ago

Also tried moving the sqf:fix into the abstract rule: no joy.

nkutsche commented 4 years ago

I think the SQF part is correct. (I'm not sure if the Schematron part it is too, but the Oxygen accepts it without the QuickFixes.) The error message is really suprising and you may should add it to the issue description - I had to try out to understand what you mean. (Btw. I used Oxygen 20.1 and I got the same)

I think this has to be forwarded to @octavianN.

octavianN commented 4 years ago

Hi Tom,

Thanks for you feedback and sorry for the late response. I was on vacation and I missed the email. Yes, it seems to be a problem with the quick fix compilation in this case. In Oxygen we generate some ids for the fixes that will be executed. In this case the ids are not generated correctly, probably because of the "sch:extends". I will add an issue on the Oxygen issue tracker to correct the problem,

Best Regards, Octavian

yamahito commented 4 years ago

Thanks, Octavian! I hope you had a nice holiday ;)

octavianN commented 4 years ago

It seems that the abstract rule should be added in the same pattern element. This is from Schematron 2016 specification:

When the rule element has the attribute abstract with a value true, then the rule is an abstract rule. An abstract rule shall not have a context attribute. An abstract rule is a list of assertions that will be invoked by other rules belonging to the same pattern using the extends element. Abstract rules provide a mechanism for reducing schema size