Scoping of options and variables

Hi all,

I just encountered a small problem with options and variables.

Section 3.2 says: "The scope of option and variable names is determined
by where they are declared. When an option is declared with p:option (or
a variable with p:variable), unless otherwise specified, its scope
consists of the sibling elements that follow its declaration and the
descendants of those siblings."

So what happens in this case:

<p:pipeline version="1.0">
    <p:option name="foo" select="'bar'"/>
    <p:variable name="foo" select="'baz'"/>
    <p:identity/>
</p:pipeline>

Should it run (with the variable "shadowing" the option value), or
should you get a static error? In our implementation, you currently get
err:XS0004: "It is a static error to declare two or more options on the
same step with the same name." But I don't think that err:XS0004
describes the essence of the problem really well.

And what about this case:

<p:pipeline version="1.0">
  <p:option name="foo" select="'bar'"/>
  <p:group>
    <p:variable name="foo" select="'baz'"/>
    <p:identity/>
  </p:group>
</p:pipeline>

Should it fail, too? Or does the variable "shadow" the option? I just
found out that in our implementation, that is exactly what happens at
the moment.

I think the behavior should be the same both of the cases above: either
a static error (do we need a new one or is loosening the description of
err:XS0004 enough?), or it should just work.

What do you think?

Regards,
Vojtech


--
Vojtech Toman
Principal Software Engineer
EMC Corporation
toman_vojtech@emc.com
http://developer.emc.com/xmltech

Received on Friday, 22 January 2010 11:14:27 UTC