W3C home > Mailing lists > Public > public-qt-comments@w3.org > August 2017

[Bug 30171] New: Can a global variable declaration refer to an imported variable it is overriding?

From: <bugzilla@jessica.w3.org>
Date: Fri, 25 Aug 2017 23:21:32 +0000
To: public-qt-comments@w3.org
Message-ID: <bug-30171-523@http.www.w3.org/Bugs/Public/>
https://www.w3.org/Bugs/Public/show_bug.cgi?id=30171

            Bug ID: 30171
           Summary: Can a global variable declaration refer to an imported
                    variable it is overriding?
           Product: XPath / XQuery / XSLT
           Version: Proposed Recommendation
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSLT 3.0
          Assignee: mike@saxonica.com
          Reporter: mike@saxonica.com
        QA Contact: public-qt-comments@w3.org
  Target Milestone: ---

Consider a stylesheet module a.xsl that contains the global variable
declaration

<xsl:variable name="v" xml:id="v1" select="23"/>

Now consider a stylesheet module b.xsl that does

<xsl:import href="a.xsl">
<xsl:variable name="v"  xml:id="v2" select="$v+1"/>
<xsl:template name="xsl:initial-template">{$v}</xsl:template>

My immediate instinct is that the second variable declaration (v2) is an error:
a variable is not in scope within its own declaration. But there appears to be
a reading of the spec that suggests that the stylesheet should output 24.

9.5 tells us that v1 declares a global variable $v that is visible "everywhere
except within its own declaration, and where it is shadowed by another
binding".

In the select expression of v2, is the variable declared by v1 visible? It's
not within its own declaration. Is it shadowed by another binding -
specifically by the binding v2?

[Definition: A binding shadows another binding if the binding occurs at a point
where the other binding is visible, and the bindings have the same name. ]

This definition suggests that v2 shadows v1. But there is something missing in
the definition. A local variable v shadows a global variable v, but only within
the scope of the local variable v. The pertinent phrase is "where it is
shadowed". So is v1 shadowed by v2 *within the select expression of v2*, given
that v2 is not visible here? 

This question applies equally to XSLT 1.0 and 2.0. I don't think either of
those specs tells us the answer.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
Received on Friday, 25 August 2017 23:21:36 UTC

This archive was generated by hypermail 2.3.1 : Friday, 25 August 2017 23:21:37 UTC