Re: p:split-sequence gives "Undeclared variable in XPath expression"

The context used to evaluate the XPath expression in the 'test'  
attribute is set successively to each of the documents appearing on  
the "source" port (each document triggering an evaluation of the  
expression).

The variables and options of the XProc document are not available in  
this context. If you want to use them, you have to "build" the test  
expression dynamically, e.g. with p:with-option

<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="1.0">

     <p:input port="source" sequence="true">
         <p:inline>
             <doc/>
         </p:inline>
     </p:input>
     <p:output port="result" sequence="true"/>
     <p:option name="option" select="true()"/>

     <p:split-sequence>
 <p:with-option name="test" select="concat('&quot;',$option,'&quot;')"/>
     </p:split-sequence>

</p:declare-step>

Cheers,
Romain.

Le 16 août 11 à 15:51, Jostein Austvik Jacobsen a écrit :

> Hi all.
>
> I'm always excited when I come across a use-case that lets me use an  
> XProc step that I haven't used before, and today I tried p:split- 
> sequence. It seemed pretty straight forward, however I stumbled upon  
> a problem right away. This pipeline doesn't work:
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="1.0">
>
>     <p:input port="source" sequence="true">
>         <p:inline>
>             <doc/>
>         </p:inline>
>     </p:input>
>     <p:output port="result" sequence="true"/>
>     <p:option name="option" select="true()"/>
>
>     <p:split-sequence test="$option"/>
>
> </p:declare-step>
>
>
> This fails with the message "Undeclared variable in XPath  
> expression: $option". If I replace test="$option" with either  
> test="true()" or test="position()=1" it works. But when I introduce  
> a variable or option into the test, it fails. So what am I missing  
> here?
>
>
> Regards
> Jostein

Received on Tuesday, 16 August 2011 14:13:13 UTC