W3C home > Mailing lists > Public > xproc-dev@w3.org > September 2008

Re: p:validate-with-xml-schema

From: Norman Walsh <ndw@nwalsh.com>
Date: Fri, 26 Sep 2008 08:32:07 -0400
To: XProc Dev <xproc-dev@w3.org>
Message-ID: <m2tzc3nl4o.fsf@nwalsh.com>
James Garriss <james@garriss.org> writes:

> I guess I don't know how everyone else uses XML Schema (or RelaxNG or
> Schematron), but when I do schema validation I want to know if my XML is
> valid or not (and if not, why not?).
> Two questions, if I may:
> 1) Why does this step return a PSVI instead of true/false?  I'd like to
> understand the thinking.

In the case of W3C XML Schema at least, schema validation performs
type assignment and augments the infoset with new information. For
many users, this new type information is at least as important as
validity checking.

> 2) How can I get it to return true/false?

For better or worse, I think the best thing you can do today is define
your own pipeline that returns the result you want:

<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
<p:input port="source" primary="true"/>
<p:input port="schema" sequence="true"/>
<p:output port="result"/>
<p:option name="mode" select="'strict'"/>

    <p:validate-with-xml-schema assert-valid="true">
      <p:input port="source">
	<p:pipe step="is-valid" port="source"/>
      <p:input port="schema">
	<p:pipe step="is-valid" port="schema"/>
      <p:with-option name="mode" select="$mode"/>
      <p:when test="/*">
	  <p:input port="source">
	<!-- this can't happen -->
	  <p:input port="source">
      <p:input port="source">

If you put the preceding declaration in your pipeline, then you can call
it as a step:

  <p:input port="source">
  <p:input port="schema">

and it will produce <c:result>true|false</c:result> on its primary
output port. *And* Calabash 0.6.2, released this morning, will in fact
run it. :-)

On the one hand, this may seem like a fairly clumsy answer. On the
other, you can stick this pipeline, and other utility pipelines that
you write, in a library, import that library, and then it just becomes
another step you can call.

Support for calling declared pipelines in Calabash is very fragile,
but I'm working on it.

I don't think p:import works yet, but I'm working on that too.

                                        Be seeing you,

Norman Walsh <ndw@nwalsh.com> | When we are tired, we are attacked by
http://nwalsh.com/            | ideas we conquered long ago.-- Nietzsche

Received on Friday, 26 September 2008 12:32:53 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:03:03 UTC