- From: Norman Walsh <ndw@nwalsh.com>
- Date: Tue, 22 Nov 2011 16:13:37 -0500
- To: XProc Dev <xproc-dev@w3.org>
- Message-ID: <m27h2ramim.fsf@nwalsh.com>
"Imsieke, Gerrit, le-tex" <gerrit.imsieke@le-tex.de> writes: > I had or rather I still have similar issues. I was bothered by the fact > that Schematron validation provides a "report" port which the > schema-based validations lack. > > p:validate-with-relax-ng for example has a single output port which will > only reproduce the document if it is valid (or if @assert-valid="false"). > > In order to catch errors, I wrapped p:validate-with-relax-ng into a > try/catch and forwarded the "error" port of the catch branch to a > "report" output port that I declared for both branches. Right. And you can wrap that up in a custom step that you reuse and get just want you want. Here's an example that returns the validated document and an empty result port or the unvalidated document and an error report: <p:declare-step type="ex:validate-with-relax-ng" name="main"> <p:input port="source"/> <p:input port="schema" sequence="true"/> <p:output port="result" primary="true"> <p:pipe step="tryvalidation" port="result"/> </p:output> <p:output port="report" sequence="true"> <p:pipe step="tryvalidation" port="report"/> </p:output> <p:try name="tryvalidation"> <p:group> <p:output port="result"> <p:pipe step="xmlvalidate" port="result"/> </p:output> <p:output port="report" sequence="true"> <p:empty/> </p:output> <p:validate-with-relax-ng name="xmlvalidate"> <p:input port="source"> <p:pipe step="main" port="source"/> </p:input> <p:input port="schema"> <p:pipe step="main" port="schema"/> </p:input> </p:validate-with-relax-ng> </p:group> <p:catch name="catch"> <p:output port="result"> <p:pipe step="main" port="source"/> </p:output> <p:output port="report"> <p:pipe step="id" port="result"/> </p:output> <p:identity name="id"> <p:input port="source"> <p:pipe step="catch" port="error"/> </p:input> </p:identity> </p:catch> </p:try> </p:declare-step> > <aside> > I just found out that p:validate-with-relax-ng will only give me the > first error. But it’s wrapped in c:errors and c:error elements, like this: That's a bug. Fixed in github. You'll now get multiple c:error elements in a c:errors wrapper. I also fixed it in XSD and improved the report for DTD validation from p:load. > A uniform report port for all types of validation is clearly desirable. Indeed. Be seeing you, norm -- Norman Walsh Lead Engineer MarkLogic Corporation Phone: +1 413 624 6676 www.marklogic.com
Received on Tuesday, 22 November 2011 21:14:18 UTC