W3C home > Mailing lists > Public > xproc-dev@w3.org > May 2012

Re: Referencing an XProc variable in p:split-sequence/@test

From: Romain Deltour <rdeltour@gmail.com>
Date: Mon, 7 May 2012 16:02:21 +0200
Cc: XProc Dev <xproc-dev@w3.org>
Message-Id: <BC064523-FAF4-4F5E-8FD0-A0D8559615C2@gmail.com>
To: Florent Georges <fgeorges@fgeorges.org>
The XPath context of the @test is the document currently being processed among the sequence appearing on the input port.

If you want to use the variable, you meed to construct the XPath expression of the test with a p:with-option element:

<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
    xmlns:c="http://www.w3.org/ns/xproc-step"
    name="pipeline"
    version="1.0">
    
    <p:input port="source" sequence="true" primary="true">
        <p:inline>
            <one/>
        </p:inline>
        <p:inline>
            <two/>
        </p:inline>
    </p:input>
    
    <p:output port="result" sequence="true" primary="true"/>
    
    <p:variable name="elem" select="'two'">
        <p:empty/>
    </p:variable>
    
    <p:split-sequence>
        <p:with-option name="test" select="concat('name(/*) eq &quot;',$elem,'&quot;')">
            <p:empty/>
        </p:with-option>
    </p:split-sequence>
    
    
</p:declare-step>


HTH,
Romain.

On 7 mai 2012, at 15:39, Florent Georges wrote:

>  Hi,
> 
>  I have the following pipeline, which returns as expected the
> document with element 'one' as result:
> 
>    <p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
>                    xmlns:c="http://www.w3.org/ns/xproc-step"
>                    name="pipeline"
>                    version="1.0">
> 
>       <p:input port="source" sequence="true" primary="true">
>          <p:inline>
>             <one/>
>          </p:inline>
>          <p:inline>
>             <two/>
>          </p:inline>
>       </p:input>
> 
>       <p:output port="result" sequence="true" primary="true"/>
> 
>       <p:split-sequence test="name(/*) eq 'one'"/>
> 
>    </p:declare-step>
> 
>  If I replace the above split sequence step with the following (that
> is, simply creating a variable to get the name of the element out of
> the XPath expression itself):
> 
>    <p:variable name="elem" select=" 'one' ">
>       <p:empty/>
>    </p:variable>
>    <p:split-sequence test="name(/*) eq $elem"/>
> 
> then I get the following error:
> 
>    SEVERE: Underlying exception: net.sf.saxon.trans.XPathException:
>    Undeclared variable in XPath expression: $elem
> 
>  From my reading, using an XProc variable in a p:split-sequence/@test
> expression is allowed.  Did I miss something, or is it a bug in
> Calabash? (latest Github content for Saxon 9.4+)
> 
>  Regards,
> 
> -- 
> Florent Georges
> http://fgeorges.org/
> http://h2oconsulting.be/
> 
Received on Monday, 7 May 2012 14:02:59 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 7 May 2012 14:02:59 GMT