flex-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alex Harui (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLEX-35075) E4X filters need to be smarter
Date Tue, 12 Apr 2016 18:30:25 GMT

    [ https://issues.apache.org/jira/browse/FLEX-35075?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15237708#comment-15237708

Alex Harui commented on FLEX-35075:

I haven't really taken the time to understand the allowed syntax for e4x filters.  It is rather
strange that there is an implied node when evaluating the expression (that just "year" is
allowed instead of "node.year").  This makes the compiler have to make some assumptions when
resolving identifiers (could 'year' be a global or scope variable?).  I'm putting in a fix
to get this simple "year == '2016'" to generate node.child('year') == '2016' for now.  I want
to see what other filters people have actually used.  It may not be practical to map all operators
to function calls.  There might be other complex expressions that don't easily map.  If toString()
is implied and we can just try to insert attribute() and child() calls and let JS run the
rest of the expression, I think that would be easier for the compiler.

> E4X filters need to be smarter
> ------------------------------
>                 Key: FLEX-35075
>                 URL: https://issues.apache.org/jira/browse/FLEX-35075
>             Project: Apache Flex
>          Issue Type: Bug
>          Components: FalconJX
>    Affects Versions: Apache FalconJX 0.6.0
>            Reporter: Harbs
> The following expression:
> {code:actionscript}
> xmlSource.Set1.child.(year == "2015");
> {code}
> compiles into:
> {code:javascript}
> xmlSource.child('Set1').child('child').filter(function(node){return (node.year == "2015")});
> {code}
> This is all fine except for the filter expression.
> node.year means nothing in Javascript.
> I'm not sure the best way to compile this. The following will work, but it will probably
get tricky covering all cases:
> {code:javascript}
> xmlSource.child('Set1').child('child').filter(function(node){return (node.child("year").toString()
== "2015")});
> {code}
> What might make more sense might be to add some helper functions like:
> XML.isEqual(randomObject); (mapped to ==)
> XML.isNotEqual(randomObject); (mapped to !=)
> XML.greaterThan(randomObject); (mapped to >)
> XML.lessThan(randomObject); (mapped to <)
> XML.greaterThanOrEqualTo(randomObject);(mapped to >=)
> XML.lessThanOrEqualTo(randomObject);(mapped to <=)
> And the code will figure out the best way to handle these comparisons based on the type
at runtime.
> In that case, this would compile like this:
> xmlSource.child('Set1').child('child').filter(function(node){return (node.child("year").isEqualTo("2015"))});
> Thoughts?

This message was sent by Atlassian JIRA

View raw message