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

Support Ant error levels #50

Closed
stefan-jung opened this issue Aug 16, 2017 · 21 comments
Closed

Support Ant error levels #50

stefan-jung opened this issue Aug 16, 2017 · 21 comments
Assignees
Milestone

Comments

@stefan-jung
Copy link

stefan-jung commented Aug 16, 2017

Unfortunately error levels are not supported, see #16. I've changed the <report> level to warning, so the build should throw a warning and no error and should not fail. Builds should fail only on fatal or error.

Current output

[schematron] Validating XML file '/tmp/temp20170816172804143/topic-1.dita' against Schematron rules from 'topic-validation.sch' expecting success
[schematron] 1 Schematron errors for XML file '/tmp/temp20170816172804143/topic-1.dita'
[schematron] [error] in /topic/title @ /tmp/temp20170816172804143/topic-1.dita 
[schematron]                 Do not use inline formatting in <title>
[schematron]              Test=*[contains(@class, 'hi-d/')]

It would be nice, if the output would be one line per <report>/<assert>. This would make it easier to implement a log parser/filter. I'd recommend (as a replacement for the snippet above):

[schematron] /tmp/temp20170816172804143/topic-1.dita:4: [WARNING]: Do not use inline formatting in <title>

Note: The :4 shout mean line 4. I think the line is important to find the position of the error quickly. The test that fired the report/assert is not important, I think.

@phax phax self-assigned this Aug 16, 2017
@phax phax added this to the v5.0.0 milestone Aug 16, 2017
phax added a commit that referenced this issue Aug 16, 2017
@phax
Copy link
Owner

phax commented Aug 16, 2017

I followed your suggested, trimed stuff and added error handling support. But unfortunately the source XML position cannot be emitted, because it is not part of the created SVRL

@stefan-jung
Copy link
Author

Hmm... that's a pity. 😞
Should I add line support as a new enhancement issue? If you use Schematron for validating DITA-XML, so to check style guide rules, the line is absolutely mandatory to find the violating snippet.

The library used in oXygen XML is able to determine the line:

System-ID: /home/stefan/workspace/org.doctales.schematron/samples/topic-1.dita
Haupt-Validierungsdatei: /home/stefan/workspace/org.doctales.schematron/samples/topic-1.dita
Schema: /home/stefan/workspace/org.doctales.schematron/rules/topic-validation.sch
Programmname: ISO Schematron
Fehlerlevel: warning
Beschreibung: Do not use inline formatting in <title>
Anfang: 4:0

So if you're stuck somewhere and just need food for thought, maybe dropping a line to them might help. They'll surely strongly appreciate your work.

@phax
Copy link
Owner

phax commented Aug 17, 2017

I will dig into the Locator API and see what I can do...

@stefan-jung
Copy link
Author

stefan-jung commented Aug 22, 2017

@phax
Copy link
Owner

phax commented Aug 22, 2017

Haha - weird side effects :)
I was thinking more like:

if (byte stream used) then
{
  1. XML Charset detection via new class https://github.com/phax/ph-commons/blob/master/ph-xml/src/main/java/com/helger/xml/serialize/read/XMLCharsetDeterminator.java
  2. Instantiating a special Reader that uses the charset from step 1. and includes line counting (with the problem that the Locator is only updated AFTER something was read)
  3. Enforce all DOM reading to use SAX reading with the Locator (or Locator2) based on the position of the Reader in step 2
}

-> if this helps as well - I'm happy :)

@fviolette
Copy link

Defintiely +1 on level support: would further improve the lib usage via ANT, dramatically.

@phax
Copy link
Owner

phax commented Aug 31, 2017

Level support is already in

@fviolette
Copy link

Right, I can see the error level in the logs. Alluding to the original request of making builds fail only on fatal or error.

@phax phax added the ANT task label Nov 2, 2017
@phax phax modified the milestones: v5.0.0, v5.1 Jan 3, 2018
@stefan-jung
Copy link
Author

stefan-jung commented Jan 3, 2018

Thanks for the new release @phax!

Log levels still do not work as expected.

Schematron

<?xml version="1.0" encoding="UTF-8"?>
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt">
    <sch:pattern>
        <sch:rule context="*[contains(@class, 'topic/title')]">
            <sch:report test="*[contains(@class, 'hi-d/')]" role="warning">
                Do not use inline formatting in &lt;title&gt;
            </sch:report>
        </sch:rule>
    </sch:pattern>
</sch:schema>

This should create a warning, but leads to an error:

  [error] in /topic/title @ /tmp/temp20180103183533704/faf922d8f51b3838f7fbdbae96dd1460d7fac5ae.dita Do not use inline formatting in <title>

See build #31

Then the build crashes and this should not happen for warnings.

@phax
Copy link
Owner

phax commented Jan 3, 2018

Thanks for testing. I needed to get 5.0 out because of other dependencies - that's why I postponed this to 5.1 :(

@fviolette
Copy link

I was confused by the addition of the failOnError parameter initially, thanks for the reminder!
This is indeed required to create better reports and not have to artificially create phases.

@phax
Copy link
Owner

phax commented Mar 22, 2018

I looked a bit into it and I'm currently only interpreting the flag attribute but not the role attribute. I will make a change that will take the role attribute if the flag attribute is not present

@stefan-jung
Copy link
Author

Excellent 😃

@phax
Copy link
Owner

phax commented Mar 22, 2018

@phax
Copy link
Owner

phax commented Mar 22, 2018

v5.0.2 SNAPSHOT 17 and later should do the trick: https://oss.sonatype.org/content/repositories/snapshots/com/helger/ph-schematron/5.0.2-SNAPSHOT/

@stale
Copy link

stale bot commented May 14, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label May 14, 2019
@phax
Copy link
Owner

phax commented May 15, 2019

@xephon2 if you could crosscheck, it would be appreicated :)

@stale stale bot removed the wontfix label May 15, 2019
@stefan-jung
Copy link
Author

@phax, will try to do so.

@stefan-jung
Copy link
Author

stefan-jung commented May 16, 2019

As the log shows, nothing has changed.

  • Tried latest stable release of ph-schematron 5.0.10.
  • Warnings are not echoed as shown in the log.
  • Build does not fail, but property has been set correctly.

@phax
Copy link
Owner

phax commented May 17, 2019

Thank you @xephon2 for your input.

  • I think I resolved the issue with the missing log output - now all SVRL results are logged
  • Concerning the build not failing, there is a slight misunderstanding I assume. I currently only support the property failOnError but nothing else. And this property applies not just to SVRL results but also to other criticial issues (e.g. IO errors). If I understand you correctly, you need something to break your build only depending on the validation output (SVRL).
    The following example assumes you expect a successful validation. So if an error is in SVRL and "fail on error" is true, the build should be aborted. If The SVRL contains at least one warning and "fail on warning" is true, the build should be aborted etc. Is this assumption correct? In that case I would need to create new properties like failOnSVRLError, failOnSVRLWarning and failOnSVRLInfo - does that sound reasonable?

@phax
Copy link
Owner

phax commented May 28, 2019

Finally fixed in 5.0.11

@phax phax closed this as completed May 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants