Uploaded image for project: 'Apache Flex'
  1. Apache Flex
  2. FLEX-35075

E4X filters need to be smarter

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • Apache FalconJX 0.6.0
    • None
    • FalconJX
    • None

    Description

      The following expression:

      xmlSource.Set1.child.(year == "2015");
      

      compiles into:

      xmlSource.child('Set1').child('child').filter(function(node){return (node.year == "2015")});
      

      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:

      xmlSource.child('Set1').child('child').filter(function(node){return (node.child("year").toString() == "2015")});
      

      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?

      Attachments

        Activity

          People

            Unassigned Unassigned
            harbs Harbs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: