You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Harbs <ha...@gmail.com> on 2016/05/05 07:49:43 UTC
[FlexJS][XML]appending XMLLists
I have a situation where the FlexJS output is different than the Flash output of XML, but it seems to me like the Flash output is wrong. I’m not sure what I’m missing:
Here’s the (stripped down) code:
var xml2:XML = new XML('<root xmlns:fz="http://ns.adobe.com/mxml/2009"><a><b/></a><a name="fred"/><a>hi<b>yeah!</b></a><a name="frank"/><c/></root>');
var list1:XMLList = xml2.a;
var aaa = list1[0];
var aab = list1[0][0][0];
var list2:XMLList = xml2.child("a");
var list3:XMLList = xml2.descendants();
list3 = list3.(attribute("name").length());
list2[list2.length()] = <c id="1"/>;
list2[0] = <bla/>;
var list4:XMLList = new XMLList();
list4[0] = <a id="1"/>;
list4[1] = <a id="2"/>;
list4[2] = <a id="3"/>;
list1 += list4
trace("after concat");
trace(xml2.toString());
In Flash the output is:
after concat
<root xmlns:fz="http://ns.adobe.com/mxml/2009">
<bla/>
<a name="fred"/>
<a>
hi
<b>yeah!</b>
</a>
<a name="frank"/>
<c id="1"/>
<c/>
</root>
In JS, the output is:
after concat
<root xmlns:fz="http://ns.adobe.com/mxml/2009">
<bla/>
<a name="fred"/>
<a>
hi
<b>yeah!</b>
</a>
<a name="frank"/>
<c/>
<c id="1"/>
<a id="1"/>
<a id="2"/>
<a id="3"/>
</root>
Ignoring the order of the “c” elements for right now (which is a bug I’m going to fix), it seems to me that the three “a” elements that appear in the JS output is correct. I don’t know why Flash does not append the elements to the original XML.
Does anyone have any ideas?
Harbs
Re: [FlexJS][XML]appending XMLLists
Posted by Alex Harui <ah...@adobe.com>.
I thought I fixed this. Is it not working?
Sent from my LG G3, an AT&T 4G LTE smartphone
------ Original message------
From: Harbs
Date: Sat, May 14, 2016 11:53 PM
To: dev@flex.apache.org;
Subject:Re: [FlexJS][XML]appending XMLLists
Alex,
Can you look at this?
On May 12, 2016, at 2:56 PM, Harbs <ha...@gmail.com> wrote:
> I committed my changes, but I need you to look at it.
>
> I commented out the test to get it to compile, but besides that, there’s definitely a problem:
>
> 198: ERROR - Parse error. invalid assignment target
> [java] this.xml2.child('a') = this.xml2.child('a').plus(new XML( '<a id="456"/>'));
>
>
> The original code is the following:
> xml2.a += <a id="456"/>;
>
> I’m not sure how to best handle this.
>
> There are two cases we need to deal with:
> 1. Variable assignment.
> 2. XML children assignment.
>
> Case 1 should simply be foo = foo.plus(bar);
>
> However, case 2 cannot become xml.child(foo) = ...
>
> It could wrap the whole thing in a setChild() call, but that gets kind of complicated. Not sure of any other way, though...
>
> Additionally, my changes are working at all in the simple case of:
> list1 += list4
> which still becomes:
> list1.concat(list4);
>
> A simple “+” is even worse:
> var fud:XMLList = list1 + list4;
> becomes:
> var /** @type {XMLList} */ fud = list1 + list4;
>
> Thanks,
> Harbs
>
> On May 12, 2016, at 1:40 PM, Harbs <ha...@gmail.com> wrote:
>
>> Well I tried this, but something is wrong.
>>
>> I changed the tests to reflect my changes and I’m getting an error in the tests (in TestFlexJSGlobalClasses). How can I see the results of the test to see what’s wrong?
>>
>> On May 10, 2016, at 6:09 PM, Alex Harui <ah...@adobe.com> wrote:
>>
>>>
>>>
>>> On 5/10/16, 8:03 AM, "Harbs" <ha...@gmail.com> wrote:
>>>
>>>> foo = foo.plus(bar);
>>>
>>> OK, well in theory the compiler generated "foo" and is about to add
>>> ".concat(" so you would get "foo.concat(" then "bar" would get emitted.
>>> Try replacing ".concat" with:
>>>
>>> " = "
>>> getWalker().walk(node.getLeftOperandNode()); // should re-output "foo"
>>> "; "
>>> getWalker().walk(node.getLeftOperandNode()); // should re-output "foo"
>>> ".plus("
>>>
>>>
>>> Or something like that. If that doesn't work I will try to look at it
>>> later today.
>>>
>>> -Alex
>>>
>>
>
Re: [FlexJS][XML]appending XMLLists
Posted by Harbs <ha...@gmail.com>.
Alex,
Can you look at this?
On May 12, 2016, at 2:56 PM, Harbs <ha...@gmail.com> wrote:
> I committed my changes, but I need you to look at it.
>
> I commented out the test to get it to compile, but besides that, there’s definitely a problem:
>
> 198: ERROR - Parse error. invalid assignment target
> [java] this.xml2.child('a') = this.xml2.child('a').plus(new XML( '<a id="456"/>'));
>
>
> The original code is the following:
> xml2.a += <a id="456"/>;
>
> I’m not sure how to best handle this.
>
> There are two cases we need to deal with:
> 1. Variable assignment.
> 2. XML children assignment.
>
> Case 1 should simply be foo = foo.plus(bar);
>
> However, case 2 cannot become xml.child(foo) = ...
>
> It could wrap the whole thing in a setChild() call, but that gets kind of complicated. Not sure of any other way, though...
>
> Additionally, my changes are working at all in the simple case of:
> list1 += list4
> which still becomes:
> list1.concat(list4);
>
> A simple “+” is even worse:
> var fud:XMLList = list1 + list4;
> becomes:
> var /** @type {XMLList} */ fud = list1 + list4;
>
> Thanks,
> Harbs
>
> On May 12, 2016, at 1:40 PM, Harbs <ha...@gmail.com> wrote:
>
>> Well I tried this, but something is wrong.
>>
>> I changed the tests to reflect my changes and I’m getting an error in the tests (in TestFlexJSGlobalClasses). How can I see the results of the test to see what’s wrong?
>>
>> On May 10, 2016, at 6:09 PM, Alex Harui <ah...@adobe.com> wrote:
>>
>>>
>>>
>>> On 5/10/16, 8:03 AM, "Harbs" <ha...@gmail.com> wrote:
>>>
>>>> foo = foo.plus(bar);
>>>
>>> OK, well in theory the compiler generated "foo" and is about to add
>>> ".concat(" so you would get "foo.concat(" then "bar" would get emitted.
>>> Try replacing ".concat" with:
>>>
>>> " = "
>>> getWalker().walk(node.getLeftOperandNode()); // should re-output "foo"
>>> "; "
>>> getWalker().walk(node.getLeftOperandNode()); // should re-output "foo"
>>> ".plus("
>>>
>>>
>>> Or something like that. If that doesn't work I will try to look at it
>>> later today.
>>>
>>> -Alex
>>>
>>
>
Re: [FlexJS][XML]appending XMLLists
Posted by Harbs <ha...@gmail.com>.
I committed my changes, but I need you to look at it.
I commented out the test to get it to compile, but besides that, there’s definitely a problem:
198: ERROR - Parse error. invalid assignment target
[java] this.xml2.child('a') = this.xml2.child('a').plus(new XML( '<a id="456"/>'));
The original code is the following:
xml2.a += <a id="456"/>;
I’m not sure how to best handle this.
There are two cases we need to deal with:
1. Variable assignment.
2. XML children assignment.
Case 1 should simply be foo = foo.plus(bar);
However, case 2 cannot become xml.child(foo) = ...
It could wrap the whole thing in a setChild() call, but that gets kind of complicated. Not sure of any other way, though...
Additionally, my changes are working at all in the simple case of:
list1 += list4
which still becomes:
list1.concat(list4);
A simple “+” is even worse:
var fud:XMLList = list1 + list4;
becomes:
var /** @type {XMLList} */ fud = list1 + list4;
Thanks,
Harbs
On May 12, 2016, at 1:40 PM, Harbs <ha...@gmail.com> wrote:
> Well I tried this, but something is wrong.
>
> I changed the tests to reflect my changes and I’m getting an error in the tests (in TestFlexJSGlobalClasses). How can I see the results of the test to see what’s wrong?
>
> On May 10, 2016, at 6:09 PM, Alex Harui <ah...@adobe.com> wrote:
>
>>
>>
>> On 5/10/16, 8:03 AM, "Harbs" <ha...@gmail.com> wrote:
>>
>>> foo = foo.plus(bar);
>>
>> OK, well in theory the compiler generated "foo" and is about to add
>> ".concat(" so you would get "foo.concat(" then "bar" would get emitted.
>> Try replacing ".concat" with:
>>
>> " = "
>> getWalker().walk(node.getLeftOperandNode()); // should re-output "foo"
>> "; "
>> getWalker().walk(node.getLeftOperandNode()); // should re-output "foo"
>> ".plus("
>>
>>
>> Or something like that. If that doesn't work I will try to look at it
>> later today.
>>
>> -Alex
>>
>
Re: [FlexJS][XML]appending XMLLists
Posted by Alex Harui <ah...@adobe.com>.
Results should be in
compiler-jx/target/junit-results/TEST-org.apache.flex.compiler.internal.cod
egen.js.flexjs.TestFlexJSGlobalClasses.xml
-Alex
On 5/12/16, 3:40 AM, "Harbs" <ha...@gmail.com> wrote:
>Well I tried this, but something is wrong.
>
>I changed the tests to reflect my changes and I’m getting an error in the
>tests (in TestFlexJSGlobalClasses). How can I see the results of the test
>to see what’s wrong?
>
>On May 10, 2016, at 6:09 PM, Alex Harui <ah...@adobe.com> wrote:
>
>>
>>
>> On 5/10/16, 8:03 AM, "Harbs" <ha...@gmail.com> wrote:
>>
>>> foo = foo.plus(bar);
>>
>> OK, well in theory the compiler generated "foo" and is about to add
>> ".concat(" so you would get "foo.concat(" then "bar" would get emitted.
>> Try replacing ".concat" with:
>>
>> " = "
>> getWalker().walk(node.getLeftOperandNode()); // should re-output "foo"
>> "; "
>> getWalker().walk(node.getLeftOperandNode()); // should re-output "foo"
>> ".plus("
>>
>>
>> Or something like that. If that doesn't work I will try to look at it
>> later today.
>>
>> -Alex
>>
>
Re: [FlexJS][XML]appending XMLLists
Posted by Harbs <ha...@gmail.com>.
Well I tried this, but something is wrong.
I changed the tests to reflect my changes and I’m getting an error in the tests (in TestFlexJSGlobalClasses). How can I see the results of the test to see what’s wrong?
On May 10, 2016, at 6:09 PM, Alex Harui <ah...@adobe.com> wrote:
>
>
> On 5/10/16, 8:03 AM, "Harbs" <ha...@gmail.com> wrote:
>
>> foo = foo.plus(bar);
>
> OK, well in theory the compiler generated "foo" and is about to add
> ".concat(" so you would get "foo.concat(" then "bar" would get emitted.
> Try replacing ".concat" with:
>
> " = "
> getWalker().walk(node.getLeftOperandNode()); // should re-output "foo"
> "; "
> getWalker().walk(node.getLeftOperandNode()); // should re-output "foo"
> ".plus("
>
>
> Or something like that. If that doesn't work I will try to look at it
> later today.
>
> -Alex
>
Re: [FlexJS][XML]appending XMLLists
Posted by Alex Harui <ah...@adobe.com>.
On 5/10/16, 8:03 AM, "Harbs" <ha...@gmail.com> wrote:
>foo = foo.plus(bar);
OK, well in theory the compiler generated "foo" and is about to add
".concat(" so you would get "foo.concat(" then "bar" would get emitted.
Try replacing ".concat" with:
" = "
getWalker().walk(node.getLeftOperandNode()); // should re-output "foo"
"; "
getWalker().walk(node.getLeftOperandNode()); // should re-output "foo"
".plus("
Or something like that. If that doesn't work I will try to look at it
later today.
-Alex
Re: [FlexJS][XML]appending XMLLists
Posted by Harbs <ha...@gmail.com>.
foo = foo.plus(bar);
On May 10, 2016, at 5:58 PM, Alex Harui <ah...@adobe.com> wrote:
> IOW, what is the full JS you want generated for foo += bar?
Re: [FlexJS][XML]appending XMLLists
Posted by Alex Harui <ah...@adobe.com>.
On 5/10/16, 2:40 AM, "Harbs" <ha...@gmail.com> wrote:
>I’m not sure I totally understand the pattern:
>
> else if (node.getNodeID() == ASTNodeID.Op_AddAssignID)
> {
> getWalker().walk(xmlNode);
> write(".concat(");
> getWalker().walk(node.getRightOperandNode());
> write(ASEmitterTokens.PAREN_CLOSE);
> return;
> }
> else if (node.getNodeID() == ASTNodeID.Op_AddID)
> {
> getWalker().walk(xmlNode);
> write(".copy().concat(");
> getWalker().walk(node.getRightOperandNode());
> write(ASEmitterTokens.PAREN_CLOSE);
> return;
> }
>I think there’s two changes which need to happen. One seems easy:
>write(".copy().concat(“); needs to become write(“.plus(“);
>
>However, for ASTNodeID.Op_AddAssignID we need to add in foo = foo before
>the plus. I’m not sure what I need to do for that. I tried figuring out
>what’s happening in getWalker.walk(), but after a few minutes my limited
>attention span lost it… ;-)
I would first just try changing that to plus() as well. Then compile it
and see if the output is correct or not. If not we can discuss more. In
theory, the left hand side "foo" was already emitted. Is plus() going to
modify foo() or return a copy of the modified results()? IOW, what is the
full JS you want generated for foo += bar?
-Alex
Re: [FlexJS][XML]appending XMLLists
Posted by Harbs <ha...@gmail.com>.
I’m not sure I totally understand the pattern:
else if (node.getNodeID() == ASTNodeID.Op_AddAssignID)
{
getWalker().walk(xmlNode);
write(".concat(");
getWalker().walk(node.getRightOperandNode());
write(ASEmitterTokens.PAREN_CLOSE);
return;
}
else if (node.getNodeID() == ASTNodeID.Op_AddID)
{
getWalker().walk(xmlNode);
write(".copy().concat(");
getWalker().walk(node.getRightOperandNode());
write(ASEmitterTokens.PAREN_CLOSE);
return;
}
I think there’s two changes which need to happen. One seems easy:
write(".copy().concat(“); needs to become write(“.plus(“);
However, for ASTNodeID.Op_AddAssignID we need to add in foo = foo before the plus. I’m not sure what I need to do for that. I tried figuring out what’s happening in getWalker.walk(), but after a few minutes my limited attention span lost it… ;-)
On May 9, 2016, at 10:52 PM, Harbs <ha...@gmail.com> wrote:
>> Feel free to make changes to BinaryOperatorEmitter and see if you can make
>> it all work.
>
> I’ll try, but the last time I did, I was not very successful. I don’t have a Java dev setup, so I’d probably just make these edits in the text editor and run ant to build. What’s the minimum target I need to rebuild FalconJX?
Re: [FlexJS][XML]appending XMLLists
Posted by Harbs <ha...@gmail.com>.
On May 9, 2016, at 8:21 PM, Alex Harui <ah...@adobe.com> wrote:
>
>
> On 5/9/16, 9:44 AM, "Harbs" <ha...@gmail.com> wrote:
>>> OK, after more reading, I think section 7.1.2 confirms your assumption.
>>> But based on the algorithm and that knowledge, do you see any issues
>>> with
>>> the Flash implementation? Yes, it is puzzling that targetObject gets
>>> assigned before the elements are appended, but isn't Flash doing that?
>>
>> I don’t think so. If it was, I’d think that the value would get assigned
>> agin to the XML.
>
> Which specific scenario are you referring to? For scenarios involving
> list4, list4 had targetObject = null so no assignment to any XML should
> occur.
I’m not expressing myself very well. Don’t worry about it. As far as I’m concerned, if it’s working like it’s supposed to (which it is), it does not bother me that the code does not 100% match my reading of the spec.
>>>
>>> OK. I think I changed my mind about this after reading 7.1.2. If you
>>> want to rename the compiler's use of concat() to addition() or plus() it
>>> should be relatively simple. It is in BinaryOperatorEmitter.java. But
>>> I
>>> noticed that the regular code for + is calling copy() then concat() but
>>> +=
>>> doesn't, so the compiler could also generate a copy() first for += as
>>> well. Right now that's a bit inconsistent as to who is in charge of the
>>> implementation, so maybe the compiler should always just call
>>> addition()/plus() and have the actual implementation make the copy.
>>
>> Yes. I was thinking that plus() would mimic “the addition operator”
>> semantics in the spec.
>>
>> so: foo = bar + baz would be foo = bar.plus(baz)
>> and bar += baz would become bar = bar.plus(baz)
>>
>> and plus() would take care of creating the copy and determining whether
>> the objects are all XML or strings/numbers or what-have-you.
>
> Feel free to make changes to BinaryOperatorEmitter and see if you can make
> it all work.
I’ll try, but the last time I did, I was not very successful. I don’t have a Java dev setup, so I’d probably just make these edits in the text editor and run ant to build. What’s the minimum target I need to rebuild FalconJX?
I’m also not sure I’m going to know how to do chaining.
(i.e. bar + foo + baz would need to become bar.plus(foo).plus(baz) )
> I'm not sure how much the compiler will need to be involved in "mixed
> type" expressions. Sometimes things are all coerced to strings and
> sometimes some text gets added to XML so not sure if you can get all cases.
If the left hand XML is converted to String or Number, than we’ll have problems (although toString() seems to work fine). Otherwise I think everything can just work.
Re: [FlexJS][XML]appending XMLLists
Posted by Alex Harui <ah...@adobe.com>.
On 5/9/16, 9:44 AM, "Harbs" <ha...@gmail.com> wrote:
>>OK, after more reading, I think section 7.1.2 confirms your assumption.
>> But based on the algorithm and that knowledge, do you see any issues
>>with
>> the Flash implementation? Yes, it is puzzling that targetObject gets
>> assigned before the elements are appended, but isn't Flash doing that?
>
>I don’t think so. If it was, I’d think that the value would get assigned
>agin to the XML.
Which specific scenario are you referring to? For scenarios involving
list4, list4 had targetObject = null so no assignment to any XML should
occur.
>>OK. I think I changed my mind about this after reading 7.1.2. If you
>> want to rename the compiler's use of concat() to addition() or plus() it
>> should be relatively simple. It is in BinaryOperatorEmitter.java. But
>>I
>> noticed that the regular code for + is calling copy() then concat() but
>>+=
>> doesn't, so the compiler could also generate a copy() first for += as
>> well. Right now that's a bit inconsistent as to who is in charge of the
>> implementation, so maybe the compiler should always just call
>> addition()/plus() and have the actual implementation make the copy.
>
>Yes. I was thinking that plus() would mimic “the addition operator”
>semantics in the spec.
>
>so: foo = bar + baz would be foo = bar.plus(baz)
>and bar += baz would become bar = bar.plus(baz)
>
>and plus() would take care of creating the copy and determining whether
>the objects are all XML or strings/numbers or what-have-you.
Feel free to make changes to BinaryOperatorEmitter and see if you can make
it all work.
I'm not sure how much the compiler will need to be involved in "mixed
type" expressions. Sometimes things are all coerced to strings and
sometimes some text gets added to XML so not sure if you can get all cases.
-Alex
Re: [FlexJS][XML]appending XMLLists
Posted by Harbs <ha...@gmail.com>.
On May 9, 2016, at 6:14 PM, Alex Harui <ah...@adobe.com> wrote:
>
>
> On 5/9/16, 12:00 AM, "Harbs" <ha...@gmail.com> wrote:
>
>>
>> On May 9, 2016, at 8:10 AM, Alex Harui <ah...@adobe.com> wrote:
>>
>>>
>>>
>>> On 5/8/16, 1:18 AM, "Harbs" <ha...@gmail.com> wrote:
>>>
>>>> I’m still having trouble with the spec, though. The spec has the
>>>> following in [[Append]]:
>>>>
>>>> 3. If Type(V) is XMLList,
>>>> a. Let x.[[TargetObject]] = V.[[TargetObject]]
>>>> b. Let x.[[TargetProperty]] = V.[[TargetProperty]]
>>>> c. Let n = V.[[Length]]
>>>> d. If n == 0, Return
>>>> e. For j = 0 to V.[[Length]]-1, let x[i + j] = V[j]
>>>>
>>>> Step e uses bracket assignment to the XMList of the values in the
>>>> right-hand object. As I understand it, bracket assignment inserts the
>>>> object into the target object as well. I think that’s what it says in
>>>> [[Put]], but I’m not sure. Of course, with my understanding, a and b
>>>> should be after step e. So, I’m somewhat confused there...
>>>
>>> Can you be more specific about what text makes you think the bracket
>>> assignment inserts into the targetObject? I'd say that other parts of
>>> the
>>> spec are more explicit about calling [[Put]] and other methods and that
>>> bracket syntax is just assigning values to the internal object for XML
>>> and
>>> XMLList.
>>
>> My assumption is that bracket assignment calls [[Put]].
>
> OK, after more reading, I think section 7.1.2 confirms your assumption.
> But based on the algorithm and that knowledge, do you see any issues with
> the Flash implementation? Yes, it is puzzling that targetObject gets
> assigned before the elements are appended, but isn't Flash doing that?
I don’t think so. If it was, I’d think that the value would get assigned agin to the XML.
In the other places where [[TargetObject]] gets assigned I moved it to the end of the process as well to prevent double assignment. (Which is what I’d do here as well.) Practically, it works and seems to be how it works in Flash, but I don’t see that in the spec.
>
>>
>>>>
>>>> Either way, I think we need to add a plus() method to XML and XMLList
>>>> which does “the right thing” as described by 11.4.1 in the spec.
>>>>
>>>> I’m also not sure every case of addition is being handled correctly:
>>>>
>>>> 1. Number + XML/XMLList
>>>> 2. XML/XMLList + Number
>>>> 3. String + XML/XMLList
>>>> 4. XML/XMLList + String
>>>> 5. XML/XMLList + XML/XMLList
>>>
>>> Well, concat() is currently what is output. It might be only used where
>>> you would want to use plus().
>>
>> concat() currently modifies the original XMLList. We need a method when
>> returns a new one with the value added on. It should also gracefully
>> handle strings and numbers.
>>
>> the compiler should produce the following:
>> list += list4;
>> should become:
>> list1 = list1.plus(list4);
>>
>> It can be
>> list1 = list1.concat(list4);
>>
>> My point is that the behavior of the function — whatever it’s called
>> would need to change. I am using concat internally in XMLList, but I can
>> change that.
>>
>>> But I had a not-so-nice thought: Maybe we need to rewrite our XML
>>> implementation. I am feeling like we made a mistake making up our own
>>> method names thinking that we understood the 'semantics' of E4x. It
>>> might
>>> be that we need to have you implement [[Put]] [[Append]], etc. and have
>>> the compiler generate the algorithms described in the spec.
>>
>> I’m not sure about this. I think it’s important for bracket notation to
>> “just work” without having to cross-compiling to something else. Where we
>> have no choice but to require XML typing, we have no choice, but I think
>> we should keep the code as close to the original as possible.
>
> OK. I think I changed my mind about this after reading 7.1.2. If you
> want to rename the compiler's use of concat() to addition() or plus() it
> should be relatively simple. It is in BinaryOperatorEmitter.java. But I
> noticed that the regular code for + is calling copy() then concat() but +=
> doesn't, so the compiler could also generate a copy() first for += as
> well. Right now that's a bit inconsistent as to who is in charge of the
> implementation, so maybe the compiler should always just call
> addition()/plus() and have the actual implementation make the copy.
Yes. I was thinking that plus() would mimic “the addition operator” semantics in the spec.
so: foo = bar + baz would be foo = bar.plus(baz)
and bar += baz would become bar = bar.plus(baz)
and plus() would take care of creating the copy and determining whether the objects are all XML or strings/numbers or what-have-you.
> -Alex
Re: [FlexJS][XML]appending XMLLists
Posted by Alex Harui <ah...@adobe.com>.
On 5/9/16, 12:00 AM, "Harbs" <ha...@gmail.com> wrote:
>
>On May 9, 2016, at 8:10 AM, Alex Harui <ah...@adobe.com> wrote:
>
>>
>>
>> On 5/8/16, 1:18 AM, "Harbs" <ha...@gmail.com> wrote:
>>
>>> I’m still having trouble with the spec, though. The spec has the
>>> following in [[Append]]:
>>>
>>> 3. If Type(V) is XMLList,
>>> a. Let x.[[TargetObject]] = V.[[TargetObject]]
>>> b. Let x.[[TargetProperty]] = V.[[TargetProperty]]
>>> c. Let n = V.[[Length]]
>>> d. If n == 0, Return
>>> e. For j = 0 to V.[[Length]]-1, let x[i + j] = V[j]
>>>
>>> Step e uses bracket assignment to the XMList of the values in the
>>> right-hand object. As I understand it, bracket assignment inserts the
>>> object into the target object as well. I think that’s what it says in
>>> [[Put]], but I’m not sure. Of course, with my understanding, a and b
>>> should be after step e. So, I’m somewhat confused there...
>>
>> Can you be more specific about what text makes you think the bracket
>> assignment inserts into the targetObject? I'd say that other parts of
>>the
>> spec are more explicit about calling [[Put]] and other methods and that
>> bracket syntax is just assigning values to the internal object for XML
>>and
>> XMLList.
>
>My assumption is that bracket assignment calls [[Put]].
OK, after more reading, I think section 7.1.2 confirms your assumption.
But based on the algorithm and that knowledge, do you see any issues with
the Flash implementation? Yes, it is puzzling that targetObject gets
assigned before the elements are appended, but isn't Flash doing that?
>
>>>
>>> Either way, I think we need to add a plus() method to XML and XMLList
>>> which does “the right thing” as described by 11.4.1 in the spec.
>>>
>>> I’m also not sure every case of addition is being handled correctly:
>>>
>>> 1. Number + XML/XMLList
>>> 2. XML/XMLList + Number
>>> 3. String + XML/XMLList
>>> 4. XML/XMLList + String
>>> 5. XML/XMLList + XML/XMLList
>>
>> Well, concat() is currently what is output. It might be only used where
>> you would want to use plus().
>
>concat() currently modifies the original XMLList. We need a method when
>returns a new one with the value added on. It should also gracefully
>handle strings and numbers.
>
>the compiler should produce the following:
>list += list4;
>should become:
>list1 = list1.plus(list4);
>
>It can be
>list1 = list1.concat(list4);
>
>My point is that the behavior of the function — whatever it’s called
>would need to change. I am using concat internally in XMLList, but I can
>change that.
>
>> But I had a not-so-nice thought: Maybe we need to rewrite our XML
>> implementation. I am feeling like we made a mistake making up our own
>> method names thinking that we understood the 'semantics' of E4x. It
>>might
>> be that we need to have you implement [[Put]] [[Append]], etc. and have
>> the compiler generate the algorithms described in the spec.
>
>I’m not sure about this. I think it’s important for bracket notation to
>“just work” without having to cross-compiling to something else. Where we
>have no choice but to require XML typing, we have no choice, but I think
>we should keep the code as close to the original as possible.
OK. I think I changed my mind about this after reading 7.1.2. If you
want to rename the compiler's use of concat() to addition() or plus() it
should be relatively simple. It is in BinaryOperatorEmitter.java. But I
noticed that the regular code for + is calling copy() then concat() but +=
doesn't, so the compiler could also generate a copy() first for += as
well. Right now that's a bit inconsistent as to who is in charge of the
implementation, so maybe the compiler should always just call
addition()/plus() and have the actual implementation make the copy.
-Alex
Re: [FlexJS][XML]appending XMLLists
Posted by Harbs <ha...@gmail.com>.
On May 9, 2016, at 8:10 AM, Alex Harui <ah...@adobe.com> wrote:
>
>
> On 5/8/16, 1:18 AM, "Harbs" <ha...@gmail.com> wrote:
>
>> I’m still having trouble with the spec, though. The spec has the
>> following in [[Append]]:
>>
>> 3. If Type(V) is XMLList,
>> a. Let x.[[TargetObject]] = V.[[TargetObject]]
>> b. Let x.[[TargetProperty]] = V.[[TargetProperty]]
>> c. Let n = V.[[Length]]
>> d. If n == 0, Return
>> e. For j = 0 to V.[[Length]]-1, let x[i + j] = V[j]
>>
>> Step e uses bracket assignment to the XMList of the values in the
>> right-hand object. As I understand it, bracket assignment inserts the
>> object into the target object as well. I think that’s what it says in
>> [[Put]], but I’m not sure. Of course, with my understanding, a and b
>> should be after step e. So, I’m somewhat confused there...
>
> Can you be more specific about what text makes you think the bracket
> assignment inserts into the targetObject? I'd say that other parts of the
> spec are more explicit about calling [[Put]] and other methods and that
> bracket syntax is just assigning values to the internal object for XML and
> XMLList.
My assumption is that bracket assignment calls [[Put]].
>>
>> Either way, I think we need to add a plus() method to XML and XMLList
>> which does “the right thing” as described by 11.4.1 in the spec.
>>
>> I’m also not sure every case of addition is being handled correctly:
>>
>> 1. Number + XML/XMLList
>> 2. XML/XMLList + Number
>> 3. String + XML/XMLList
>> 4. XML/XMLList + String
>> 5. XML/XMLList + XML/XMLList
>
> Well, concat() is currently what is output. It might be only used where
> you would want to use plus().
concat() currently modifies the original XMLList. We need a method when returns a new one with the value added on. It should also gracefully handle strings and numbers.
the compiler should produce the following:
list += list4;
should become:
list1 = list1.plus(list4);
It can be
list1 = list1.concat(list4);
My point is that the behavior of the function — whatever it’s called would need to change. I am using concat internally in XMLList, but I can change that.
> But I had a not-so-nice thought: Maybe we need to rewrite our XML
> implementation. I am feeling like we made a mistake making up our own
> method names thinking that we understood the 'semantics' of E4x. It might
> be that we need to have you implement [[Put]] [[Append]], etc. and have
> the compiler generate the algorithms described in the spec.
I’m not sure about this. I think it’s important for bracket notation to “just work” without having to cross-compiling to something else. Where we have no choice but to require XML typing, we have no choice, but I think we should keep the code as close to the original as possible.
> This would void your suggestion for adding a foreach() method. Our
> current codegen expects the return of an object to iterate which is what
> the E4x spec says to do.
Like you mentioned there, forEach is not a good solution no-matter.
> This would be a significant amount of work, but might be for the best.
>
> Thoughts?
> -Alex
>
Re: [FlexJS][XML]appending XMLLists
Posted by Alex Harui <ah...@adobe.com>.
On 5/8/16, 1:18 AM, "Harbs" <ha...@gmail.com> wrote:
>I’m still having trouble with the spec, though. The spec has the
>following in [[Append]]:
>
>3. If Type(V) is XMLList,
> a. Let x.[[TargetObject]] = V.[[TargetObject]]
> b. Let x.[[TargetProperty]] = V.[[TargetProperty]]
> c. Let n = V.[[Length]]
> d. If n == 0, Return
> e. For j = 0 to V.[[Length]]-1, let x[i + j] = V[j]
>
>Step e uses bracket assignment to the XMList of the values in the
>right-hand object. As I understand it, bracket assignment inserts the
>object into the target object as well. I think that’s what it says in
>[[Put]], but I’m not sure. Of course, with my understanding, a and b
>should be after step e. So, I’m somewhat confused there...
Can you be more specific about what text makes you think the bracket
assignment inserts into the targetObject? I'd say that other parts of the
spec are more explicit about calling [[Put]] and other methods and that
bracket syntax is just assigning values to the internal object for XML and
XMLList.
>
>Either way, I think we need to add a plus() method to XML and XMLList
>which does “the right thing” as described by 11.4.1 in the spec.
>
>I’m also not sure every case of addition is being handled correctly:
>
>1. Number + XML/XMLList
>2. XML/XMLList + Number
>3. String + XML/XMLList
>4. XML/XMLList + String
>5. XML/XMLList + XML/XMLList
Well, concat() is currently what is output. It might be only used where
you would want to use plus().
But I had a not-so-nice thought: Maybe we need to rewrite our XML
implementation. I am feeling like we made a mistake making up our own
method names thinking that we understood the 'semantics' of E4x. It might
be that we need to have you implement [[Put]] [[Append]], etc. and have
the compiler generate the algorithms described in the spec.
This would void your suggestion for adding a foreach() method. Our
current codegen expects the return of an object to iterate which is what
the E4x spec says to do.
This would be a significant amount of work, but might be for the best.
Thoughts?
-Alex
Re: [FlexJS][XML]appending XMLLists
Posted by Harbs <ha...@gmail.com>.
OK. You are right about this.
When I do this:
list1 += list4 + xml2.z;// leaving out xml2.z prevents the next line from adding <voo/> to the original xml
list1[list1.length()] = <voo/>;
I get:
<root xmlns:fz="http://ns.adobe.com/mxml/2009">
<bla/>
<a name="fred"/>
<a>
hi
<b>yeah!</b>
</a>
<a name="frank"/>
<c id="1"/>
<c/>
<voo/>
</root>
So, anything added to the XMLList afterwards gets added to the original XML.
I’m still having trouble with the spec, though. The spec has the following in [[Append]]:
3. If Type(V) is XMLList,
a. Let x.[[TargetObject]] = V.[[TargetObject]]
b. Let x.[[TargetProperty]] = V.[[TargetProperty]]
c. Let n = V.[[Length]]
d. If n == 0, Return
e. For j = 0 to V.[[Length]]-1, let x[i + j] = V[j]
Step e uses bracket assignment to the XMList of the values in the right-hand object. As I understand it, bracket assignment inserts the object into the target object as well. I think that’s what it says in [[Put]], but I’m not sure. Of course, with my understanding, a and b should be after step e. So, I’m somewhat confused there...
Either way, I think we need to add a plus() method to XML and XMLList which does “the right thing” as described by 11.4.1 in the spec.
I’m also not sure every case of addition is being handled correctly:
1. Number + XML/XMLList
2. XML/XMLList + Number
3. String + XML/XMLList
4. XML/XMLList + String
5. XML/XMLList + XML/XMLList
On May 8, 2016, at 9:10 AM, Alex Harui <ah...@adobe.com> wrote:
>
>
> On 5/7/16, 11:36 AM, "Harbs" <ha...@gmail.com> wrote:
>
>> Right. I read that. This was what I was referring to in my last email.
>>
>> However, the Addition Operator is supposed to call [[Append]] and
>> [[Append]] is supposed to assign the right side target object and target
>> property to the left side object. So why doesn’t the original XML get
>> effected?
>
> For which example? For list = list1 + list4, the steps are:
>
> temp = new XMLList();
> temp.append(list1)
> temp.append(list4);
> list1 = temp;
>
> temp is created with targetObject = null.
> list4 has targetObject = null
>
>
> But also, in re-reading the spec, I don't see where [[Append]] updates the
> targetObject's properties and attributes. There is no mention of [[Put]],
> for example. Maybe manipulation of the targetObject always happens on
> some other assignment?
>
> -Alex
>
Re: [FlexJS][XML]appending XMLLists
Posted by Alex Harui <ah...@adobe.com>.
On 5/7/16, 11:36 AM, "Harbs" <ha...@gmail.com> wrote:
>Right. I read that. This was what I was referring to in my last email.
>
>However, the Addition Operator is supposed to call [[Append]] and
>[[Append]] is supposed to assign the right side target object and target
>property to the left side object. So why doesn’t the original XML get
>effected?
For which example? For list = list1 + list4, the steps are:
temp = new XMLList();
temp.append(list1)
temp.append(list4);
list1 = temp;
temp is created with targetObject = null.
list4 has targetObject = null
But also, in re-reading the spec, I don't see where [[Append]] updates the
targetObject's properties and attributes. There is no mention of [[Put]],
for example. Maybe manipulation of the targetObject always happens on
some other assignment?
-Alex
Re: [FlexJS][XML]appending XMLLists
Posted by Harbs <ha...@gmail.com>.
Right. I read that. This was what I was referring to in my last email.
However, the Addition Operator is supposed to call [[Append]] and [[Append]] is supposed to assign the right side target object and target property to the left side object. So why doesn’t the original XML get effected?
On May 6, 2016, at 9:29 PM, Alex Harui <ah...@adobe.com> wrote:
> I think I found the answer. I was thinking that
>
> list1 += list4, which is equivalent to
> list1 = list1 + list4
>
> would just use the [[Append]] operation. But that isn't true. Further
> down in the spec (in 11.4) it actually addresses Addition operator. And
> in there it says:
>
>
>
>
>
>
>
>
>
> "When both AdditiveExpression and MultiplicativeExpression
> evaluate to either an XML object or an XMLList, the
> addition operator starts by creating a new, empty XMLList
> as the return value. If the left operand evaluates to an
> XML object, it is added to the return value. If the left
> operand evaluates to an XMLList, each XML property of the
> XMLList is added to the return value in order. Likewise,
> if the right operand evaluates to an XML object, it is added
> to the return value. Otherwise, if it is an XMLList each
> XML property of the XMLList is added to the return value in
> order."
>
>
>
>
>
> Note the "new, empty XMLList". So, really, it is doing:
>
>
> temp = new XMLList();
> temp.append(list1)
> temp.append(list4);
> list1 = temp;
>
> But when you run:
>
> xml2.a += list4, which is equivalent to
> xml2.a = xml2.a + list4
>
> It is really doing:
>
> temp = new XMLList();
> temp.append(xml2.a)
> temp.append(list4);
> xml2.a = temp;
>
> Temp doesn't have TargetObject or TargetProperty, and thus in the first
> example, you can see that xml2 would never be affected.
>
> But in the second example, the reason it works is because temp is assigned
> back to xml2.a with the Put operation.
>
> So, IMO, Flash is doing the right thing. Bizarre, but that's what the
> spec says. And why all of your other examples did what they did.
>
> HTH,
> -Alex
>
> On 5/6/16, 1:53 AM, "Harbs" <ha...@gmail.com> wrote:
>
>> But, according to how I’m reading the spec, the following should work,
>> but it doesn’t:
>>
>> list4 = new XMLList();
>> list4[0] = <a id="1"/>;
>> list4[1] = <a id="2"/>;
>> list4[2] = <a id="3"/>;
>>
>> list1 += list4 + xml2.z;
>
Re: [FlexJS][XML]appending XMLLists
Posted by Alex Harui <ah...@adobe.com>.
I think I found the answer. I was thinking that
list1 += list4, which is equivalent to
list1 = list1 + list4
would just use the [[Append]] operation. But that isn't true. Further
down in the spec (in 11.4) it actually addresses Addition operator. And
in there it says:
"When both AdditiveExpression and MultiplicativeExpression
evaluate to either an XML object or an XMLList, the
addition operator starts by creating a new, empty XMLList
as the return value. If the left operand evaluates to an
XML object, it is added to the return value. If the left
operand evaluates to an XMLList, each XML property of the
XMLList is added to the return value in order. Likewise,
if the right operand evaluates to an XML object, it is added
to the return value. Otherwise, if it is an XMLList each
XML property of the XMLList is added to the return value in
order."
Note the "new, empty XMLList". So, really, it is doing:
temp = new XMLList();
temp.append(list1)
temp.append(list4);
list1 = temp;
But when you run:
xml2.a += list4, which is equivalent to
xml2.a = xml2.a + list4
It is really doing:
temp = new XMLList();
temp.append(xml2.a)
temp.append(list4);
xml2.a = temp;
Temp doesn't have TargetObject or TargetProperty, and thus in the first
example, you can see that xml2 would never be affected.
But in the second example, the reason it works is because temp is assigned
back to xml2.a with the Put operation.
So, IMO, Flash is doing the right thing. Bizarre, but that's what the
spec says. And why all of your other examples did what they did.
HTH,
-Alex
On 5/6/16, 1:53 AM, "Harbs" <ha...@gmail.com> wrote:
>But, according to how I’m reading the spec, the following should work,
>but it doesn’t:
>
>list4 = new XMLList();
>list4[0] = <a id="1"/>;
>list4[1] = <a id="2"/>;
>list4[2] = <a id="3"/>;
>
>list1 += list4 + xml2.z;
Re: [FlexJS][XML]appending XMLLists
Posted by Harbs <ha...@gmail.com>.
But, according to how I’m reading the spec, the following should work, but it doesn’t:
list4 = new XMLList();
list4[0] = <a id="1"/>;
list4[1] = <a id="2"/>;
list4[2] = <a id="3"/>;
list1 += list4 + xml2.z;
On May 6, 2016, at 11:29 AM, Harbs <ha...@gmail.com> wrote:
> I got rid of just about everything and it still was not working.
>
> I finally replaced list1 += list4 with xml2.a += list4 and that works.
>
> So the following does not work:
> list1 = xml2.a;
> list1 += list4;
>
> But the following does:
> xml2.a += list4
>
> I’m guessing that the reason the second case works is because it’s actually reassigning all <a> elements of the original xml with the new XMLList.
>
> So the following does what I want:
>
> for(i=0;i<list4.length();i++){
> list1[list1.length()] = list4[i];
> }
>
> which is different than:
>
> list1 += list4;
>
> But:
>
> If I do this:
>
> list4 = xml2.z; // z does not exist
> list4[0] = <a id="1"/>;
> list4[1] = <a id="2"/>;
> list4[2] = <a id="3"/>;
>
> instead of this:
> list4 = new XMLList();
> list4[0] = <a id="1"/>;
> list4[1] = <a id="2"/>;
> list4[2] = <a id="3"/>;
>
> I get the elements appended to the XML.
> Bizarre, but this does jive with your reading of the spec.
>
> On May 6, 2016, at 10:53 AM, Alex Harui <ah...@adobe.com> wrote:
>
>> Hmm.
>>
>> Did you try commenting out lines of code in your first example until it
>> looks like this employees example? Maybe one of the lines cause a bug. I
>> wasn't sure what list1[0][0][0] would be, for example.
>>
>> Or comment out the <c /> node. I just noticed that the append may have
>> picked up the name() from the last node, not the last node in the XMLList,
>> and that would be a bug, IMO.
>>
>> -Alex
>>
>> On 5/6/16, 12:21 AM, "Harbs" <ha...@gmail.com> wrote:
>>
>>> No. That’s not it.
>>>
>>> For example, this:
>>>
>>> var e = <employees>
>>> <employee id="1"><name>Joe</name><age>20</age></employee>
>>> <employee id="2"><name>Sue</name><age>30</age></employee>
>>> </employees>;
>>> // append employees 3 and 4 to the end of the employee list
>>> var newE:XMLList = new XMLList();
>>> newE[0] = <employee id="3"><name>Fred</name></employee>;
>>> newE[1] = <employee id="4"><name>Carol</name></employee>;
>>> e.employee += newE;
>>> trace(e);
>>>
>>> outputs:
>>> <employees>
>>> <employee id="1">
>>> <name>Joe</name>
>>> <age>20</age>
>>> </employee>
>>> <employee id="2">
>>> <name>Sue</name>
>>> <age>30</age>
>>> </employee>
>>> <employee id="3">
>>> <name>Fred</name>
>>> </employee>
>>> <employee id="4">
>>> <name>Carol</name>
>>> </employee>
>>> </employees>
>>>
>>> There’s something about the XML in my test case which is preventing the
>>> appending of either XML or XMLList to the original XML object. It feels
>>> to me like a bug in Flash…
>>>
>>> On May 6, 2016, at 10:06 AM, Alex Harui <ah...@adobe.com> wrote:
>>>
>>>> Well, the spec is checking to see if the thing appended is an XMLList
>>>> and
>>>> in the above example, I think you are appending XML not XMLList so that
>>>> might explain the different behavior.
>>>
>>
>
Re: [FlexJS][XML]appending XMLLists
Posted by Harbs <ha...@gmail.com>.
I got rid of just about everything and it still was not working.
I finally replaced list1 += list4 with xml2.a += list4 and that works.
So the following does not work:
list1 = xml2.a;
list1 += list4;
But the following does:
xml2.a += list4
I’m guessing that the reason the second case works is because it’s actually reassigning all <a> elements of the original xml with the new XMLList.
So the following does what I want:
for(i=0;i<list4.length();i++){
list1[list1.length()] = list4[i];
}
which is different than:
list1 += list4;
But:
If I do this:
list4 = xml2.z; // z does not exist
list4[0] = <a id="1"/>;
list4[1] = <a id="2"/>;
list4[2] = <a id="3"/>;
instead of this:
list4 = new XMLList();
list4[0] = <a id="1"/>;
list4[1] = <a id="2"/>;
list4[2] = <a id="3"/>;
I get the elements appended to the XML.
Bizarre, but this does jive with your reading of the spec.
On May 6, 2016, at 10:53 AM, Alex Harui <ah...@adobe.com> wrote:
> Hmm.
>
> Did you try commenting out lines of code in your first example until it
> looks like this employees example? Maybe one of the lines cause a bug. I
> wasn't sure what list1[0][0][0] would be, for example.
>
> Or comment out the <c /> node. I just noticed that the append may have
> picked up the name() from the last node, not the last node in the XMLList,
> and that would be a bug, IMO.
>
> -Alex
>
> On 5/6/16, 12:21 AM, "Harbs" <ha...@gmail.com> wrote:
>
>> No. That’s not it.
>>
>> For example, this:
>>
>> var e = <employees>
>> <employee id="1"><name>Joe</name><age>20</age></employee>
>> <employee id="2"><name>Sue</name><age>30</age></employee>
>> </employees>;
>> // append employees 3 and 4 to the end of the employee list
>> var newE:XMLList = new XMLList();
>> newE[0] = <employee id="3"><name>Fred</name></employee>;
>> newE[1] = <employee id="4"><name>Carol</name></employee>;
>> e.employee += newE;
>> trace(e);
>>
>> outputs:
>> <employees>
>> <employee id="1">
>> <name>Joe</name>
>> <age>20</age>
>> </employee>
>> <employee id="2">
>> <name>Sue</name>
>> <age>30</age>
>> </employee>
>> <employee id="3">
>> <name>Fred</name>
>> </employee>
>> <employee id="4">
>> <name>Carol</name>
>> </employee>
>> </employees>
>>
>> There’s something about the XML in my test case which is preventing the
>> appending of either XML or XMLList to the original XML object. It feels
>> to me like a bug in Flash…
>>
>> On May 6, 2016, at 10:06 AM, Alex Harui <ah...@adobe.com> wrote:
>>
>>> Well, the spec is checking to see if the thing appended is an XMLList
>>> and
>>> in the above example, I think you are appending XML not XMLList so that
>>> might explain the different behavior.
>>
>
Re: [FlexJS][XML]appending XMLLists
Posted by Alex Harui <ah...@adobe.com>.
Hmm.
Did you try commenting out lines of code in your first example until it
looks like this employees example? Maybe one of the lines cause a bug. I
wasn't sure what list1[0][0][0] would be, for example.
Or comment out the <c /> node. I just noticed that the append may have
picked up the name() from the last node, not the last node in the XMLList,
and that would be a bug, IMO.
-Alex
On 5/6/16, 12:21 AM, "Harbs" <ha...@gmail.com> wrote:
>No. That’s not it.
>
>For example, this:
>
>var e = <employees>
><employee id="1"><name>Joe</name><age>20</age></employee>
><employee id="2"><name>Sue</name><age>30</age></employee>
></employees>;
>// append employees 3 and 4 to the end of the employee list
>var newE:XMLList = new XMLList();
>newE[0] = <employee id="3"><name>Fred</name></employee>;
>newE[1] = <employee id="4"><name>Carol</name></employee>;
>e.employee += newE;
>trace(e);
>
>outputs:
><employees>
> <employee id="1">
> <name>Joe</name>
> <age>20</age>
> </employee>
> <employee id="2">
> <name>Sue</name>
> <age>30</age>
> </employee>
> <employee id="3">
> <name>Fred</name>
> </employee>
> <employee id="4">
> <name>Carol</name>
> </employee>
></employees>
>
>There’s something about the XML in my test case which is preventing the
>appending of either XML or XMLList to the original XML object. It feels
>to me like a bug in Flash…
>
>On May 6, 2016, at 10:06 AM, Alex Harui <ah...@adobe.com> wrote:
>
>> Well, the spec is checking to see if the thing appended is an XMLList
>>and
>> in the above example, I think you are appending XML not XMLList so that
>> might explain the different behavior.
>
Re: [FlexJS][XML]appending XMLLists
Posted by Harbs <ha...@gmail.com>.
No. That’s not it.
For example, this:
var e = <employees>
<employee id="1"><name>Joe</name><age>20</age></employee>
<employee id="2"><name>Sue</name><age>30</age></employee>
</employees>;
// append employees 3 and 4 to the end of the employee list
var newE:XMLList = new XMLList();
newE[0] = <employee id="3"><name>Fred</name></employee>;
newE[1] = <employee id="4"><name>Carol</name></employee>;
e.employee += newE;
trace(e);
outputs:
<employees>
<employee id="1">
<name>Joe</name>
<age>20</age>
</employee>
<employee id="2">
<name>Sue</name>
<age>30</age>
</employee>
<employee id="3">
<name>Fred</name>
</employee>
<employee id="4">
<name>Carol</name>
</employee>
</employees>
There’s something about the XML in my test case which is preventing the appending of either XML or XMLList to the original XML object. It feels to me like a bug in Flash…
On May 6, 2016, at 10:06 AM, Alex Harui <ah...@adobe.com> wrote:
> Well, the spec is checking to see if the thing appended is an XMLList and
> in the above example, I think you are appending XML not XMLList so that
> might explain the different behavior.
Re: [FlexJS][XML]appending XMLLists
Posted by Alex Harui <ah...@adobe.com>.
On 5/5/16, 11:38 PM, "Harbs" <ha...@gmail.com> wrote:
>FWIW, I also tried
>list1 += < id=“1”/>;
>instead of
>list1 += list4
>but that did not work either.
>
>I re-read the spec and it does look like you are reading it right, but it
>does not make sense to me and I don’t know how that jives with the
>behavior in other cases. For example (from the spec):
>
>> Similarly, after evaluating the statements below,
>> var e = <employees>
>> <employee id="1"><name>Joe</name><age>20</age></employee>
>> <employee id="2"><name>Sue</name><age>30</age></employee>
>> </employees>;
>> // append employees 3 and 4 to the end of the employee list
>> e.employee += <employee id="3"><name>Fred</name></employee> +
>> <employee id="4"><name>Carol</name></employee>;
>> the variable “e” would contain the XML value:
>> <employees>
>> <employee id="1"><name>Joe</name><age>20</age></employee>
>> <employee id="2"><name>Sue</name><age>30</age></employee>
>> <employee id="3"><name>Fred</name></employee>
>> <employee id="4"><name>Carol</name></employee>
>> </employees>;
>
>If e.employee loses its targetObject I don’t see how 3 and 4 get appended
>to the XML.
Well, the spec is checking to see if the thing appended is an XMLList and
in the above example, I think you are appending XML not XMLList so that
might explain the different behavior.
>
>I also have no idea what this comment means:
>> Note, however, that the "+=" operation does not necessarily preserve
>>the identity of the XML object specified by the LeftHandSideExpression.
I think that means that the XML object may be replaced instead of modified.
>
>I do believe that my case is pretty “fringe”. I don’t expect that people
>are adding objects to XMLLists and relying on the fact that it will not
>get added to the original XML.
>
>I’m ready to call it a day and say the XML is ready for the 0.7.0
>release. I fully expect there to be more bugs (especially revolving
>around namespaces which is not tested very well), but my test cases are
>all working well.
Way cool to hear that. Add a blurb to the RELEASE_NOTES.
-Alex
Re: [FlexJS][XML]appending XMLLists
Posted by Harbs <ha...@gmail.com>.
FWIW, I also tried
list1 += < id=“1”/>;
instead of
list1 += list4
but that did not work either.
I re-read the spec and it does look like you are reading it right, but it does not make sense to me and I don’t know how that jives with the behavior in other cases. For example (from the spec):
> Similarly, after evaluating the statements below,
> var e = <employees>
> <employee id="1"><name>Joe</name><age>20</age></employee>
> <employee id="2"><name>Sue</name><age>30</age></employee>
> </employees>;
> // append employees 3 and 4 to the end of the employee list
> e.employee += <employee id="3"><name>Fred</name></employee> +
> <employee id="4"><name>Carol</name></employee>;
> the variable “e” would contain the XML value:
> <employees>
> <employee id="1"><name>Joe</name><age>20</age></employee>
> <employee id="2"><name>Sue</name><age>30</age></employee>
> <employee id="3"><name>Fred</name></employee>
> <employee id="4"><name>Carol</name></employee>
> </employees>;
If e.employee loses its targetObject I don’t see how 3 and 4 get appended to the XML.
I also have no idea what this comment means:
> Note, however, that the "+=" operation does not necessarily preserve the identity of the XML object specified by the LeftHandSideExpression.
I do believe that my case is pretty “fringe”. I don’t expect that people are adding objects to XMLLists and relying on the fact that it will not get added to the original XML.
I’m ready to call it a day and say the XML is ready for the 0.7.0 release. I fully expect there to be more bugs (especially revolving around namespaces which is not tested very well), but my test cases are all working well.
Harbs
On May 6, 2016, at 1:45 AM, Alex Harui <ah...@adobe.com> wrote:
> Baffling, isn't it? Reading the spec is equally baffling, but I think I
> see for XMLList Append, that the targetObject of the appended XMLList
> becomes the targetObject of the destination XMLList! That seems really
> surprising to me and why they would do that doesn't jump to mind, but I
> think that's what I see.
>
> HTH,
> -Alex
>
> On 5/5/16, 12:49 AM, "Harbs" <ha...@gmail.com> wrote:
>
>> I have a situation where the FlexJS output is different than the Flash
>> output of XML, but it seems to me like the Flash output is wrong. I’m not
>> sure what I’m missing:
>>
>> Here’s the (stripped down) code:
>>
>> var xml2:XML = new XML('<root
>> xmlns:fz="http://ns.adobe.com/mxml/2009"><a><b/></a><a
>> name="fred"/><a>hi<b>yeah!</b></a><a name="frank"/><c/></root>');
>> var list1:XMLList = xml2.a;
>> var aaa = list1[0];
>> var aab = list1[0][0][0];
>> var list2:XMLList = xml2.child("a");
>> var list3:XMLList = xml2.descendants();
>> list3 = list3.(attribute("name").length());
>> list2[list2.length()] = <c id="1"/>;
>> list2[0] = <bla/>;
>> var list4:XMLList = new XMLList();
>> list4[0] = <a id="1"/>;
>> list4[1] = <a id="2"/>;
>> list4[2] = <a id="3"/>;
>> list1 += list4
>> trace("after concat");
>> trace(xml2.toString());
>>
>> In Flash the output is:
>>
>> after concat
>> <root xmlns:fz="http://ns.adobe.com/mxml/2009">
>> <bla/>
>> <a name="fred"/>
>> <a>
>> hi
>> <b>yeah!</b>
>> </a>
>> <a name="frank"/>
>> <c id="1"/>
>> <c/>
>> </root>
>>
>> In JS, the output is:
>>
>> after concat
>> <root xmlns:fz="http://ns.adobe.com/mxml/2009">
>> <bla/>
>> <a name="fred"/>
>> <a>
>> hi
>> <b>yeah!</b>
>> </a>
>> <a name="frank"/>
>> <c/>
>> <c id="1"/>
>> <a id="1"/>
>> <a id="2"/>
>> <a id="3"/>
>> </root>
>>
>> Ignoring the order of the “c” elements for right now (which is a bug I’m
>> going to fix), it seems to me that the three “a” elements that appear in
>> the JS output is correct. I don’t know why Flash does not append the
>> elements to the original XML.
>>
>> Does anyone have any ideas?
>>
>> Harbs
>
Re: [FlexJS][XML]appending XMLLists
Posted by Alex Harui <ah...@adobe.com>.
Baffling, isn't it? Reading the spec is equally baffling, but I think I
see for XMLList Append, that the targetObject of the appended XMLList
becomes the targetObject of the destination XMLList! That seems really
surprising to me and why they would do that doesn't jump to mind, but I
think that's what I see.
HTH,
-Alex
On 5/5/16, 12:49 AM, "Harbs" <ha...@gmail.com> wrote:
>I have a situation where the FlexJS output is different than the Flash
>output of XML, but it seems to me like the Flash output is wrong. I’m not
>sure what I’m missing:
>
>Here’s the (stripped down) code:
>
>var xml2:XML = new XML('<root
>xmlns:fz="http://ns.adobe.com/mxml/2009"><a><b/></a><a
>name="fred"/><a>hi<b>yeah!</b></a><a name="frank"/><c/></root>');
>var list1:XMLList = xml2.a;
>var aaa = list1[0];
>var aab = list1[0][0][0];
>var list2:XMLList = xml2.child("a");
>var list3:XMLList = xml2.descendants();
>list3 = list3.(attribute("name").length());
>list2[list2.length()] = <c id="1"/>;
>list2[0] = <bla/>;
>var list4:XMLList = new XMLList();
>list4[0] = <a id="1"/>;
>list4[1] = <a id="2"/>;
>list4[2] = <a id="3"/>;
>list1 += list4
>trace("after concat");
>trace(xml2.toString());
>
>In Flash the output is:
>
>after concat
><root xmlns:fz="http://ns.adobe.com/mxml/2009">
> <bla/>
> <a name="fred"/>
> <a>
> hi
> <b>yeah!</b>
> </a>
> <a name="frank"/>
> <c id="1"/>
> <c/>
></root>
>
>In JS, the output is:
>
>after concat
><root xmlns:fz="http://ns.adobe.com/mxml/2009">
> <bla/>
> <a name="fred"/>
> <a>
> hi
> <b>yeah!</b>
> </a>
> <a name="frank"/>
> <c/>
> <c id="1"/>
> <a id="1"/>
> <a id="2"/>
> <a id="3"/>
></root>
>
>Ignoring the order of the “c” elements for right now (which is a bug I’m
>going to fix), it seems to me that the three “a” elements that appear in
>the JS output is correct. I don’t know why Flash does not append the
>elements to the original XML.
>
>Does anyone have any ideas?
>
>Harbs
Re: [FlexJS][XML]appending XMLLists
Posted by Harbs <ha...@gmail.com>.
I’ve tried quite a number of angles on this, and I am just as clueless as when I started.
Nothing I do seems to get the a elements added in Flash.
I’m really stumped on this. I’m going to leave the JS output as it is until someone can explain to me why it’s wrong…
On May 5, 2016, at 10:49 AM, Harbs <ha...@gmail.com> wrote:
> I have a situation where the FlexJS output is different than the Flash output of XML, but it seems to me like the Flash output is wrong. I’m not sure what I’m missing:
>
> Here’s the (stripped down) code:
>
> var xml2:XML = new XML('<root xmlns:fz="http://ns.adobe.com/mxml/2009"><a><b/></a><a name="fred"/><a>hi<b>yeah!</b></a><a name="frank"/><c/></root>');
> var list1:XMLList = xml2.a;
> var aaa = list1[0];
> var aab = list1[0][0][0];
> var list2:XMLList = xml2.child("a");
> var list3:XMLList = xml2.descendants();
> list3 = list3.(attribute("name").length());
> list2[list2.length()] = <c id="1"/>;
> list2[0] = <bla/>;
> var list4:XMLList = new XMLList();
> list4[0] = <a id="1"/>;
> list4[1] = <a id="2"/>;
> list4[2] = <a id="3"/>;
> list1 += list4
> trace("after concat");
> trace(xml2.toString());
>
> In Flash the output is:
>
> after concat
> <root xmlns:fz="http://ns.adobe.com/mxml/2009">
> <bla/>
> <a name="fred"/>
> <a>
> hi
> <b>yeah!</b>
> </a>
> <a name="frank"/>
> <c id="1"/>
> <c/>
> </root>
>
> In JS, the output is:
>
> after concat
> <root xmlns:fz="http://ns.adobe.com/mxml/2009">
> <bla/>
> <a name="fred"/>
> <a>
> hi
> <b>yeah!</b>
> </a>
> <a name="frank"/>
> <c/>
> <c id="1"/>
> <a id="1"/>
> <a id="2"/>
> <a id="3"/>
> </root>
>
> Ignoring the order of the “c” elements for right now (which is a bug I’m going to fix), it seems to me that the three “a” elements that appear in the JS output is correct. I don’t know why Flash does not append the elements to the original XML.
>
> Does anyone have any ideas?
>
> Harbs