W3C home > Mailing lists > Public > xproc-dev@w3.org > August 2013

How to get p:validate-with-xml-schema to work within p:for-each

From: Steve Taylor <steve.h.g.taylor@gmail.com>
Date: Wed, 14 Aug 2013 21:23:13 -0400
Message-ID: <CAEEdU0fN9MiUuCKcK1G6B5tBmu348CrwEH+D=efzqERcMhFB_Q@mail.gmail.com>
To: xproc-dev@w3.org
Hi,

I'm trying to validate a directory of xml files creating a report. I can't
seem to get the validation to use the p:load xml file

<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" xmlns:c="
http://www.w3.org/ns/xproc-step" xmlns:cx="
http://xmlcalabash.com/ns/extensions" name="myPipeline" version="1.0">



    <p:output port="result" sequence="true"/>

    <p:variable name="path" select="'../xml/'"/>
    <p:variable name="schema" select="'../xsd/red.xsd'"/>


    <p:load name="load-schema">
        <p:with-option name="href" select="$schema"/>
    </p:load>

    <p:directory-list>
        <p:with-option name="path" select="$path">
            <p:empty/>
        </p:with-option>
    </p:directory-list>


    <p:for-each name="loop">

        <p:iteration-source select="/c:directory/c:file"/>

        <p:try name="try">
            <p:group>
                <p:output port="result" sequence="false"/>

                <p:load name="file">
                    <p:with-option name="href"
select="concat(@xml:base,@name)"/>
                </p:load>

                <p:validate-with-xml-schema name="XSD">
                    <p:input port="source">
                        <p:pipe port="result" step="file"/>
                    </p:input>
                    <p:input port="schema">
                        <p:pipe step="load-schema" port="result"/>
                    </p:input>
                    <p:with-option name="assert-valid" select="true()"/>
                </p:validate-with-xml-schema>

                <p:pack wrapper="wrap">
                    <p:input port="alternate">
                        <p:pipe step="XSD" port="result"/>
                    </p:input>

                </p:pack>

                <p:identity/>
            </p:group>
            <p:catch name="catch">
                <p:output port="result" sequence="false"/>
                <p:identity name="copy-errors">
                    <p:input port="source">
                        <p:pipe step="catch" port="error"/>
                    </p:input>
                </p:identity>
            </p:catch>
        </p:try>
    </p:for-each>

    <p:wrap-sequence wrapper="errors"/>


</p:declare-step>

I end up getting output as follows:

<errors>
<c:errors xmlns:c="http://www.w3.org/ns/xproc-step">
<c:error line="1" column="214">ValidationException: Cannot validate &lt;{...
w3.org/ns/xproc}declare-step&gt;: no element declaration available</c:error>
</c:errors>
<c:errors xmlns:c="http://www.w3.org/ns/xproc-step">
<c:error line="1" column="214">ValidationException: Cannot validate &lt;{...
w3.org/ns/xproc}declare-step&gt;: no element declaration available</c:error>
<c:error line="1" column="214">ValidationException: Cannot validate &lt;{...
w3.org/ns/xproc}declare-step&gt;: no element declaration available</c:error>
</c:errors>

I assume I'm not putting the correct input data into the p:validate
although I've been unable to work it out. Any ideas how I fix this?


Thanks
-- 


Steve,
Received on Thursday, 15 August 2013 14:24:14 UTC

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