Page 1 of 1

Validate with Schematron in Git pre-push hook?

Posted: Sun Sep 30, 2018 5:43 am
by kirkilj
There may be a certain class of rules that want to block a writer from ever pushing to a remote git repo. We may want the schematron rules to create a failure condition, but that doesn't keep the writer from saving and then committing and pushing the content, correct? From what I've read, it seems like it should be possible as long as there's we can launch the schematron rule from a command script and catch an error code which can be used to fail the hook. Does this seem possible? Has anyone done something like this? We have Windows 10 desktops for the writers who are using Oxygen to Author. We'd need to write the hook logic in a scripting language that is pre-installed, I assume.

Re: Validate with Schematron in Git pre-push hook?

Posted: Mon Oct 01, 2018 11:28 am
by Radu
Hi John,

Indeed there are various GIT hooks but we (the Oxygen team) are not using any so we do not have experience with this. The forum is a more static place as most users receive updated only on the posts they reply to. Maybe you could register on the Oxygen Users mailing List and ask there.
What we do for our DITA-based user's guide is to run a validation task on a Jenkins server which from time to time checks if new pushes have been made to the project, so that if after a push to the server the validation task fails, people will get emails from that failed Jenkins task and they can correct their work, commit and push it again.
There is a DITA OT plugin which can be used to run Schematron checks on a DITA Map (and its topics):

https://github.com/doctales/org.doctales.schematron

An alternative is to go to the Oxygen Preferences->"Editor / Open/Save" page and select the "Check Errors on Save" checkbox.

Regards,
Radu

Re: Validate with Schematron in Git pre-push hook?

Posted: Mon Oct 01, 2018 11:31 am
by Radu
One unrelated thing, the email which you have configured in your forum account no longer works so you should try to change it to some other email address.

Regards,
Radu

Re: Validate with Schematron in Git pre-push hook?

Posted: Fri Oct 26, 2018 5:04 pm
by kirkilj
I saw an Operation in github called ExecuteAuthorActionsOnSaveHook at https://github.com/oxygenxml/ExecuteAut ... nsion.java.

Could we not write an equivalent in Javascript or a wrapper to the Java version to check the creation date of a dita file to determine if schematron should validate deprecated elements/attributes should be warnings or failures? By "deprecate", I'm referring to elements/attributes that our Information Architecture group is asking writers to stop using for new files, but allow for old files. Are there easier ways to accomplish this?

Re: Validate with Schematron in Git pre-push hook?

Posted: Mon Oct 29, 2018 9:48 am
by Radu
Hi John,

Performing various validation asserts depending on a certain file's creation date does not seem like a good choice for me. Files may be copied, and then the original creation date is no longer maintained. Maybe you could mark the old files (or the new ones) with some kind of processing instruction and then the Schematron could skip over certain asserts based on that custom processing instruction being located in the file or not.
There seems to be some API in Java to retrieve the creation time (as a long integer):

https://stackoverflow.com/questions/272 ... te-in-java

and from Schematron you can directly access Java code, for example this is some XSLT code which checks if a file exists by using the "java.io.File" utilities:

https://gist.github.com/eerohele/4531924

Regards,
Radu