<?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>29458</bug_id>
          
          <creation_ts>2016-02-14 17:20:20 +0000</creation_ts>
          <short_desc>[xslt30ts] seqtor-027</short_desc>
          <delta_ts>2016-10-19 19:14:54 +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 3.0 Test Suite</component>
          <version>Candidate Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Michael Kay">mike</reporter>
          <assigned_to name="Abel Braaksma">abel.online</assigned_to>
          <cc>abel.braaksma</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>125019</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-02-14 17:20:20 +0000</bug_when>
    <thetext>This is a tough one to analyze. I am getting a space before the &quot;A&quot;. I think it&apos;s simpler to work out what&apos;s happening if we simplify the test by writing f:create(2) rather than f:create(61). In that case I get the result 

startend A BC

This follows the following logic, where CSC means &quot;construct simple content&quot;, and CCC is &quot;construct complex content:

1. The initial template creates a text node &quot;start&quot; followed by the results of f:create(2).

2. The result of f:create(2) is a text node whose string value is CSC(f:create(1)) followed by the string &quot;C&quot;

3. The result of f:create(1) is a text node whose string value is CSC(f:create(0)) followed by the string &quot;B&quot;

4. The result of f:create(0) is a text node whose string value is &quot;end&quot;, followed by the string &quot;A&quot;.

So the overall result is equivalent to

let $R4 := (text(&quot;end&quot;), &quot;A&quot;)
let $R3 := (text(CSC($R4)), &quot;B&quot;)
let $R2 := (text(CSC($R3)), &quot;C&quot;)
let $R1 := (text(&quot;start&quot;), $R2)
return $R1

Now:

CSC($R4) is as follows:

1. Zero-length text nodes in the sequence are discarded. No change.

2. Adjacent text nodes in the sequence are merged into a single text node. No change.

3. The sequence is atomized (which may cause a dynamic error). =&gt; (&quot;end&quot;, &quot;A&quot;)

4. Every value in the atomized sequence is cast to a string. =&gt; (&quot;end&quot;, &quot;A&quot;)

5. The strings within the resulting sequence are concatenated, with a (possibly zero-length) separator inserted between successive strings. =&gt; &quot;end A&quot;

6. In the case of xsl:processing-instruction, any leading spaces in the resulting string are removed. N/A.

So $R3 is (text(&quot;end A&quot;), &quot;B&quot;)

CSC($R3), by similar logic to that above, is text(&quot;end A B&quot;)

So $R2 is (text(&quot;end A B&quot;), &quot;C&quot;)

So $R1 is (text(&quot;start&quot;), text(&quot;end A B&quot;), &quot;C&quot;)

The final serialization step gives a result of

document-node(CCC(text(&quot;start&quot;), text(&quot;end A B&quot;), &quot;C&quot;))

Step 4 of CCC gives (text(&quot;start&quot;), text(&quot;end A B&quot;), text(&quot;C&quot;))

Step 7 of CCC gives (text(&quot;startend A BC&quot;)

so the result is document-node(&quot;startend A BC&quot;)

which is the result that Saxon delivers.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>125021</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-02-14 17:36:09 +0000</bug_when>
    <thetext>The seqtor tests for which I get different results (I haven&apos;t analyzed them all in detail) are:

-s:seqtor -t:seqtor-027
Actual:&apos;startend A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | }~&apos;

-s:seqtor -t:seqtor-028
Actual:&apos;startend A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | }~&apos;

s:seqtor -t:seqtor-039a
Actual results:
&lt;bar foo=&quot; | | &quot;/&gt;

-s:seqtor -t:seqtor-039d
Actual results:
&lt;bar foo=&quot;||&quot;/&gt;

-s:seqtor -t:seqtor-040a
Actual results:
&lt;bar&gt; | | &lt;/bar&gt;

-s:seqtor -t:seqtor-040c
Actual results:
&lt;bar&gt; | | &lt;/bar&gt;

-s:seqtor -t:seqtor-040d
Actual results:
&lt;bar&gt;||&lt;/bar&gt;

-s:seqtor -t:seqtor-041
Error on line 16 of seqtor-041.xsl:
  XTTE0570: A sequence of more than one item is not allowed as the value of variable $foo
  (text(&quot;&quot;), text(&quot;&quot;), ...) 
Expected success, got error XTTE0570

-s:seqtor -t:seqtor-042
Error on line 16 of seqtor-042.xsl:
  XTTE0570: A sequence of more than one item is not allowed as the value of variable $foo
  (text(&quot;non-empty&quot;), text(&quot;&quot;), ...) 
Expected success, got error XTTE0570</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>125022</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-02-14 21:32:20 +0000</bug_when>
    <thetext>Regarding seqtor-041 and -042:

seqtor-041 has

    &lt;xsl:variable name=&quot;foo&quot; as=&quot;text()&quot;&gt;
        &lt;!-- multiple empty text nodes are removed --&gt;
        &lt;xsl:text expand-text=&quot;yes&quot;&gt;{ (:hello:) &apos;empty&apos;[false()]}&lt;/xsl:text&gt;
        &lt;xsl:text/&gt;
        &lt;xsl:text expand-text=&quot;yes&quot;&gt;{ (:hello:) &apos;empty&apos;[false()]}&lt;/xsl:text&gt;
    &lt;/xsl:variable&gt;

There is nothing in the spec to justify the comment &quot;multiple empty text nodes are removed&quot;. When xsl:variable has an &quot;as&quot; attribute, the value of the variable is the result of the sequence constructor, modified if necessary by applying the function conversion rules. The rules for constructing simple/complex content are not applied, therefore empty text nodes are not removed, therefore the raw value is a sequence of three text nodes and this fails the type check.

Similarly seqtor-042 - multiple text nodes are NOT combined unless CSC or CCC is invoked, and this only happens when the seqtor is used to construct the content of a node.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>125125</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-02-17 12:00:09 +0000</bug_when>
    <thetext>These tests have been fixed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>125404</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-03-09 14:56:34 +0000</bug_when>
    <thetext>I am still seeing different results for seqtor-027 and -028.

Specifically I am still getting

-s:seqtor -t:seqtor-027
Actual:&apos;startend A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | }~&apos;

-s:seqtor -t:seqtor-028
Actual:&apos;startend A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | }~&apos;

but the expected results have no space between the final &quot;}&quot; and &quot;~&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>125405</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-03-09 15:22:15 +0000</bug_when>
    <thetext>Sorry for the confusion.

The expected results for both tests end in 

x y z { | } ~

The actual results I am getting for both tests ends in

x y z { | }~

that is, without any space between the last two printable characters.

The recursive function is:

    &lt;xsl:function name=&quot;f:create&quot; as=&quot;item()+&quot;&gt;
        &lt;xsl:param name=&quot;i&quot; as=&quot;xs:integer&quot; /&gt;
        &lt;xsl:text expand-text=&quot;yes&quot;&gt;{if($i = 0) then &apos;end&apos; 
            else f:create($i - 1)}&lt;/xsl:text&gt;
        &lt;xsl:sequence select=&quot;codepoints-to-string($i + 65)&quot; /&gt;
    &lt;/xsl:function&gt;

If we consider the first three calls, (X) the call create(61) returns (text(create(60)), &amp;#126;); the call create(60) returns (text(create(59)), &amp;#125;), and the call create(59) returns (text(&apos;....&apos;), &amp;#124;) where &quot;....&quot; is the result of further calls. Combining these results we have

So create(59) returns a text node(&apos;....&apos;) followed by a string(&quot;|&quot;).

text(create(59)) combines these using CSC to a text node (&apos;.... |&apos;)

So create(60) returns a text node (&apos;.... |&apos;) followed by a string(&quot;}&quot;)

text(create(60)) combines these using CSC to a text node (&apos;.... | }&apos;)

create(61) returns this text node followed by the string &quot;~&quot;.

These two items form part of the result of the initial template. They are combined using CSC. The CSC rules do not insert a space between a text node and a string, and therefore in the final result there should be no space preceding the final tilde.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>125408</commentid>
    <comment_count>6</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2016-03-09 16:26:39 +0000</bug_when>
    <thetext>I think you are right, the tests are failing for me as well, with:

Actual string  : startend A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | }~

So, indeed, no space before the final character for reasons of the order of unwinding the recursion. I will update the tests in the repo.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127870</commentid>
    <comment_count>7</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-10-19 19:14:54 +0000</bug_when>
    <thetext>I believe that these problems have now been fixed.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>