W3C home > Mailing lists > Public > public-xml-processing-model-comments@w3.org > February 2010

Re: Scoping of options and variables

From: Norman Walsh <ndw@nwalsh.com>
Date: Wed, 10 Feb 2010 16:22:21 -0500
To: public-xml-processing-model-comments@w3.org
Message-ID: <m28wb04whe.fsf@nwalsh.com>
"Toman_Vojtech@emc.com" <Toman_Vojtech@emc.com> writes:
> 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.

I think that should be an error. I think we should generalize
err:XS0004 to say that it's an error to have two or more sibling
option or variable declarations that attempt to declare the same name.

> 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.

Do we all agree that in this case:

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

Shadowing is the expected (and correct) behavior?

> 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?

We could add a rule that says that variable names are never allowed
to shadow option names, but I'm not sure it's worth the effort.

                                        Be seeing you,
                                          norm

-- 
Norman Walsh <ndw@nwalsh.com> | Everything has been said before, but
http://nwalsh.com/            | since nobody every listens we have to
                              | keep going back and beginning all over
                              | again.--André Gide

Received on Wednesday, 10 February 2010 21:22:55 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 10 February 2010 21:22:55 GMT