RE: [Flashcoders] E4X filtering strange behaviour

2008-07-22 Thread Merrill, Jason
That was it, it works now, thanks.  Funny, I didn't notice that, I had
it in my code before, but somewhere along the line of messing with
things, it just switched back over to .toString() and I hadn't noticed.
Thanks everyone! 

One more question if I may - how can I exclude certain things like blank
spaces?  I mean, I could check the textfield, but it would seem there is
an easier way.  If I put a blank space (or nothing for that matter) in
the input text field and search for that, it returns all nodes.  I could
check the input text field, but I'd rather do it with a regular
expression (both for elegance and to learn).  The help docs are skimpy,
so excuse so many questions here.  It's also such a huge subject, it's
very hard to Google exactly what you need.

Jason Merrill 
Bank of America 
Enterprise Technology  Global Risk LLD 
Instructional Technology  Media

Join the Bank of America Flash Platform Developer Community 

Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe. 

 

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] E4X filtering strange behaviour

2008-07-22 Thread Kenneth Kawamoto
I could be wrong but that (user input validation) should be done prior 
to RegExp construction.


Kenneth Kawamoto
http://www.materiaprima.co.uk/

Merrill, Jason wrote:

That was it, it works now, thanks.  Funny, I didn't notice that, I had
it in my code before, but somewhere along the line of messing with
things, it just switched back over to .toString() and I hadn't noticed.
Thanks everyone! 


One more question if I may - how can I exclude certain things like blank
spaces?  I mean, I could check the textfield, but it would seem there is
an easier way.  If I put a blank space (or nothing for that matter) in
the input text field and search for that, it returns all nodes.  I could
check the input text field, but I'd rather do it with a regular
expression (both for elegance and to learn).  The help docs are skimpy,
so excuse so many questions here.  It's also such a huge subject, it's
very hard to Google exactly what you need.


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] E4X filtering strange behaviour

2008-07-21 Thread Merrill, Jason
Ah, I know where the confusion came from, you said the code was based on
my example, but that was actually Wagner's example, where he put

var test:XML = data...etc.

(it was based on my example, but he used test as an instance of the
XML when requoting my original question) The use of test as the XML
name threw me, because it was mixed in with the regex method, re.test
- I never realized you meant test as the XML not test as some regex
method I wasn't aware of.  So when you wrote

var xmlListSearch:XMLList = 
test..*.(re[test](attribute(*)) || re[test](child(*)));

You meant

var xmlListSearch:XMLList =  theXML..*.(re[test](attribute(*)) ||
re[test](child(*)));

Got it, I'll give it a shot, thanks.

Jason Merrill 
Bank of America 
Enterprise Technology  Global Risk LLD 
Instructional Technology  Media

Join the Bank of America Flash Platform Developer Community 

Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe. 

 
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] E4X filtering strange behaviour

2008-07-21 Thread Merrill, Jason
 Also this is shorter:
 var xmlListSearch:XMLList = test..topic.(re.test(@title));

If we don't know anything about the XML we could do something like:

var xmlListSearch:XMLList = 
test..*.(re[test](attribute(*)) || re[test](child(*)));

Kenneth - no, what I mean is, your examples aren't pointing to any XML
instance at all (that I could see anyway, maybe you could point it out),
so how in the world can the AVM know what you're referring to in order
to search though and make an XMLList from?

Jason Merrill 
Bank of America 
Enterprise Technology  Global Risk LLD 
Instructional Technology  Media

Join the Bank of America Flash Platform Developer Community 

Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe. 

 

-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf 
Of Kenneth Kawamoto
Sent: Saturday, July 19, 2008 6:19 AM
To: Flash Coders List
Subject: Re: [Flashcoders] E4X filtering strange behaviour

The code was based on your example and therefore we know the 
XML schema, i.e. we know the node name and they all have the 
attribute title.

If we don't know anything about the XML we could do something like:

var xmlListSearch:XMLList = 
test..*.(re[test](attribute(*)) || re[test](child(*)));

Kenneth Kawamoto
http://www.materiaprima.co.uk/

Merrill, Jason wrote:
 Thanks.  However, I have been told using @title is not good in most 
 situations because it will return an error if a node 
doesn't have the 
 attribute, wheras attribute(title) will not.
 
 Also this is shorter:
 var xmlListSearch:XMLList = test..topic.(re.test(@title));
 
 But you still need to specify what XML to search through, no?  How 
 would the above know what XML object topic is within using 
the code above?
 
 Jason Merrill
 
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] E4X filtering strange behaviour

2008-07-21 Thread Merrill, Jason
Kenneth - no, what I mean is, your examples aren't pointing 
to any XML instance at all

Disregard that last post - see my follow up on it instead.

Jason Merrill 
Bank of America 
Enterprise Technology  Global Risk LLD 
Instructional Technology  Media

Join the Bank of America Flash Platform Developer Community 

Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe. 

 

-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf 
Of Merrill, Jason
Sent: Monday, July 21, 2008 10:08 AM
To: Flash Coders List
Subject: RE: [Flashcoders] E4X filtering strange behaviour

 Also this is shorter:
 var xmlListSearch:XMLList = test..topic.(re.test(@title));

If we don't know anything about the XML we could do something like:

var xmlListSearch:XMLList =
test..*.(re[test](attribute(*)) || re[test](child(*)));

Kenneth - no, what I mean is, your examples aren't pointing 
to any XML instance at all (that I could see anyway, maybe 
you could point it out), so how in the world can the AVM know 
what you're referring to in order to search though and make 
an XMLList from?

Jason Merrill
Bank of America
Enterprise Technology  Global Risk LLD Instructional 
Technology  Media

Join the Bank of America Flash Platform Developer Community 

Are you a Bank of America associate interested in innovative 
learning ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe. 

 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of 
Kenneth Kawamoto
Sent: Saturday, July 19, 2008 6:19 AM
To: Flash Coders List
Subject: Re: [Flashcoders] E4X filtering strange behaviour

The code was based on your example and therefore we know the XML 
schema, i.e. we know the node name and they all have the attribute 
title.

If we don't know anything about the XML we could do something like:

var xmlListSearch:XMLList =
test..*.(re[test](attribute(*)) || re[test](child(*)));

Kenneth Kawamoto
http://www.materiaprima.co.uk/

Merrill, Jason wrote:
 Thanks.  However, I have been told using @title is not 
good in most 
 situations because it will return an error if a node
doesn't have the
 attribute, wheras attribute(title) will not.
 
 Also this is shorter:
 var xmlListSearch:XMLList = test..topic.(re.test(@title));
 
 But you still need to specify what XML to search through, 
no?  How 
 would the above know what XML object topic is within using
the code above?
 
 Jason Merrill
 
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] E4X filtering strange behaviour

2008-07-21 Thread Kenneth Kawamoto

Yes that's that :)

Anyway in your case you know the incoming XML schema so you shouldn't 
use wildcard * - I think wildcards have serious performance hits.


i.e. theXML.topics.topic. should be used rather than theXML..*.

Kenneth Kawamoto
http://www.materiaprima.co.uk/

Merrill, Jason wrote:

Ah, I know where the confusion came from, you said the code was based on
my example, but that was actually Wagner's example, where he put

var test:XML = data...etc.

(it was based on my example, but he used test as an instance of the
XML when requoting my original question) The use of test as the XML
name threw me, because it was mixed in with the regex method, re.test
- I never realized you meant test as the XML not test as some regex
method I wasn't aware of.  So when you wrote

var xmlListSearch:XMLList = 
test..*.(re[test](attribute(*)) || re[test](child(*)));


You meant

var xmlListSearch:XMLList =  theXML..*.(re[test](attribute(*)) ||
re[test](child(*)));

Got it, I'll give it a shot, thanks.

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] E4X filtering strange behaviour

2008-07-21 Thread Merrill, Jason
OK good to know, thanks!

Jason Merrill 
Bank of America 
Enterprise Technology  Global Risk LLD 
Instructional Technology  Media

Join the Bank of America Flash Platform Developer Community 

Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe. 

 

-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf 
Of Kenneth Kawamoto
Sent: Monday, July 21, 2008 12:52 PM
To: Flash Coders List
Subject: Re: [Flashcoders] E4X filtering strange behaviour

Yes that's that :)

Anyway in your case you know the incoming XML schema so you 
shouldn't use wildcard * - I think wildcards have serious 
performance hits.

i.e. theXML.topics.topic. should be used rather than theXML..*.

Kenneth Kawamoto
http://www.materiaprima.co.uk/

Merrill, Jason wrote:
 Ah, I know where the confusion came from, you said the code 
was based 
 on my example, but that was actually Wagner's example, where he put
 
 var test:XML = data...etc.
 
 (it was based on my example, but he used test as an 
instance of the 
 XML when requoting my original question) The use of test 
as the XML 
 name threw me, because it was mixed in with the regex 
method, re.test
 - I never realized you meant test as the XML not test as 
some regex 
 method I wasn't aware of.  So when you wrote
 
 var xmlListSearch:XMLList =
 test..*.(re[test](attribute(*)) || re[test](child(*)));
 
 You meant
 
 var xmlListSearch:XMLList =  
theXML..*.(re[test](attribute(*)) || 
 re[test](child(*)));
 
 Got it, I'll give it a shot, thanks.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] E4X filtering strange behaviour

2008-07-21 Thread Merrill, Jason
OK, so this is almost there, but not quite.  If I do as Kenneth
suggested (and this should be able to be reproduced), 

var testXML:XML = data
topics
topic title=Coldplays New Album /
topic title=The Dark Knight /
topic title=Arrested Development: The
Movie /
/topics
/data;

var re:RegExp = new RegExp(^+searchInput.text);
var xmlListSearch:XMLList = testXML.topics.topic.(re[test](@title));
trace(result: +xmlListSearch.toXMLString());

(Assuming there is a TextInput text field on the stage and a function
run when a button is clicked to run the regex search), if I enter the
search term, The, it only returns the second node containing The Dark
Knight, not the third topic node, which has a The in it's title
attribute as well.  If I put Dark, it doesn't return anything.  So it
seems it's only searching nodes where the search term is the first item.
How can I modify the regular expression above to find all nodes
containing an element of the search term?

Thanks,

Jason Merrill 
Bank of America 
Enterprise Technology  Global Risk LLD 
Instructional Technology  Media

Join the Bank of America Flash Platform Developer Community 

Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe. 

 
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] E4X filtering strange behaviour

2008-07-21 Thread Robert Leisle
Hi Jason,

This works for me:
var testXML:XML = data
topics
topic title=Coldplays New Album /
topic title=The Dark Knight /
topic title=Arrested Development: The
Movie /
/topics
/data;

var re:RegExp = new RegExp(searchInput.text, g); 
var xmlListSearch:XMLList = testXML.topics.topic.(re[test](@title));
trace(result: +xmlListSearch.toXMLString());

Hth,
Bob

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Merrill,
Jason
Sent: Monday, July 21, 2008 12:27 PM
To: Flash Coders List
Subject: RE: [Flashcoders] E4X filtering strange behaviour

OK, so this is almost there, but not quite.  If I do as Kenneth
suggested (and this should be able to be reproduced), 

var testXML:XML = data
topics
topic title=Coldplays New Album /
topic title=The Dark Knight /
topic title=Arrested Development: The
Movie /
/topics
/data;

var re:RegExp = new RegExp(^+searchInput.text);
var xmlListSearch:XMLList = testXML.topics.topic.(re[test](@title));
trace(result: +xmlListSearch.toXMLString());

(Assuming there is a TextInput text field on the stage and a function
run when a button is clicked to run the regex search), if I enter the
search term, The, it only returns the second node containing The Dark
Knight, not the third topic node, which has a The in it's title
attribute as well.  If I put Dark, it doesn't return anything.  So it
seems it's only searching nodes where the search term is the first item.
How can I modify the regular expression above to find all nodes
containing an element of the search term?

Thanks,

Jason Merrill 
Bank of America 
Enterprise Technology  Global Risk LLD 
Instructional Technology  Media

Join the Bank of America Flash Platform Developer Community 

Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe. 

 
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] E4X filtering strange behaviour

2008-07-21 Thread Merrill, Jason
var re:RegExp = new RegExp(searchInput.text, g)

Thanks - so it looks like I need the global flag, but how do I also pass
the i (ignore case) flag if the RegExp constructor only takes the two
arguments?


Jason Merrill 
Bank of America 
Enterprise Technology  Global Risk LLD 
Instructional Technology  Media

Join the Bank of America Flash Platform Developer Community 

Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe. 

 
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] E4X filtering strange behaviour

2008-07-21 Thread Merrill, Jason
Wait, think I got it:

var re:RegExp = new RegExp(searchInput.text, g,i);

var xmlListSearch:XMLList = testXML..*.( re[test](
attribute(title)));

trace(result: +xmlListSearch.toString());

seems to work for me.  Thanks eveyrone!

Jason Merrill 
Bank of America 
Enterprise Technology  Global Risk LLD 
Instructional Technology  Media

Join the Bank of America Flash Platform Developer Community 

Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe. 

 

-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf 
Of Robert Leisle
Sent: Monday, July 21, 2008 3:54 PM
To: 'Flash Coders List'
Subject: RE: [Flashcoders] E4X filtering strange behaviour

Hi Jason,

This works for me:
var testXML:XML = data
  topics
  topic title=Coldplays New Album /
  topic title=The Dark Knight /
  topic title=Arrested 
Development: The Movie /
  /topics
  /data;

var re:RegExp = new RegExp(searchInput.text, g); var 
xmlListSearch:XMLList = testXML.topics.topic.(re[test](@title));
trace(result: +xmlListSearch.toXMLString());

Hth,
Bob

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf 
Of Merrill, Jason
Sent: Monday, July 21, 2008 12:27 PM
To: Flash Coders List
Subject: RE: [Flashcoders] E4X filtering strange behaviour

OK, so this is almost there, but not quite.  If I do as 
Kenneth suggested (and this should be able to be reproduced), 

var testXML:XML = data
  topics
  topic title=Coldplays New Album /
  topic title=The Dark Knight /
  topic title=Arrested 
Development: The Movie /
  /topics
  /data;

var re:RegExp = new RegExp(^+searchInput.text); var 
xmlListSearch:XMLList = testXML.topics.topic.(re[test](@title));
trace(result: +xmlListSearch.toXMLString());

(Assuming there is a TextInput text field on the stage and a 
function run when a button is clicked to run the regex 
search), if I enter the search term, The, it only returns 
the second node containing The Dark Knight, not the third 
topic node, which has a The in it's title attribute as 
well.  If I put Dark, it doesn't return anything.  So it 
seems it's only searching nodes where the search term is the 
first item.
How can I modify the regular expression above to find all 
nodes containing an element of the search term?

Thanks,

Jason Merrill
Bank of America
Enterprise Technology  Global Risk LLD Instructional 
Technology  Media

Join the Bank of America Flash Platform Developer Community 

Are you a Bank of America associate interested in innovative 
learning ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe. 

 
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] E4X filtering strange behaviour

2008-07-21 Thread Merrill, Jason
OK, I'm like 95% there, but there is still some kind of bug - here is
how to reproduce:

var testXML:XML = data
 topics
   topic title=Coldplay's New Album, Viva La Vida Or Death And All His
Friends /
   topic title=The Dark Knight /
   topic title=Arrested Development, The Movie /
   topic title=Band Of Horses: Everything All The Time /
   topic title=Master And Commander: The Far Side Of The World /
   topic title=The Quick Brown Fox Jumped Over The Lazy Dog /
   topic title=Violet Hill /
  /topics
 /data;

var re:RegExp = new RegExp(The, g,i);

var xmlListSearch:XMLList = testXML..*.topic.( re[test](
attribute(title)));

trace(result: +xmlListSearch.toString());


If you search for the word, the, as I do when I construct the regular
expression, you should get 5 nodes returned into the XMLList, but I only
get these four:

topic title=The Dark Knight/
topic title=Arrested Development, The Movie/
topic title=Band Of Horses: Everything All The Time/
topic title=Master And Commander: The Far Side Of The World/

I don't get this node:

 topic title=The Quick Brown Fox Jumped Over The Lazy Dog /

? Any idea why?  Does it fail if there is more than one the in the
string?



Jason Merrill 
Bank of America 
Enterprise Technology  Global Risk LLD 
Instructional Technology  Media

Join the Bank of America Flash Platform Developer Community 

Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe. 

 
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] E4X filtering strange behaviour

2008-07-21 Thread Kenneth Kawamoto

I don't think you need g (Global flag) for this.

Kenneth Kawamoto
http://www.materiaprima.co.uk/

Merrill, Jason wrote:

Wait, think I got it:

var re:RegExp = new RegExp(searchInput.text, g,i);

var xmlListSearch:XMLList = testXML..*.( re[test](
attribute(title)));

trace(result: +xmlListSearch.toString());

seems to work for me.  Thanks eveyrone!

Jason Merrill 
Bank of America 
Enterprise Technology  Global Risk LLD 
Instructional Technology  Media


Join the Bank of America Flash Platform Developer Community 


Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe. 

 


-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf 
Of Robert Leisle

Sent: Monday, July 21, 2008 3:54 PM
To: 'Flash Coders List'
Subject: RE: [Flashcoders] E4X filtering strange behaviour

Hi Jason,

This works for me:
var testXML:XML = data
topics
topic title=Coldplays New Album /
topic title=The Dark Knight /
topic title=Arrested 
Development: The Movie /

/topics
/data;

var re:RegExp = new RegExp(searchInput.text, g); var 
xmlListSearch:XMLList = testXML.topics.topic.(re[test](@title));

trace(result: +xmlListSearch.toXMLString());

Hth,
Bob

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf 
Of Merrill, Jason

Sent: Monday, July 21, 2008 12:27 PM
To: Flash Coders List
Subject: RE: [Flashcoders] E4X filtering strange behaviour

OK, so this is almost there, but not quite.  If I do as 
Kenneth suggested (and this should be able to be reproduced), 


var testXML:XML = data
topics
topic title=Coldplays New Album /
topic title=The Dark Knight /
topic title=Arrested 
Development: The Movie /

/topics
/data;

var re:RegExp = new RegExp(^+searchInput.text); var 
xmlListSearch:XMLList = testXML.topics.topic.(re[test](@title));

trace(result: +xmlListSearch.toXMLString());

(Assuming there is a TextInput text field on the stage and a 
function run when a button is clicked to run the regex 
search), if I enter the search term, The, it only returns 
the second node containing The Dark Knight, not the third 
topic node, which has a The in it's title attribute as 
well.  If I put Dark, it doesn't return anything.  So it 
seems it's only searching nodes where the search term is the 
first item.
How can I modify the regular expression above to find all 
nodes containing an element of the search term?

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] E4X filtering strange behaviour

2008-07-21 Thread Wagner Amaral
Indeed, the g seems to make it not work. Not a big problem, since it's
useless in this case - the g flag in a test() call makes the search start
at a specified index (lastIndex property)
What may have confused you, Jason, is the example Robert posted fixed your
problem (by removing the ^ character from the regexp - the ^ when the
first character on a regexp means match at the start of the line), and
also added the g flag, which is not quite what you wanted. So just drop it
and it will work ;)

Side note: I really hate the re[test](...) kind of syntax, so here goes my
suggestion:
(re as RegExp).test(...)



On Mon, Jul 21, 2008 at 5:40 PM, Kenneth Kawamoto [EMAIL PROTECTED]
wrote:

 I don't think you need g (Global flag) for this.

 Kenneth Kawamoto
 http://www.materiaprima.co.uk/

 Merrill, Jason wrote:

 Wait, think I got it:

 var re:RegExp = new RegExp(searchInput.text, g,i);

 var xmlListSearch:XMLList = testXML..*.( re[test](
 attribute(title)));

 trace(result: +xmlListSearch.toString());

 seems to work for me.  Thanks eveyrone!

 Jason Merrill Bank of America Enterprise Technology  Global Risk LLD
 Instructional Technology  Media

 Join the Bank of America Flash Platform Developer Community
 Are you a Bank of America associate interested in innovative learning
 ideas and technologies?
 Check out our internal  GTO Innovative Learning Blog  subscribe.


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:
 [EMAIL PROTECTED] On Behalf Of Robert Leisle
 Sent: Monday, July 21, 2008 3:54 PM
 To: 'Flash Coders List'
 Subject: RE: [Flashcoders] E4X filtering strange behaviour

 Hi Jason,

 This works for me:
 var testXML:XML = data
topics
topic title=Coldplays New Album /
topic title=The Dark Knight /
topic title=Arrested Development: The
 Movie /
/topics
/data;

 var re:RegExp = new RegExp(searchInput.text, g); var
 xmlListSearch:XMLList = testXML.topics.topic.(re[test](@title));
 trace(result: +xmlListSearch.toXMLString());

 Hth,
 Bob

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of
 Merrill, Jason
 Sent: Monday, July 21, 2008 12:27 PM
 To: Flash Coders List
 Subject: RE: [Flashcoders] E4X filtering strange behaviour

 OK, so this is almost there, but not quite.  If I do as Kenneth
 suggested (and this should be able to be reproduced),
 var testXML:XML = data
topics
topic title=Coldplays New Album /
topic title=The Dark Knight /
topic title=Arrested Development: The
 Movie /
/topics
/data;

 var re:RegExp = new RegExp(^+searchInput.text); var
 xmlListSearch:XMLList = testXML.topics.topic.(re[test](@title));
 trace(result: +xmlListSearch.toXMLString());

 (Assuming there is a TextInput text field on the stage and a function
 run when a button is clicked to run the regex search), if I enter the 
 search
 term, The, it only returns the second node containing The Dark Knight,
 not the third topic node, which has a The in it's title attribute as 
 well.
  If I put Dark, it doesn't return anything.  So it seems it's only
 searching nodes where the search term is the first item.
 How can I modify the regular expression above to find all nodes
 containing an element of the search term?

 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] E4X filtering strange behaviour

2008-07-21 Thread Kenneth Kawamoto
If I may repeat myself I don't think you need g (Global flag) for 
this. :)


The reason is, I quote from the doc, If the g (global) flag is set for 
the regular expression, then the search starts at the index position 
specified by the lastIndex property of the regular expression. If the 
search matches a substring, the lastIndex property changes to match the 
position of the end of the match. 


To prove this point, if I do something like:

//
var re:RegExp;

re = new RegExp(The, gi); // with global flag

for each(var prop1:XML in testXML.topics.topic){
   trace(re.lastIndex,  - , [EMAIL PROTECTED],  - , 
re[test]([EMAIL PROTECTED]));

}

trace(***);

re = new RegExp(The, i); // without global flag

for each(var prop2:XML in testXML.topics.topic){
   trace(re.lastIndex,  - , [EMAIL PROTECTED],  - , 
re[test]([EMAIL PROTECTED]));

}
//

I'd get:

0  -  Coldplay's New Album, Viva La Vida Or Death And All His Friends  - 
 false

0  -  The Dark Knight  -  true
3  -  Arrested Development, The Movie  -  true
25  -  Band Of Horses: Everything All The Time  -  true
34  -  Master And Commander: The Far Side Of The World  -  true
41  -  The Quick Brown Fox Jumped Over The Lazy Dog  -  false
0  -  Violet Hill  -  false
***
0  -  Coldplay's New Album, Viva La Vida Or Death And All His Friends  - 
 false

0  -  The Dark Knight  -  true
0  -  Arrested Development, The Movie  -  true
0  -  Band Of Horses: Everything All The Time  -  true
0  -  Master And Commander: The Far Side Of The World  -  true
0  -  The Quick Brown Fox Jumped Over The Lazy Dog  -  true
0  -  Violet Hill  -  false

With global flag RegExp will not find the in The Quick Brown Fox 
Jumped Over The Lazy Dog because it looks for the from the character 
41 onwards, namely Dog, which has no the.



Kenneth Kawamoto
http://www.materiaprima.co.uk/

Merrill, Jason wrote:

OK, I'm like 95% there, but there is still some kind of bug - here is
how to reproduce:

var testXML:XML = data
 topics
   topic title=Coldplay's New Album, Viva La Vida Or Death And All His
Friends /
   topic title=The Dark Knight /
   topic title=Arrested Development, The Movie /
   topic title=Band Of Horses: Everything All The Time /
   topic title=Master And Commander: The Far Side Of The World /
   topic title=The Quick Brown Fox Jumped Over The Lazy Dog /
   topic title=Violet Hill /
  /topics
 /data;

var re:RegExp = new RegExp(The, g,i);

var xmlListSearch:XMLList = testXML..*.topic.( re[test](
attribute(title)));

trace(result: +xmlListSearch.toString());


If you search for the word, the, as I do when I construct the regular
expression, you should get 5 nodes returned into the XMLList, but I only
get these four:

topic title=The Dark Knight/
topic title=Arrested Development, The Movie/
topic title=Band Of Horses: Everything All The Time/
topic title=Master And Commander: The Far Side Of The World/

I don't get this node:

 topic title=The Quick Brown Fox Jumped Over The Lazy Dog /

? Any idea why?  Does it fail if there is more than one the in the
string?


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] E4X filtering strange behaviour

2008-07-21 Thread Kenneth Kawamoto

I just run a quick and dirty test, and I think I can confirm that.

The following test for 10,000 times each:

testXML..*.( re[test](attribute(title)));
testXML..topic.( re[test](attribute(title)));
testXML.topics.topic.( re[test](attribute(title)));
testXML.topics.topic.( re[test](@title));
testXML.topics.topic.((re as RegExp).test(@title));

The result:

1114ms
1047ms
993ms
868ms
1087ms

So the wildcard * is indeed slower, which is logical. But also 
attribute() is slower than @, moreover (re as RegExp).test() is 
slower than re[test]() - well they are all logical too, you may say :)


Kenneth Kawamoto
http://www.materiaprima.co.uk/

Merrill, Jason wrote:

OK good to know, thanks!

Jason Merrill 
Bank of America 
Enterprise Technology  Global Risk LLD 
Instructional Technology  Media


Join the Bank of America Flash Platform Developer Community 


Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe. 

 


-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf 
Of Kenneth Kawamoto

Sent: Monday, July 21, 2008 12:52 PM
To: Flash Coders List
Subject: Re: [Flashcoders] E4X filtering strange behaviour

Yes that's that :)

Anyway in your case you know the incoming XML schema so you 
shouldn't use wildcard * - I think wildcards have serious 
performance hits.


i.e. theXML.topics.topic. should be used rather than theXML..*.

Kenneth Kawamoto
http://www.materiaprima.co.uk/

Merrill, Jason wrote:
Ah, I know where the confusion came from, you said the code 
was based 

on my example, but that was actually Wagner's example, where he put

var test:XML = data...etc.

(it was based on my example, but he used test as an 
instance of the 
XML when requoting my original question) The use of test 
as the XML 
name threw me, because it was mixed in with the regex 

method, re.test
- I never realized you meant test as the XML not test as 
some regex 

method I wasn't aware of.  So when you wrote


var xmlListSearch:XMLList =
test..*.(re[test](attribute(*)) || re[test](child(*)));

You meant

var xmlListSearch:XMLList =  
theXML..*.(re[test](attribute(*)) || 

re[test](child(*)));

Got it, I'll give it a shot, thanks.

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] E4X filtering strange behaviour

2008-07-21 Thread Keith

Thanks for showing these results.
I'm not missing the attribute method that much...and after this I 
don't feel any guilt for it. :)


-- Keith H --
http://keith-hair.com





Kenneth Kawamoto wrote:

I just run a quick and dirty test, and I think I can confirm that.

The following test for 10,000 times each:

testXML..*.( re[test](attribute(title)));
testXML..topic.( re[test](attribute(title)));
testXML.topics.topic.( re[test](attribute(title)));
testXML.topics.topic.( re[test](@title));
testXML.topics.topic.((re as RegExp).test(@title));

The result:

1114ms
1047ms
993ms
868ms
1087ms

So the wildcard * is indeed slower, which is logical. But also 
attribute() is slower than @, moreover (re as RegExp).test() is 
slower than re[test]() - well they are all logical too, you may 
say :)


Kenneth Kawamoto
http://www.materiaprima.co.uk/


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] E4X filtering strange behaviour

2008-07-21 Thread Merrill, Jason
I was told on Flexcoders that using @string instead of
attribute(string) can be problematic because an error will result if
the attribute is missing in the node of the XML.  Using attribute()
won't throw any errors if the attribute is missing in the XML node, and
in most cases (depending on what you're doing) is prefereable to @. 

Jason Merrill 
Bank of America 
Enterprise Technology  Global Risk LLD 
Instructional Technology  Media

Join the Bank of America Flash Platform Developer Community 

Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe. 

 

-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf Of Keith
Sent: Monday, July 21, 2008 8:19 PM
To: Flash Coders List
Subject: Re: [Flashcoders] E4X filtering strange behaviour

Thanks for showing these results.
I'm not missing the attribute method that much...and after 
this I don't feel any guilt for it. :)

-- Keith H --
http://keith-hair.com





Kenneth Kawamoto wrote:
 I just run a quick and dirty test, and I think I can confirm that.

 The following test for 10,000 times each:

 testXML..*.( re[test](attribute(title))); testXML..topic.( 
 re[test](attribute(title))); testXML.topics.topic.( 
 re[test](attribute(title))); testXML.topics.topic.( 
 re[test](@title)); testXML.topics.topic.((re as 
 RegExp).test(@title));

 The result:

 1114ms
 1047ms
 993ms
 868ms
 1087ms

 So the wildcard * is indeed slower, which is logical. But also 
 attribute() is slower than @, moreover (re as 
RegExp).test() is 
 slower than re[test]() - well they are all logical too, you may 
 say :)

 Kenneth Kawamoto
 http://www.materiaprima.co.uk/

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] E4X filtering strange behaviour

2008-07-21 Thread Merrill, Jason
So in the following code, why doesn't it find the node containing The
Dark Knight?  Yet, if I switch out Dark in the RegExp argument for
The, it indeed finds all the nodes that have The in it.  If I again,
switch out the word, Violet, then nothing gets returned.  If I put
Of, then it returns the two nodes that contain Of.  The only logic I
have been able to find is that this only works if MORE THAN  ONE node
contains the search term.  Something to do with XMLList or the
regex.test method.  Ideas? 

var testXML:XML = data
topics
topic title=Coldplay's New Album, Viva La Vida Or
Death And All His Friends /
topic title=The Dark Knight /
topic title=Arrested Development, The Movie /
topic title=Band Of Horses: Everything All The Time
/
topic title=Master And Commander: The Far Side Of The
World /
topic title=The Quick Brown Fox Jumped Over The Lazy
Dog /
topic title=Violet Hill /
/topics
/data;


var re:RegExp = new RegExp(Dark, i);

var xmlListSearch:XMLList = testXML.topics.topic.(
re[test](attribute(title))); 

trace(result: +xmlListSearch.toString());


Jason Merrill 
Bank of America 
Enterprise Technology  Global Risk LLD 
Instructional Technology  Media

Join the Bank of America Flash Platform Developer Community 

Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe. 

 
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] E4X filtering strange behaviour

2008-07-21 Thread Keith

Why not use toXMLString():
trace(result: +xmlListSearch.toXMLString());

When I add more than one node with Dark in the title attribute it 
finds it with toString().

I've always  used toXMLString() so I was unaware of this.

-- Keith H --
http://keith-hair.com






Merrill, Jason wrote:

So in the following code, why doesn't it find the node containing The
Dark Knight?  Yet, if I switch out Dark in the RegExp argument for
The, it indeed finds all the nodes that have The in it.  If I again,
switch out the word, Violet, then nothing gets returned.  If I put
Of, then it returns the two nodes that contain Of.  The only logic I
have been able to find is that this only works if MORE THAN  ONE node
contains the search term.  Something to do with XMLList or the
regex.test method.  Ideas? 


var testXML:XML = data
topics
topic title=Coldplay's New Album, Viva La Vida Or
Death And All His Friends /
topic title=The Dark Knight /
topic title=Arrested Development, The Movie /
topic title=Band Of Horses: Everything All The Time
/
topic title=Master And Commander: The Far Side Of The
World /
topic title=The Quick Brown Fox Jumped Over The Lazy
Dog /
topic title=Violet Hill /
/topics
/data;


var re:RegExp = new RegExp(Dark, i);

var xmlListSearch:XMLList = testXML.topics.topic.(
re[test](attribute(title))); 


trace(result: +xmlListSearch.toString());


Jason Merrill 
Bank of America 
Enterprise Technology  Global Risk LLD 
Instructional Technology  Media


Join the Bank of America Flash Platform Developer Community 


Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe. 

 
___

Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

  


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] E4X filtering strange behaviour

2008-07-19 Thread Kenneth Kawamoto
The code was based on your example and therefore we know the XML schema, 
i.e. we know the node name and they all have the attribute title.


If we don't know anything about the XML we could do something like:

var xmlListSearch:XMLList = test..*.(re[test](attribute(*)) || 
re[test](child(*)));


Kenneth Kawamoto
http://www.materiaprima.co.uk/

Merrill, Jason wrote:

Thanks.  However, I have been told using @title is not good in most
situations because it will return an error if a node doesn't have the
attribute, wheras attribute(title) will not.


Also this is shorter:
var xmlListSearch:XMLList = test..topic.(re.test(@title));


But you still need to specify what XML to search through, no?  How would
the above know what XML object topic is within using the code above?

Jason Merrill 


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] E4X filtering strange behaviour

2008-07-18 Thread Kenneth Kawamoto
I get the correct node (although I also get Warning 3594). If you are 
tracing, you must do trace(xmlListSearch.toXMLString());


Also this is shorter:
var xmlListSearch:XMLList = test..topic.(re.test(@title));

Kenneth Kawamoto
http://www.materiaprima.co.uk/

Wagner Amaral wrote:

I was doing some tests here using code from Jason Merril (see previous
thread today), and something has brought my attention.
Here's the xml:

var test:XML = data
   topics
   topic title=Coldplays New Album /
   topic title=The Dark Knight /
   topic title=Arrested Development: The Movie /
   /topics
/data;

I tried two cases:
var re:RegExp = new RegExp(^Cold);
var xmlListSearch:XMLList = test..*.topic.(
re.test(attribute('title').toString()) );

and:
var re:RegExp = new RegExp(^Cold);
var xmlListSearch:XMLList = test..*.topic.(
!re.test(attribute('title').toString()) );
// this one just negates the RegExp.test() inside topic.() so I should get
the nodes NOT matching

Well, when I run the first case, I get an empty XMLList, so I was thinking
well, that doesn't work.
However, when I run the second test, I get the XMLList with all elements
EXCEPT the one filtered out, so it actually works!
But what is going on that when the regexp returns true, my XMLList is empty?
This seems a bit strange.


Note: after writing all this, I tried something else:

// this does not work
var xmlListSearch:XMLList = test..*.topic.( attribute('title').toString() ==
The Dark Knight );

// this DO work
var xmlListSearch:XMLList = test..*.topic.( attribute('title').toString() !=
The Dark Knight );

Now, THAT's bizarre!

(BTW, I'm quite new to this E4X thing, I'm more of a XPath guy, so bear with
me if I did something completely wrong ;)


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] E4X filtering strange behaviour

2008-07-18 Thread Merrill, Jason
Thanks.  However, I have been told using @title is not good in most
situations because it will return an error if a node doesn't have the
attribute, wheras attribute(title) will not.

Also this is shorter:
var xmlListSearch:XMLList = test..topic.(re.test(@title));

But you still need to specify what XML to search through, no?  How would
the above know what XML object topic is within using the code above?

Jason Merrill 
Bank of America 
Enterprise Technology  Global Risk LLD 
Instructional Technology  Media

Join the Bank of America Flash Platform Developer Community 

Are you a Bank of America associate interested in innovative learning
ideas and technologies?
Check out our internal  GTO Innovative Learning Blog  subscribe. 

 
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders