Wednesday 9 May 2007

schematron updates

Ken Holman posted a problem with the skeleton which also applied to my version described in an earlier post so I updated the code, at the same URI. There have also been some updates in the last few days removing saxon dependencies, as described in the coments, thanks to Colin Adams for picking those up. [updated again 2007/05/09] A couple of errors had crept into the schematron-get-full-path mode used to display the XPath of the current node.

11 comments:

Anonymous said...

My name is also David Carlisle.

Nice blog.

Lars said...

David,
Is there an "error browser" for ISO Schematron SVRL, corresponding to the earlier schematron-report.xsl that you wrote? I've looked around quite a bit (including on schematron.com) but can't find one.

In case the above is not clear, I'm looking for a stylesheet that takes SVRL as input, and outputs an HTML report of validation errors, including links to their locations in the XML document.

Thanks,
Lars

David Carlisle said...

I think that the existing schematron1.5 skeleton ought to work, more or less. Just import the iso skeleton rather than the 1.5 one, all the named templates are designed to do the same thing so that stylesheets building off the skeleton should work.

There may be a few small changes required. I must admit I've been rather busy with the day job recently to look at schematron, but I may see if I can find time to check whether the above works, or post a modified schematron-report if not.

If you try it before me and get it working feel free to post here.

David

Lars said...

David, thanks for your reply. I tried having schematron-report.xsl import the iso skeleton, but none of the templates seemed to match. I looked into the problem a little, but was confused because the skeleton seems designed to match Schematron schema language elements (e.g. sch:pattern), not SVRL elements (e.g. svrl:failed-assert). Maybe I'm just not understanding how the skeleton works.

I wrote a simple presentation stylesheet for SVRL myself, but I hesitate to reinvent the bells and whistles you already developed, e.g. links to user-documentation and to locations in the document-under-validation... if those features can be had by updating your report stylesheet.

Lars said...

Maybe the source of my misunderstanding is that your schematron-report.xsl is not designed to take SVRL as its input but to be an alternative to producing SVRL... is that correct?

Lars said...

I think the answer to my above question was "yes". So I've got schematron-report.xsl partially working now, with iso_schematron_skeleton.xsl.

However, it generates an invalid stylesheet: After one template the following appears:
<!--SCHEMATRON PATTERNS-->
<p>Constraints for validating a GEM system model</p><axsl:variable select="/" name="system-model"/>...

So I get an error from Saxon: "top-level elements must have a non-null namespace URI." I.e. that p element doesn't belong outside a template. The "Constraints for validating a system model" text is the content of the /*/iso:title element in my schematron schema.

Apparently the p element is generated by the template named process-p in schematron-report.xsl,
invoked by process-title in the skeleton, called by the template matching iso:title, which is applied at the end of the template match="*" mode="stylesheetbody".

Clearly, it's fine for an non-top-level iso:title to be rendered using a p element, but not a top-level one. The skeleton's default template matching iso:title is a no-op. The iso:title content is used by other templates. Maybe schematron-report.xsl should be doing the same.

(Maybe we should take this discussion off-line... I can be reached at lars_huttar at sil dot org.)
Lars

Lars said...

I wrote, "The skeleton's default template matching iso:title is a no-op."
I should have said, "The skeleton's default template named 'process-p' is a no-op."

It's not clear to me what ought to be done to fix this. The iso_svrl.xsl provided on schematron.com does a similar thing: it outputs a top-level svrl:text element in the generated stylesheet. Of course this doesn't make the stylesheet invalid, but it doesn't seem to serve any purpose either. Seems to me that the iso skeleton (or possibly iso_svrl.xsl) has overlooked the case of how a top-level iso:title element is processed by apply-templates select="*|...".

David Carlisle said...

.. or move to the schematron list
after all, someone may already have made the required fixes/updates

SVRL is _almost_ what you want as intermediate output so you can generate (say) html from it, rather than the "skeleton" model where you generate, as you say, html instead of svrl.

Rick didn't have this usage in mind when he defined svrl, it was more a minimal output to drive a test harness. there have been repeated requests to extend it and its on some list of things being considered for a revision of the spec.

I should say I have no input to the specification, I'm not on the committee, just implemented schematron-report a few years back out of interest and made the updates listed on this blog just to see what was new in the iso version. This thread discusses extending svrl for the usage you suggest, and updates to the schematron-report system.

http://eccnet.eccnet.com/pipermail/schematron-love-in/2007-May/000714.html

Lars said...

Thanks, that's what I was looking for. I will ask on that list whether Eric was able to get the HTML report working.

David Carlisle said...

Lars, I have updated the skeleton implementation available from this blog entry to have the fix that you posted on the schematron list, thanks.

David

Lars said...

Thanks for your help, David.
Lars