Re: Validation...

Hash: SHA1

Hi there,
The example below works for me, but I would like to stop processing
and print the errors to stdout/stderr when the document is invalid. I
can get it to stop processing by adding a p:error in the p:catch:

But I haven't figured out how to make it display the error messages in
any form. Any pointers?


On 11/22/2011 03:13 PM, Norman Walsh wrote:
> "Imsieke, Gerrit, le-tex" <> 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

Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla -


Received on Saturday, 24 December 2011 03:38:58 UTC