<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>7356</bug_id>
          
          <creation_ts>2009-08-17 21:25:59 +0000</creation_ts>
          <short_desc>[XSLT 2.0] Need clarification in the definition of circularity</short_desc>
          <delta_ts>2010-07-27 20:40:21 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>XSLT 2.0</component>
          <version>Recommendation</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://www.w3.org/TR/xslt20/#dt-circularity</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Henry Zongaro">zongaro</reporter>
          <assigned_to name="Michael Kay">mike</assigned_to>
          <cc>sca.w3c</cc>
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>26496</commentid>
    <comment_count>0</comment_count>
    <who name="Henry Zongaro">zongaro</who>
    <bug_when>2009-08-17 21:25:59 +0000</bug_when>
    <thetext>The definition of circularity in XSLT 2.0[1] is &quot;A circularity is said to exist if a construct such as a global variable, an attribute set, or a key is defined in terms of itself. For example, if the expression or sequence constructor  specifying the value of a global variable X references a global variable Y, then the value for Y must be computed before the value of X. A circularity exists if it is impossible to do this for all global variable definitions.&quot;

The error reported for a circularity is &quot;[ERR XTDE0640] In general, a circularity in a stylesheet is a non-recoverable dynamic error. However, as with all other dynamic errors, an implementation will signal the error only if it actually executes the instructions and expressions that participate in the circularity.&quot;

It&apos;s not clear from the definition or the examples whether circularity is a static property of a variable or key, or it is something that is dynamic.  Consider the following example:

&lt;xsl:stylesheet xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot; version=&quot;2.0&quot;&gt;
  &lt;xsl:param name=&quot;p&quot; as=&quot;xs:boolean&quot;/&gt;
  &lt;xsl:variable name=&quot;x&quot; select=&quot;if $p then $y+1 else 17&quot;/&gt;
  &lt;xsl:variable name=&quot;y&quot; select=&quot;if $p then 19 else $x&quot;/&gt;

  &lt;xsl:template match=&quot;/&quot;&gt;
    &lt;out&gt;&lt;xsl:sequence select=&quot;$x, $y&quot;/&gt;&lt;/out&gt;
  &lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;

In this example, there is a variable reference for x in the expression used to define y, and a variable reference for y in the expression used to define x.  If these are &quot;references&quot; for the purposes of the definition of circularity, then x must be computed before y, and y before x, and so there is a circularity.

However, if a reference for the purposes of circularity means a reference that is actually evaluated, then there is no circularity - if p has the value true, the definition of x has a reference to y, but the definition of y does not have a reference to x, so y must be evaluated before x if p is true; if p has the value false, the definition of y has a reference to x, but the definition of x does not have a reference to y, so x must be evaluated before y if p is false.

[1] http://www.w3.org/TR/xslt20/#dt-circularity</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>26498</commentid>
    <comment_count>1</comment_count>
    <who name="Henry Zongaro">zongaro</who>
    <bug_when>2009-08-18 01:34:41 +0000</bug_when>
    <thetext>Sorry - I forgot to tie that back to error XTDE0640.  With the static view of what is considered a circularity, the &quot;if-then-else&quot; expressions in the select attributes of the two variables, in their entirety, would be considered &quot;instructions and expressions that participate in the circularity.&quot;  With the dynamic view, the &quot;instructions and expressions that participate in the circularity&quot; would be only those that actually cause a variable to be referenced in evaluating that same variable.

I think the dynamic view of circularity was intended, otherwise it makes it unnecessarily awkward to have the definition of a global variable use an xsl:apply-templates instruction, for instance.  However, neither the definition nor the examples make that clear.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36887</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2010-07-15 08:45:23 +0000</bug_when>
    <thetext>The WG looked at this.

We propose to make no change for 2.0: the spec clearly states that this is a dynamic error, triggered only if the expressions causing the circularity are actually evaluated.

For 2.1/3.0 we decided to allow implementations to raise a static error in respect of a cycle of statically-determined references (e.g between functions, variables, named templates and keys) irrespective of whether they are actually evaluated.

Needs drafting for 3.0.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36927</commentid>
    <comment_count>3</comment_count>
    <who name="Henry Zongaro">zongaro</who>
    <bug_when>2010-07-15 16:48:31 +0000</bug_when>
    <thetext>May I ask for a clarification on what will happen in XSLT 3.0?  Would a processor be permitted to report a static error in the case of the potential circularity I described in comment #0?  Or required to report one?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>36931</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2010-07-15 18:48:50 +0000</bug_when>
    <thetext>My interpretation of the direction was that we would allow this to be reported as a static error, but not require it. Some circularities (those involving xsl:apply-templates) can only be detected dynamically, so this would still be allowed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>37109</commentid>
    <comment_count>5</comment_count>
    <who name="Sharon Adler">sca.w3c</who>
    <bug_when>2010-07-27 20:39:30 +0000</bug_when>
    <thetext>See 15 July 2010 Minutes - resolution was: do nothing for 2.0; for next version, allow implementations to raise a static error in respect of a cycle of statically determined references without proving that they will inevitably be evaluated.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>