Le mercredi 26 janvier 2005 � 11:55 +0100, Erik Bruchez a �crit :
>  > Just a gentle reminder... despite its esoteric title, it's asking
>  > serious questions :-) ...
> 
> The mail was long and looked scary ;-)

Sorry!

>  >>I am creating an action to reload a XML dump of my eXist database
>  >>and that raises several questions showing that the behaviour of the
>  >>pipes called from an action isn't as straightforward as I had
>  >>thought.
>  >>
>  >>The bizdoc example shows several cases of such pipes without output
>  >>that lead to database operations and the database processors seem to
>  >>act as sinks that pull the input of pipes even when they don't have
>  >>any output, such as in:
> 
> [...]
> 
>  >>the identity processor is never executed. That's logical and the
>  >>result of a good optimisation since the output of the identity
>  >>processor is never used.
>  >>
>  >>Is the difference of behaviour only because the oxf:xmldb-delete has
>  >>no output while the oxf:identity processor is it a special property
>  >>of the oxf:xmldb-delete processor to act as a sink?
> 
> Yes. Processors may or may not have outputs, and there is a difference
> of behavior between a processor that exposes an output if that output
> is never called, and a processor that does not expose an output.

And the null-serializer processor is there to force the execution of a
processor which output is never called?

> 
> In the first category, your identity processor which exposes a "data"
> output which is never called.
> 
> In the second category, the xmldb-delete processor which does not
> expose an output at all.
> 
> Without this:
> 
> 1. As you say, we wouldn't be able to optimize and all processors
>     should be executed.
> 
> 2. Or, we wouldn't be able to have processors that do not have
>     outputs, which would prevent implementing something like
>     xmldb-delete.
> 
>  >>My database dumps are RDF documents in which I'd like to split each
>  >>top level element in a separate document in the eXist database
>  >>(embedded in its own rdf root element to make it snippet a valid RDF
>  >>document).
>  >>
>  >>The p:for-each loop seems to be the right tool to do so.
>  >>
>  >>Unfortunately, the for-each has a mandatory output that I need to
>  >>declare even if the branches of the for-each are oxf:xmldb-insert
>  >>that have no output.
> 
> If I remember well, the for-each's id or ref attribute is
> optional. You should be able to just omit it.

New tests show that this is true when there is no "root" attribute
(which makes sense).

>  >>As a result of that, the for-each loop isn't considered as a sink
>  >>and isn't executed when the action is called.
> 
> Correct, this is what will happen if you do declare an id or ref
> attribute.
> 
>  >>The workaround I have found for that is to create a fake result that
>  >>I remove with an XPointer expression before generating the output:
> 
> [...]
> 
>  >>That's working, but this is neither elegant, readable nor (probably)
>  >>efficient.
>  >>
>  >>Is there a simpler way of doing that?
> 
> You could also simply use the null-serializer processor, which just
> consumes data and does nothing with it. But you shouldn't have to do
> this in this particular case.

OK.

>  >>Would it solve the problem if the id attribute of p:for-each was made
>  >>optional and the for-each considered as a sink when the attribute
>  >>missing?
> 
> Yes :-) If it doesn't work in 2.7, it's a bug.

No, the following pipeline is working fine:

<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline";
    xmlns:oxf="http://www.orbeon.com/oxf/processors";
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
xmlns:xdb="http://orbeon.org/oxf/xml/xmldb";
    xmlns:bk="http://apiculteurs.info/namespace/";
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";>
    <p:param name="instance" type="input"/>
    <p:processor name="oxf:pipeline">
        <p:input name="config" href="read-uri.xpl"/>
        <p:input name="uri" href="aggregate('uri', 
#instance#xpointer(string(/form/files/file)))"
            debug="uri"/>
        <p:output name="data" id="document" debug="upload"/>
    </p:processor>
    <p:for-each href="#document" select="/rdf:RDF/*">
        <p:processor name="oxf:xmldb-insert">
            <p:input name="datasource" href="data-access/exist/datasource.xml"/>
            <p:input name="query">
                <xdb:insert collection="/db/apiculteurs/apiculteurs"/>
            </p:input>
            <p:input name="data" href="aggregate('rdf:RDF', current())" 
debug="individualFile"/>
        </p:processor>
    </p:for-each>
</p:config>

Thanks,

Eric
-- 
Did you know it? Python has now a Relax NG (partial) implementation.
                                          http://advogato.org/proj/xvif/
------------------------------------------------------------------------
Eric van der Vlist       http://xmlfr.org            http://dyomedea.com
(ISO) RELAX NG   ISBN:0-596-00421-4 http://oreilly.com/catalog/relax
(W3C) XML Schema ISBN:0-596-00252-1 http://oreilly.com/catalog/xmlschema
------------------------------------------------------------------------



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
orbeon-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/orbeon-user

Reply via email to