cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

call Schematron from ACL menu item

SOLVED

Re: call Schematron from ACL menu item

Glad to hear it! Persistence pays off.

Re: call Schematron from ACL menu item

I have one more task to sort out.

When I run the schematron from my menu item, some auto generated saxe error text comes up in the event log.

 

The rules in the Schematron have reports and assert tests with some custom text, and they should be outputting something like "The file ______________ is discontinued. Please revise your link"

 

The schematron is running, but I am not seeing my custom messages coming up anywhere. The function refers to "log_name", and add_errors_to_log - where can I find this log? Should it come up in a pop up window?

schematron::add_errors_to_log(msgs, doc, log_name);

Re: call Schematron from ACL menu item

If the messages window doesn't come up on its own, you may need to display it manually. Try adding this after your validation runs:

show_composer_log()

Re: call Schematron from ACL menu item

I tried adding

show_composer_log();

right after

 

   schematron::add_errors_to_log(msgs, doc, log_name);

but I didn't see any changes in the window pop ups.

Re: call Schematron from ACL menu item

You might need to initialize the event log to add new messages to it. Try adding this at the beginning of your function:

    _eventlog::end_job(log_name, 0, "warning");
    local log = _eventlog::start_job(log_name, "Schematron Errors");

Also, you may need to change your log name so it's a valid ID token, e.g. "schematron_log" or something like that.

Re: call Schematron from ACL menu item

Where all should I change it to be something semantic like schematron_log?


The configuration I have below doesnt seem to have any new window pop up with my custom schematron messages outlined in the .sch file.


Have I changed it in the appropriate places to see results? (I did try in the function params as well where it says log_name, but it didn't work)

 

function validate_schematron(schfile, log_name, doc=current_doc()) {
   _eventlog::end_job(Schematron_log, 0, "warning");
   local log = _eventlog::start_job(Schematron_log, "Schematron Errors");
   local msgs[];
   local result = validate_against_schematron(msgs, doc, schfile);
   validate_against_schematron(msgs, doc, schfile);
   response("validate_against_schematron is done, generated " . count(msgs) . " messages");
   schematron::add_errors_to_log(msgs, doc, Schematron_log);
   show_composer_log();
}

Re: call Schematron from ACL menu item

Where you have "Schematron_log" in your function, replace it with "log_name".

 

Also, you may need to wrap the call to schematron::add_errors_to_log() in an execute() call to defer evaluation of some of the variables. So, it would look something like this:

function validate_schematron(schfile, log_name, doc=current_doc()) {
   _eventlog::end_job(log_name, 0, "warning");
   local log = _eventlog::start_job(log_name, "Schematron Errors");
   local msgs[];
   local result = validate_against_schematron(msgs, doc, schfile);
   validate_against_schematron(msgs, doc, schfile);
   response("validate_against_schematron is done, generated " . count(msgs) . " messages");
   execute("schematron::add_errors_to_log(msgs, doc, log_name)");
   show_composer_log();
}

Re: call Schematron from ACL menu item

That worked!!! Excellent Clay thank you!

 

So close.

One small snag - I have to run the menu item twice.

 

When I run the menu item the first time, t an Event Log window opens with SAXParse information, which is normal.

In order to see the results of drugTableValidation.sch, I have to leave the Event Log window open, and run the menu item again, and then a new window opens with the Schematron 1 Errors in it.

 

If I close the Event log, before running the menu item for the second time, nothing appears. Always have to leave the Event log window up in order to see the schematron results.

 

Is there any way I can

a) merge the errors into one Event Log window or

b) make the Schematron errors appear with only running the menu item once?

Re: call Schematron from ACL menu item

I'm not sure why it's doing that. You could try adding a call to _eventlog::end_job() at the end of your function to see if that makes the messages appear the first time you call the function:

function validate_schematron(schfile, log_name, doc=current_doc()) {
   _eventlog::end_job(log_name, 0, "warning");
   local log = _eventlog::start_job(log_name, "Schematron Errors");
   local msgs[];
   local result = validate_against_schematron(msgs, doc, schfile);
   validate_against_schematron(msgs, doc, schfile);
   response("validate_against_schematron is done, generated " . count(msgs) . " messages");
   execute("schematron::add_errors_to_log(msgs, doc, log_name)");
_eventlog::end_job(log_name, 1); show_composer_log(); }

 In general, parser messages appear in a different window than completeness check messages (which is basically what we're generating here).

Re: call Schematron from ACL menu item

That did it!

 

Solution COMPLETE.

 

Thanks so much for your guidance Clay. I will be making more menu items for each of our individual schematrons now that this one is functioning as expected.