Re: using variables in match attribute of p:viewport

On 01 Feb 2016, at 17:18, Kraetke, Martin, le-tex <martin.kraetke@le-tex.de> wrote:
> 
> Hi,
> 
> I get a Saxon undeclared variable error, when I try to use a reference to a variable within a match attribute. So I would like to know if in-scope bindings to variables doesn't apply to steps which include a match attribute?
> 
> Because variable references work in steps with select attribute, it would be interesting to know the difference between @match and @select. If I missed something in the spec, please let me know.

As far I know p:viewport/@match is evaluated by the processor, so the XPath context should contain the in-scope bindings. The spec says [1]:

  "The XProc processor evaluates all of the XPath expressions in select attributes on variables, options, parameters, and inputs, in match attributes on p:viewport, and in test attributes onp:when steps."

[1] https://www.w3.org/TR/xproc/#xpath-context

So it sounds like a bug; but maybe I'm wrong and I miss something.

Romain.

> 
> I made a simple example using p:viewport and p:in-scope-names to show the issue. The pipeline fails with: "err:XPST0008:Undeclared variable in XPath expression: $foo". If you replace "$foo" with "'bar'" within matches(), the result of p:in-scope-names will show that the variable is in the scope of p:viewport.
> 
> Kind regards,
> 
> Martin
> 
> 
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
>  xmlns:c="http://www.w3.org/ns/xproc-step"
>  version="1.0"
>  name="viewport">
> 
>  <p:input port="source">
>    <p:inline>
>      <foo>bar</foo>
>    </p:inline>
>  </p:input>
> 
>  <p:output port="result"/>
> 
>  <p:variable name="foo" select="'bar'"/>
> 
>  <p:viewport match="//foo[matches(., $foo)]">
> 
>    <p:in-scope-names name="in-scope-names"/>
> 
>    <p:identity>
>      <p:input port="source">
>        <p:pipe port="result" step="in-scope-names"/>
>      </p:input>
>    </p:identity>
> 
>  </p:viewport>
> 
> </p:declare-step>
> 
> 
> 
> -- 
> Martin Kraetke
> Lead Content Engineer
> le-tex publishing services GmbH
> 
> Weissenfelser Str. 84, 04229 Leipzig, Germany
> Phone +49 341 355356 143, Fax +49 341 355356 543
> martin.kraetke@le-tex.de, http://www.le-tex.de
> 
> Registergericht / Commercial Register: Amtsgericht Leipzig
> Registernummer / Registration Number: HRB 24930
> 
> Geschäftsführer: Gerrit Imsieke, Svea Jelonek,
> Thomas Schmidt, Dr. Reinhard Vöckler
> 

Received on Monday, 1 February 2016 18:41:41 UTC