Re: err:XD0008 (more than one document in context) when not referring to the context

  Hi,

  Makes a lot of sense to me as a user.  The difficult bit here is
probably to define what means "using the context".  What about the
following XPath expression?:

    if ( false() ) then string(.) else 'xxx'

  This would require static analysis to detect the usage of the
context, even though I expect must of the processors to reduce it to
simply 'xxx' after optimization.  As XD0008 is already a dynamic
error, it makes sense to me to change the following sentence at the
end of "§5.7.3 p:with-option":

    It is a dynamic error (err:XD0008) if a sequence of more than one
    document appears on the connection for a p:with-option.

by something like the following:

    It is a dynamic error (err:XD0008) if evaluating the select
    expression of the p:with-option ever refers to the context node,
    size, or position, and if a sequence of more than one document
    appears on the connection for the same p:with-option.

  By the way, the XProc spec contains the phrase "context node, size,
or position" in several places, even though those 3 components of the
dynamic context are the exact definition of the "focus" (yeah, indeed,
only starting in XPath 2.0).

  Regards,

-- 
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/


On 27 May 2013 14:34, Jostein Austvik Jacobsen wrote:
> In XProc vNext; could it be allowed to have more than one document in the
> context of a p:with-option, p:with-param and p:variable as long as you don't
> refer to the context?
>
> I have a step with this signature:
>
> <p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
> xmlns:pxi="http://www.daisy.org/ns/pipeline/xproc/internal"
> type="pxi:daisy202-to-epub3-content" version="1.0">
>     <p:input port="content-flow" primary="true" sequence="true"/>
>     <p:input port="resolve-links-mapping"/>
>     <p:input port="ncc-navigation"/>
>     <p:output port="content" sequence="true" primary="true"/>
>     <p:output port="fileset" primary="false"/>
>
>     <p:option name="publication-dir" required="true"/>
>     <p:option name="content-dir" required="true"/>
>     <p:option name="daisy-dir" required="true"/>
> </p:declare-step>
>
> As you see, the primary input is a sequence. So when I call it, I have to
> do:
>
> <pxi:daisy202-to-epub3-content>
>     <p:with-option name="publication-dir" select="$publication-dir">
>         <p:empty/>
>     </p:with-option>
>     <p:with-option name="content-dir" select="$content-dir">
>         <p:empty/>
>     </p:with-option>
>     <p:with-option name="daisy-dir" select="$daisy-dir">
>         <p:empty/>
>     </p:with-option>
> </pxi:daisy202-to-epub3-content>
>
> As a script author I would expect that as long as I don't refer to the
> context in a select expression, it wouldn't matter what is in the context.
> (I didn't realize this until I encountered an input fileset resulting in
> that multiple documents appeared on the steps input port, which means this
> has been a bug in my script for a long time.)
>
> This should have been sufficient:
>
> <pxi:daisy202-to-epub3-content>
>     <p:with-option name="publication-dir" select="$publication-dir"/>
>     <p:with-option name="content-dir" select="$content-dir"/>
>     <p:with-option name="daisy-dir" select="$daisy-dir"/>
> </pxi:daisy202-to-epub3-content>
>
> I find it strange that if there is no documents in the context it is only an
> error if you try to refer to the context, while if there is multiple
> documents in the context it is an error even if you don't refer to the
> context.
>
> What do you think?
>
> Jostein

Received on Monday, 27 May 2013 18:52:00 UTC