Skip to main content
1-Visitor
October 22, 2018
Solved

call Schematron from ACL menu item

  • October 22, 2018
  • 1 reply
  • 11284 views

We are using schematron for extra validation of our xml documents during the standard 'Check Completeness' function and working well.

 

We would like to create a separate menu item for a different schematron (a subset of <pattern>s) only to be run by certain users employees. We would like this second Schematron to be kicked off from a custom menu item using ACL.

 

I can create a menu no problem, but how can I get my menu item to reference the schematron file? Where should this schematron file be saved?

Best answer by ClayHelberg

Hi Ashley--

 

See the documentation for the ACL function "validate_against_schematron" in the Arbortext Help Center: https://support.ptc.com/cs/help/arbortext_hc/ae61_hc/index.jspx?id=help17197&action=show. This is the function you'll want to apply ad hoc schematron checks to a document.

 

--Clay

1 reply

18-Opal
November 6, 2018

Hi Ashley--

 

See the documentation for the ACL function "validate_against_schematron" in the Arbortext Help Center: https://support.ptc.com/cs/help/arbortext_hc/ae61_hc/index.jspx?id=help17197&action=show. This is the function you'll want to apply ad hoc schematron checks to a document.

 

--Clay

1-Visitor
March 5, 2019

I am trying to implement this solution, and I have the function set up in my menu.acl

 

but it does not like the '0' arguement

 

function validate_against_schematron($S, 0, "cpha-editor.sch");

 

I get an error that says Unexpected Argument: 0,

 

I want the user to be able to open AE and then open the document, and run this schematron validation from a menu item, so 0 wont be set on initialization of AE, how can I work around this? what else can I put in instead of 0?

 

18-Opal
March 5, 2019

I would use something like this:

 

 

menu_add ".Tools." "Schematron Check" -cmd { validate_against_schematron($S, 0, "cpha-editor.sch"); }

Note that this will fill the $S array with any validation error messages, it will be up to you to display these to the user, or do something else with them.

 

If you just want to show the errors to the user, the easiest thing is probably to leverage the built-in "schematron" package code. There is a function defined there that does both the validation check and error message display, so maybe it's more direct to just use that. The function is called schematron::completeness_check_callback(doc, logname). So you could use something like this:

 

menu_add ".Tools." "Schematron Check" -cmd { schematron::completeness_check_callback(current_doc(), "Schematron Errors"); }

You may also need to make sure the schematron package is loaded before you can use this, so you can add a line near the top of your script file:

require schematron;