Re: [Flashcoders] E4X question: finding parent

2011-05-05 Thread Matt Folkard

would help if I answer the question:

childnode.parent().@group

*__

**Plastic Martians Ltd.*
email: m...@plasticmartians.co.uk
web:www.plasticmartians.co.uk
mobile: 07763 986 485
phone: 01434 382 973

On 05/05/2011 16:42, Matt Folkard wrote:

parent() should do it, as in:

childnode.parent()

Cheers

matt

*__

**Plastic Martians Ltd.*
email: m...@plasticmartians.co.uk
web:www.plasticmartians.co.uk
mobile: 07763 986 485
phone: 01434 382 973

On 05/05/2011 16:32, Mendelsohn, Michael wrote:

Hi list...

I'm trying to find some xml's parent attribute.

I havepet name=Sugar/  and I want to find B.

var pets:XML =pets group=A
pet name=Rover/
pet name=Buffy/
/pets
pets group=B
pet name=Spot/
pet name=Sugar/
/pets;

I can't seem to find it.  Anyone know how?

Thanks,
- Michael M.

___
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 question: finding parent

2011-05-05 Thread Matt Folkard

parent() should do it, as in:

childnode.parent()

Cheers

matt

*__

**Plastic Martians Ltd.*
email: m...@plasticmartians.co.uk
web:www.plasticmartians.co.uk
mobile: 07763 986 485
phone: 01434 382 973

On 05/05/2011 16:32, Mendelsohn, Michael wrote:

Hi list...

I'm trying to find some xml's parent attribute.

I havepet name=Sugar/  and I want to find B.

var pets:XML =pets group=A
pet name=Rover/
pet name=Buffy/
/pets
pets group=B
pet name=Spot/
pet name=Sugar/
/pets;

I can't seem to find it.  Anyone know how?

Thanks,
- Michael M.

___
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 question: finding parent

2011-05-05 Thread Geografiek
Hi Michael,
how about the following (not tested):
var petsList:XMLList = pets.*;
var sugarDaddy:XMLList = petsList.(pet name == Sugar);
trace(sugarDaddy@group);
HTH
Willem van den Goorbergh

On 5 mei 2011, at 17:32, Mendelsohn, Michael wrote:

 Hi list...
 
 I'm trying to find some xml's parent attribute.
 
 I have pet name=Sugar/ and I want to find B.
 
 var pets:XML = pets group=A
   pet name=Rover/
   pet name=Buffy/
 /pets
 pets group=B
   pet name=Spot/
   pet name=Sugar/
 /pets;
 
 I can't seem to find it.  Anyone know how?
 
 Thanks,
 - Michael M.
 
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
Geografiek is a Dutch, Utrecht-based map and chart design company.
Willem van den Goorbergh can be contacted by telephone: (+31)30-2719512 or cell 
phone: (+31)6-26372378
or by fax: (+31)302719687
snail mail: Hooghiemstraplein 89 3514 AX UTRECHT
Visit our website at: www.geografiek.nl
twitter: @wvdgoorbergh
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=





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


Re: [Flashcoders] E4X question: finding parent

2011-05-05 Thread Nathan Mynarcik
Perhaps

[code]
xml..GroupNodeName
[/code]

 should get the parent node for ya?
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] E4X question: finding parent

2011-05-05 Thread Mendelsohn, Michael
 childnode.parent().@group

Thanks, Matt.  Well, I'm getting stuck on finding the correct node then.

How do I find the node in the xml, given the node I have?

var myPet:XML = pet name=Sugar/

I get errors with a statements like these:
pets..(pet.toXMLString() == myPet.toXMLString());
pets..(* == myPet);

Once I have that, then I can do the parent() method call.

 var pets:XML =pets group=A
  pet name=Rover/
  pet name=Buffy/
 /pets
 pets group=B
  pet name=Spot/
  pet name=Sugar/
 /pets;

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


Re: [Flashcoders] E4X question: finding parent

2011-05-05 Thread Kenneth Kawamoto

var xml:XML = root
pets group=A
pet name=Rover/
pet name=Buffy/
/pets
pets group=B
pet name=Spot/
pet name=Sugar/
/pets
/root;

trace(xml.pets.pet.(@name == Sugar).parent().@group);

// B

Perhaps you don't want to call your XML pets as it's a node name as well.

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

On 05/05/2011 16:32, Mendelsohn, Michael wrote:

Hi list...

I'm trying to find some xml's parent attribute.

I havepet name=Sugar/  and I want to find B.

var pets:XML =pets group=A
pet name=Rover/
pet name=Buffy/
/pets
pets group=B
pet name=Spot/
pet name=Sugar/
/pets;

I can't seem to find it.  Anyone know how?

Thanks,
- Michael M.

___
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 question: finding parent

2011-05-05 Thread Matt Folkard

Errr, my very limited E4X knowledge now deserts me, but try:

pets.pet.(@name ==Sugar).parent().@group

*__

**Plastic Martians Ltd.*
email: m...@plasticmartians.co.uk
web:www.plasticmartians.co.uk
mobile: 07763 986 485
phone: 01434 382 973

On 05/05/2011 16:50, Mendelsohn, Michael wrote:

childnode.parent().@group

Thanks, Matt.  Well, I'm getting stuck on finding the correct node then.

How do I find the node in the xml, given the node I have?

var myPet:XML =pet name=Sugar/

I get errors with a statements like these:
pets..(pet.toXMLString() == myPet.toXMLString());
pets..(* == myPet);

Once I have that, then I can do the parent() method call.


var pets:XML =pets group=A
pet name=Rover/
pet name=Buffy/
/pets
pets group=B
pet name=Spot/
pet name=Sugar/
/pets;

___
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 question: finding parent

2011-05-05 Thread Glen Pike

@name - will that cause problems because name is a property of XML nodes?

if it is maybe try attribute(name) instead?

On 05/05/2011 16:53, Kenneth Kawamoto wrote:

var xml:XML = root
pets group=A
pet name=Rover/
pet name=Buffy/
/pets
pets group=B
pet name=Spot/
pet name=Sugar/
/pets
/root;

trace(xml.pets.pet.(@name == Sugar).parent().@group);

// B

Perhaps you don't want to call your XML pets as it's a node name as 
well.


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

On 05/05/2011 16:32, Mendelsohn, Michael wrote:

Hi list...

I'm trying to find some xml's parent attribute.

I havepet name=Sugar/  and I want to find B.

var pets:XML =pets group=A
pet name=Rover/
pet name=Buffy/
/pets
pets group=B
pet name=Spot/
pet name=Sugar/
/pets;

I can't seem to find it.  Anyone know how?

Thanks,
- Michael M.

___
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 question: finding parent

2011-05-05 Thread Mendelsohn, Michael
Thanks everyone.

I don't want to find the pet node by using just @name.  I need to match a 
node in xml.pets, given a full node, like so:
xml.pets.(pet.toXMLString() == myPet.toXMLString());

I can't seem to get part that working.

I think it should be easy to use parent() once I have that bit, right?

- Michael M.



-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com 
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Kenneth Kawamoto
Sent: Thursday, May 05, 2011 11:54 AM
To: flashcoders@chattyfig.figleaf.com
Subject: Re: [Flashcoders] E4X question: finding parent

var xml:XML = root
pets group=A
pet name=Rover/
pet name=Buffy/
/pets
pets group=B
pet name=Spot/
pet name=Sugar/
/pets
/root;

trace(xml.pets.pet.(@name == Sugar).parent().@group);

// B

Perhaps you don't want to call your XML pets as it's a node name as well.

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


Re: [Flashcoders] E4X question: finding parent

2011-05-05 Thread Kenneth Kawamoto
trace(xml.pets.pet.(toXMLString() == 'pet 
name=Sugar/').parent().@group);


// B

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

On 05/05/2011 17:06, Mendelsohn, Michael wrote:

Thanks everyone.

I don't want to find thepet  node by using just @name.  I need to match a 
node in xml.pets, given a full node, like so:
xml.pets.(pet.toXMLString() == myPet.toXMLString());

I can't seem to get part that working.

I think it should be easy to use parent() once I have that bit, right?

- Michael M.



-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com 
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Kenneth Kawamoto
Sent: Thursday, May 05, 2011 11:54 AM
To: flashcoders@chattyfig.figleaf.com
Subject: Re: [Flashcoders] E4X question: finding parent

var xml:XML =root
pets group=A
pet name=Rover/
pet name=Buffy/
/pets
pets group=B
pet name=Spot/
pet name=Sugar/
/pets
/root;

trace(xml.pets.pet.(@name == Sugar).parent().@group);

// B

Perhaps you don't want to call your XML pets as it's a node name as well.




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


Re: [Flashcoders] E4X question: finding parent

2011-05-05 Thread Kenneth Kawamoto

This may be slightly more elegant than using toXMLString():

trace(xml.pets.pet.(contains(pet name=Sugar/)).parent().@group);

// B

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

On 05/05/2011 17:06, Mendelsohn, Michael wrote:

Thanks everyone.

I don't want to find thepet  node by using just @name.  I need to match a 
node in xml.pets, given a full node, like so:
xml.pets.(pet.toXMLString() == myPet.toXMLString());

I can't seem to get part that working.

I think it should be easy to use parent() once I have that bit, right?

- Michael M.



-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com 
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Kenneth Kawamoto
Sent: Thursday, May 05, 2011 11:54 AM
To: flashcoders@chattyfig.figleaf.com
Subject: Re: [Flashcoders] E4X question: finding parent

var xml:XML =root
pets group=A
pet name=Rover/
pet name=Buffy/
/pets
pets group=B
pet name=Spot/
pet name=Sugar/
/pets
/root;

trace(xml.pets.pet.(@name == Sugar).parent().@group);

// B

Perhaps you don't want to call your XML pets as it's a node name as well.

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


RE: [Flashcoders] E4X question: finding parent

2011-05-05 Thread Mendelsohn, Michael
Thanks everyone for your responses.  The real xml was actually more complicated 
than what I posted.  Is it me?  Sometimes it seems that E4X solutions are 
difficult to figure out.

The actual solution in my project is this, where rslt is an XMLList:
rslt = topics..descendants(*).(contains(XML(filter)));
rslt = new XMLList(rslt[0].parent());

I don't know why I had to have a parent() call on a separate line, but when I 
had it on one line, the first line was null.

Sometimes perplexed by E4X,
- Michael M.


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


Re: [Flashcoders] E4X question: counting number of subnodes

2010-08-26 Thread Alexander Farber
Hello fellow flashcoders,

I'm still struggling with my e4x problem. With Kenneth's
help I've got it partly working for the cases
where each game has at least 1 user node:

  var games:XML =
   games

 game
   user/
   user/
   user/
 /game

 game
   user/
   user/
 /game

 game
   user/
   user/
 /game

   /games;

  trace(All games:  + games.game.length());
  trace(Full games:  + games.game.user.(length() == 3).length());
  trace(Vacant games:  + games.game.user.(length()  3).length());

This works well. But once I have a game with no user's,
i.e. game/game or just game/ it fails with runtime error:

  ReferenceError: Error #1065: Variable user is not defined.

I know, that when using e4x you're first supposed to test
for a game.user.length()!=0 before referencing a user node.

But how do you do it in this case, when I'm trying to count total numbers?

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


Re: [Flashcoders] E4X question: counting number of subnodes

2010-08-26 Thread Kenneth Kawamoto
You can use elements() (and attributes()) to avoid getting the 
error, i.e.


trace(Full games:  + games.game.(elements(user).length() == 
3).length());


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

On 26/08/2010 11:00, Alexander Farber wrote:

Hello fellow flashcoders,

I'm still struggling with my e4x problem. With Kenneth's
help I've got it partly working for the cases
where each game has at least 1 user node:

   var games:XML =
games

  game
user/
user/
user/
  /game

  game
user/
user/
  /game

  game
user/
user/
  /game

/games;

   trace(All games:  + games.game.length());
   trace(Full games:  + games.game.user.(length() == 3).length());
   trace(Vacant games:  + games.game.user.(length()  3).length());

This works well. But once I have a game with no user's,
i.e.game/game  or justgame/  it fails with runtime error:

   ReferenceError: Error #1065: Variable user is not defined.

I know, that when using e4x you're first supposed to test
for a game.user.length()!=0 before referencing a user node.

But how do you do it in this case, when I'm trying to count total numbers?

Thank you
Alex

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


Re: [Flashcoders] E4X question: counting number of subnodes

2010-08-26 Thread Kenneth Kawamoto
I meant attribute() - attribute() and attributes() are quite different 
things ;)


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

On 26/08/2010 11:41, Kenneth Kawamoto wrote:

You can use elements() (and attributes()) to avoid getting the
error, i.e.

trace(Full games:  + games.game.(elements(user).length() ==
3).length());

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

On 26/08/2010 11:00, Alexander Farber wrote:

Hello fellow flashcoders,

I'm still struggling with my e4x problem. With Kenneth's
help I've got it partly working for the cases
where each game has at least 1 user node:

var games:XML =
games

game
user/
user/
user/
/game

game
user/
user/
/game

game
user/
user/
/game

/games;

trace(All games:  + games.game.length());
trace(Full games:  + games.game.user.(length() == 3).length());
trace(Vacant games:  + games.game.user.(length() 3).length());

This works well. But once I have a game with no user's,
i.e.game/game or justgame/ it fails with runtime error:

ReferenceError: Error #1065: Variable user is not defined.

I know, that when using e4x you're first supposed to test
for a game.user.length()!=0 before referencing a user node.

But how do you do it in this case, when I'm trying to count total
numbers?

Thank you
Alex

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


Re: [Flashcoders] E4X question: counting number of subnodes

2010-08-26 Thread Alexander Farber
Thank you for the pointers, I'll read up on child() and
attribute() - I've missed them in the docs somehow
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] E4X question: counting number of subnodes

2010-08-23 Thread Alexander Farber
Hello Kenneth and others,

On Thu, Aug 19, 2010 at 9:05 PM, Kenneth Kawamoto
kennethkawam...@gmail.com wrote:
 trace(Full games:  + games.game.(user.length() == 3).length());
 trace(Vacant games:  + games.game.(user.length()  3).length());

thank you - now my Flash code is working,
but my Flex code is still not working and
I've already spent several days on it. Here is
the test case (a copy and screenshot are at
http://stackoverflow.com/questions/3517298/flex-listening-for-collectionevent-in-custom-component
)

Games.mxml (my component, trying to use e4x):

?xml version=1.0 encoding=utf-8?
mx:VBox xmlns:mx=http://www.adobe.com/2006/mxml; xmlns:my=*

mx:Script
![CDATA[
private var _xlist:XMLList;

public function get xlist():XMLList {
return _xlist;
}

public function set xlist(x:XMLList):void {
_xlist = x;
trace(111:  + _xlist.toString());
trace(222:  + _xlist.game.toString());
list.dataProvider = x;
all.text = All games:  + _xlist.game.length();
full.text = Full games:  + 
_xlist.game.(user.length() == 3).length();
vacant.text = Vacant games:  + 
_xlist.game.(user.length()  3).length();
}

private function gameLabel(item:Object):String {
return game:  + it...@label;
}
]]
/mx:Script

mx:Label id=all text=All games/
mx:Label id=full text=Full games/
mx:Label id=vacant text=Vacant games/

mx:List id=list labelFunction=gameLabel/

/mx:VBox

MyTest.mxml:

?xml version=1.0 encoding=utf-8?
mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; xmlns:my=*
mx:Script
![CDATA[
import mx.events.*;

private function changeXML1():void {
games = games
game label=1
user/
user/
user/
/game
game label=2
user/
user/
/game
game label=3
user/
user/
user/
/game
/games;   

}

private function changeXML2():void {
games = games
game label=A
user/
user/
user/
/game
game label=B
user/
user/
/game
game label=C
/game
/games;   

}
]]
/mx:Script

mx:XML id=games
games
game label=X
user/
user/
/game
game label=Y
user/
user/
/game
/games
/mx:XML

mx:Button label=Change XML 1 click=changeXML1()/
mx:Button label=Change XML 2 click=changeXML2()/
my:Games xlist={games.game}/
/mx:Application

It prints empty list for the 

Re: [Flashcoders] E4X question: counting number of subnodes

2010-08-19 Thread Glen Pike

Hi,

   I am not sure you can count the sub-nodes without having some sort 
of differentiator between parent nodes.
  
   You might have to loop through the list of games to find how many 
users are in each one as your tests for 2  3 are returning the total 
number of user nodes in the tree.


   You can test your e4x stuff quite nicely here:

   http://www.linkwerk.com/pub/javascript/e4x/e4x-tester/

   Glen

Alexander Farber wrote:

Hello,

my server delivers XML data over socket,
representing games, with up to 3 players in each.

In my custom component I'd like to display
a summary: total number of games,
number of full games (3 players)
number of vacant games (joinable, because less than 3 players).

I've prepared a reduced test case demonstrating my problem:

var games:XML =
  games
game
  user/
  user/
  user/
/game
game
  user/
  user/
/game
game
  user/
  user/
/game
  /games;

trace(All games:  + games.game.length());
trace(Full games:  + games.game.user.(length() == 3).length());
trace(Vacant games:  + games.game.user.(length()  3).length());

It prints wrong results for the 2 last calculations:

All games: 3
Full games: 0
Vacant games: 7

And a warning:

Warning: 1060: Migration issue: The method length is no longer
supported.  Use the length property of the argument instead..

Please advise me
Alex
___
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 question: counting number of subnodes

2010-08-19 Thread Nathan Mynarcik
Yeah you should add attributes to your game nodes to seperate them:

var games:XML =
 games
   game id=1
 user/
 user/
 user/
   /game
   game id=2
 user/
 user/
   /game
   game id=3
 user/
 user/
   /game
 /games;

then you can use E4X to find the actually amount of users in each game:

**Pseudo Code**
games.game(@id == 1).user.length();

Nathan Mynarcik
nat...@mynarcik.com
254.749.2525
www.mynarcik.com


On Thu, Aug 19, 2010 at 1:18 PM, Glen Pike postmas...@glenpike.co.ukwrote:

 Hi,

   I am not sure you can count the sub-nodes without having some sort of
 differentiator between parent nodes.
 You might have to loop through the list of games to find how many users
 are in each one as your tests for 2  3 are returning the total number of
 user nodes in the tree.

   You can test your e4x stuff quite nicely here:

   http://www.linkwerk.com/pub/javascript/e4x/e4x-tester/

   Glen


 Alexander Farber wrote:

 Hello,

 my server delivers XML data over socket,
 representing games, with up to 3 players in each.

 In my custom component I'd like to display
 a summary: total number of games,
 number of full games (3 players)
 number of vacant games (joinable, because less than 3 players).

 I've prepared a reduced test case demonstrating my problem:

 var games:XML =
  games
game
  user/
  user/
  user/
/game
game
  user/
  user/
/game
game
  user/
  user/
/game
  /games;

 trace(All games:  + games.game.length());
 trace(Full games:  + games.game.user.(length() == 3).length());
 trace(Vacant games:  + games.game.user.(length()  3).length());

 It prints wrong results for the 2 last calculations:

 All games: 3
 Full games: 0
 Vacant games: 7

 And a warning:

 Warning: 1060: Migration issue: The method length is no longer
 supported.  Use the length property of the argument instead..

 Please advise me
 Alex
 ___
 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 question: counting number of subnodes

2010-08-19 Thread Kenneth Kawamoto

May be this is what you after?

trace(Full games:  + games.game.(user.length() == 3).length());
trace(Vacant games:  + games.game.(user.length()  3).length());

// Trace
Full games: 1
Vacant games: 2

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

Alexander Farber wrote:

Hello,

my server delivers XML data over socket,
representing games, with up to 3 players in each.

In my custom component I'd like to display
a summary: total number of games,
number of full games (3 players)
number of vacant games (joinable, because less than 3 players).

I've prepared a reduced test case demonstrating my problem:

var games:XML =
  games
game
  user/
  user/
  user/
/game
game
  user/
  user/
/game
game
  user/
  user/
/game
  /games;

trace(All games:  + games.game.length());
trace(Full games:  + games.game.user.(length() == 3).length());
trace(Vacant games:  + games.game.user.(length()  3).length());

It prints wrong results for the 2 last calculations:

All games: 3
Full games: 0
Vacant games: 7

And a warning:

Warning: 1060: Migration issue: The method length is no longer
supported.  Use the length property of the argument instead..

Please advise me
Alex

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


Re: [Flashcoders] E4X question

2010-02-03 Thread Jer Brand
Give this a try -- worked for me : )


var x:XML = new XML(allp id='1'sdog/s/pp
id='2'scat/s/pp id='3'sbird/s/pp
id='4'sdog/s/pp//all) ;
var animal:String = dog ;
var list:XMLList = x.p.(child('s').text()[0] == animal) ;
trace(list.toXMLString())

// traces...

p id=1
  sdog/s
/p
p id=4
  sdog/s
/p

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


RE: [Flashcoders] E4X question

2010-02-03 Thread Merrill, Jason
Is there a reason to have s as a child node instead of an attribute?
Sorting would be a lot easier if s was an attribute of p instead of
a child node.  For example:

var myXML:XML = new XML(all
p s=dog /
p s=cat /
p s=bird /
p s=cat /
p s=sheep /
p s=goat /
p s=cat /
/all);

var myXMLList:XMLList = myXML.p.(@s == cat);
trace(myXMLList);

Jason Merrill 

Bank of  America  Global Learning 
Learning  Performance Soluions

Join the Bank of America Flash Platform Community  and visit our
Instructional Technology Design Blog
(note: these are for Bank of America employees only)





-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of
Mendelsohn, Michael
Sent: Wednesday, February 03, 2010 9:47 AM
To: Flash Coders List
Subject: [Flashcoders] E4X question

Hi list...

I can't seem to get the right E4X statement.  I'm trying to get an
XMLList of all the p tags that have an s tag that is a certain string.
I've tried all sorts of combinations, thinking this one would work, but
it doesn't:
// where animal is passed dog
var list:XMLList = XMLList(all..p..(s.toString()==animal).parent());
or even
var list:XMLList = XMLList(all..(s.toString()==animal).parent());

Help! Thanks,
- Michael M.
 
all
p
sdog/s
/p
p
scat/s
/p
p
sbird/s
/p
p
sdog/s
/p
p/
/all

___
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 question

2010-02-03 Thread kennethkawam...@gmail.com
You can condense it a little:

var xmllist:XMLList = xml.p.(child(s) == animal);

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

On 3 February 2010 15:21, Jer Brand thejhe...@gmail.com wrote:
 Give this a try -- worked for me : )


 var x:XML = new XML(allp id='1'sdog/s/pp
 id='2'scat/s/pp id='3'sbird/s/pp
 id='4'sdog/s/pp//all) ;
 var animal:String = dog ;
 var list:XMLList = x.p.(child('s').text()[0] == animal) ;
 trace(list.toXMLString())

 // traces...

 p id=1
  sdog/s
 /p
 p id=4
  sdog/s
 /p

 Jer

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


RE: [Flashcoders] E4X question

2010-02-03 Thread Mendelsohn, Michael
Thanks for the responses...

Jason: You're right...as always!  :-)
Having s as an attribute will make my life easier.  I was trying to do it with 
a tag though, because I was trying to have really clean xml, everything as 
tags, no attributes.  My train of thought is that actually, the p tags are art 
pieces, so I figured if the s were a tag instead of an attribute, I could 
discern more than one artist working on any individual piece.  I wonder what 
your opinion on that would be.

Jer:
Your solution worked! Much appreciated.

Kenneth:
Thanks for streamlining it. You're an E4X genius.

Thanks my friends!!
- MM

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


RE: [Flashcoders] E4X question

2010-02-03 Thread Merrill, Jason
 because I was trying to have really clean xml, everything as tags,
no attributes 

Heh heh, yeah, I think a bunch of child nodes is messier, more
attributes is cleaner (and this leaner) but it's a matter of perspective
I guess. :) 


Jason Merrill 

Bank of  America  Global Learning 
Learning  Performance Soluions

Join the Bank of America Flash Platform Community  and visit our
Instructional Technology Design Blog
(note: these are for Bank of America employees only)






-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of
Mendelsohn, Michael
Sent: Wednesday, February 03, 2010 10:51 AM
To: Flash Coders List
Subject: RE: [Flashcoders] E4X question

Thanks for the responses...

Jason: You're right...as always!  :-)
Having s as an attribute will make my life easier.  I was trying to do
it with a tag though, because I was trying to have really clean xml,
everything as tags, no attributes.  My train of thought is that
actually, the p tags are art pieces, so I figured if the s were a tag
instead of an attribute, I could discern more than one artist working on
any individual piece.  I wonder what your opinion on that would be.

Jer:
Your solution worked! Much appreciated.

Kenneth:
Thanks for streamlining it. You're an E4X genius.

Thanks my friends!!
- MM

___
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 question

2009-05-01 Thread Mendelsohn, Michael
Thanks for all the responses!  I ended up adapting this solution, and I got 
tripped up on the fact that parent() is a method!!  Ugh.

- MM




take the XMLList that you have and run a for each loop on it looking for a
match at the name attribute

for each (var element:XML in FloorPlanData.floor){
   if(eleme...@name == thisLabel){
   return element

   }

}


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


RE: [Flashcoders] E4X question

2009-04-30 Thread Mendelsohn, Michael
Thanks for replying, Cor.  Yes, when the xml is loaded, the Event.COMPLETE 
function gets fired.  That part isn't the problem because I'm already doing 
other things with the XML.  It's just this bit that I can't get an XMLList for.

What really happens is Sprites within a ScrollPane component get a 
MouseEvent.MOUSE_UP event, and these sprites contain a TextField that has a 
string.  
Here's the real function below.  The string gets passed no problem.  I just 
can't get an XMLList built.

Thanks!
- Michael M.

private function onClick(m:MouseEvent):void{
// no problem here
var thisLabel:String = TextField(m.target[getChildAt](1)).text;
// should I build an XMLList containing everything first?
// no problem here either
trace(FloorplanData..floor);
// traces nothing
trace(FloorplanData..*.((hasOwnProperty(name))  
(attribute(name)==thisLabel)));
}

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


Re: [Flashcoders] E4X question

2009-04-30 Thread Gregory Boland
Mike,

take the XMLList that you have and run a for each loop on it looking for a
match at the name attribute

for each (var element:XML in FloorPlanData.floor){
   if(eleme...@name == thisLabel){
   return element

   }

}

or something along those lines

Hope this is what you were asking

greg


On Thu, Apr 30, 2009 at 3:23 PM, Mendelsohn, Michael 
michael.mendels...@fmglobal.com wrote:

 Thanks for replying, Cor.  Yes, when the xml is loaded, the Event.COMPLETE
 function gets fired.  That part isn't the problem because I'm already doing
 other things with the XML.  It's just this bit that I can't get an XMLList
 for.

 What really happens is Sprites within a ScrollPane component get a
 MouseEvent.MOUSE_UP event, and these sprites contain a TextField that has a
 string.
 Here's the real function below.  The string gets passed no problem.  I just
 can't get an XMLList built.

 Thanks!
 - Michael M.

 private function onClick(m:MouseEvent):void{
// no problem here
var thisLabel:String = TextField(m.target[getChildAt](1)).text;
// should I build an XMLList containing everything first?
// no problem here either
trace(FloorplanData..floor);
// traces nothing
trace(FloorplanData..*.((hasOwnProperty(name)) 
 (attribute(name)==thisLabel)));
 }

 ___
 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 question

2009-04-30 Thread Muzak

var floorplan:XML = FloorplanData
floor name=1
 dept name=Administration/
 dept name=Reception/
/floor
floor name=2
 dept name=Human Resources/
 dept name=Finance/
/floor
floor name=3
 dept name=Marketing/
 dept name=Accounting/
/floor
floor name=4
 dept name=Sales/
 dept name=Legal/
/floor
/FloorplanData;

var dep:String = Reception;

trace(floor: , floorplan.floor.dept.(@name == dep).parent().toXMLString());

//output:
floor:  floor name=1
 dept name=Administration/
 dept name=Reception/
/floor

Is that what you're looking for?

regards,
Muzak

- Original Message - 
From: Mendelsohn, Michael michael.mendels...@fmglobal.com

To: Flash Coders List flashcoders@chattyfig.figleaf.com
Sent: Thursday, April 30, 2009 8:43 PM
Subject: [Flashcoders] E4X question



Hi list...

I'm still relatively new with E4X.  I can't get seem to get this function to return the name of the floor that the department is 
on.  I.E., pass a string, traverse the xml, get the parent's name attribute.  In my second attempt, I figured to test for the 
property name first, because the root node doesn't have @name, but still no luck.  This should be easy, right?  It's probably 
obvious.


Thanks,
- Michael M.

private function getFloor(deptName:String):void{
// always errors
var theFilteredList:XMLList = FloorplanData..*.(@name==thisLabel);
// this doesn't work either
var f:XMLList = FloorplanData.*.(hasOwnProperty(name)  
attribute(name)==thisLabel);
}


?xml version=1.0 encoding=utf-8?
FloorplanData
floor name=1
dept name=Administration/
dept name=Reception/
/floor
floor name=2
dept name=Human Resources/
dept name=Finance/
/floor
floor name=3
dept name=Marketing/
dept name=Accounting/
/floor
floor name=4
dept name=Sales/
dept name=Legal/
/floor
/FloorplanData

___
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 question in regards to ill-formed node

2008-07-29 Thread Ian Thomas
trace(foo.descendants(P-E));

(Worth looking at foo.child() and foo.elements() too...)

HTH,
  Ian

On Tue, Jul 29, 2008 at 3:50 PM, eric e. dolecki [EMAIL PROTECTED] wrote:
 I am getting XML from a WSDL and one of the nodes is like so:

 P-E26.95/P-E

 now, how can I address this node?

 trace( foo..P-E );

 won't work, how can I use E4X to reliably get that node's value if the index
 of it (child index) could move around within the parent nodes?

 Eric
 ___
 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 question in regards to ill-formed node

2008-07-29 Thread Kenneth Kawamoto

One way is: trace(foo.descendants(P-E).toXMLString());

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

eric e. dolecki wrote:

I am getting XML from a WSDL and one of the nodes is like so:

P-E26.95/P-E

now, how can I address this node?

trace( foo..P-E );

won't work, how can I use E4X to reliably get that node's value if the index
of it (child index) could move around within the parent nodes?

Eric

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


Re: [Flashcoders] E4X question in regards to ill-formed node

2008-07-29 Thread eric e. dolecki
Many thanks, that works quite nicely.

Eric

On Tue, Jul 29, 2008 at 11:11 AM, Ian Thomas [EMAIL PROTECTED] wrote:

 trace(foo.descendants(P-E));

 (Worth looking at foo.child() and foo.elements() too...)

 HTH,
  Ian

 On Tue, Jul 29, 2008 at 3:50 PM, eric e. dolecki [EMAIL PROTECTED]
 wrote:
  I am getting XML from a WSDL and one of the nodes is like so:
 
  P-E26.95/P-E
 
  now, how can I address this node?
 
  trace( foo..P-E );
 
  won't work, how can I use E4X to reliably get that node's value if the
 index
  of it (child index) could move around within the parent nodes?
 
  Eric
  ___
  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 question in regards to ill-formed node

2008-07-29 Thread Merrill, Jason
Escuse the last post, some of the URL was missing.  Go here:

http://www.laflash.org/node/435

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 eric e. dolecki
Sent: Tuesday, July 29, 2008 10:50 AM
To: Flash Coders List
Subject: [Flashcoders] E4X question in regards to ill-formed node

I am getting XML from a WSDL and one of the nodes is like so:

P-E26.95/P-E

now, how can I address this node?

trace( foo..P-E );

won't work, how can I use E4X to reliably get that node's 
value if the index of it (child index) could move around 
within the parent nodes?

Eric
___
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 question

2008-07-03 Thread Steven Sacks
Just because you CAN do it (as this document is just that, 
documentation), it doesn't mean you SHOULD.


I mean, you CAN put underscores in class names.  You CAN start class 
names with lower case characters.  You can make all your variable names 
ALL CAPS even if they're not constants.  You can put 10 underscores and 
dollar signs alternating _$_$_$_$_$ before every variable name if you 
want to.  You can cast every variable as an Object, or as *.  The 
language supports it, and the documentation says you're able to do it.


So just because XML supports it, and the documentation says it's 
allowed, doesn't mean it's in any way a good practice, or smart, or even 
acceptable.  In fact, it is not.  I'll give you the number one reason why.


Because XML is MEANT to be read by programming languages while still 
being human readable.


Programming languages generally don't like hyphens in the middle of 
attribute names or variable names.  You have to do hacky stuff like 
bracket access to use them.


Hence, you should never use hyphens in XML attributes or node names.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] E4X question

2008-07-03 Thread Alias Cummins
Unfortunately, telling other people to change their entire XML
structure and config doesn't usually win you a lot of friends...
especially on a tight deadline.

Thanks,
Alias

2008/7/2 Steven Sacks [EMAIL PROTECTED]:
 You might want to try following XML standards and best practices by not
 using hyphens in XML node or attribute names.

 The only time I've seen hyphens in XML is when salespeople and other laymen
 end up writing XML schemas.  Why they're ever given authority to do such
 things is beyond me.

 If it was me, I would fight tooth and nail to get those hyphens removed and
 replaced with camel case.  Best practices or die!  ;)
 ___
 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 question

2008-07-03 Thread Alias Cummins
Hi guys,

First, thanks for your help. The problem is now fixed, without having
to change the XML.

Whenever the term best practices comes up in a debate, it usually
becomes a big long complicated discussion. I try to avoid the term, as
it implies one way of doing something is inherently better than
another, which is very rarely true. Instead, I would ask the question
whose best practices are we talking about here? because anyone can
stand up and claim that such and such is best practice, and as it's
subject to opinion, there's never a resolution to the debate.

2008/7/2 Rich Shupe [EMAIL PROTECTED]:
 I don't understand the subtleties here. Just because XHTML was following
 it's own rules doesn't mean it was within best practices to use AS E4X to
 parse it. I'm quite sure it is not considered best practice to work with
 HTML in XML child nodes, without either CDATA or encoded entities, and your
 experience reflected that.

I have to say that it's certainly common practice - whether it's best
is subject to debate. However, it does get projects done on time.


 And, although my opinion is insignificant, I would have done exactly what
 you did. Best practices are just that, guidelines for which we should
 strive. But, since there's no XHTML parser at the ready, you work with what
 you have.



 All of this is beside the point, however. I did not cite your example as a
 criticism. I prefer not to do that. I mentioned it because I was suggesting
 that maybe this recent question was posed because the author couldn't change
 the source, just as you couldn't. And, therefore (best practices or not) the
 author had to work with a hyphenated attribute name.

You are correct - changing the XML was not an option. Hence the post
to flashcoders.

 I think it would be difficult to find a defense for hyphenated attributes,
 but there still may be times when you must work with them.

They are deeply annoying, all right. It was surprisingly hard to find
the answer online, too. Bad Google!

Thanks for all your help,
Alias
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] E4X question

2008-07-03 Thread Juan Pablo Califano
I agree with most of what you've said. I just wanted to point out that using
hyphens is not sub-standard. Avoiding them is a good decision if that's up
to you and you happen to use a language like AS (which lets you reference
previously undefined identifiers and would cause the - to clash with the
substraction operator). Nevertheless, there are many cases out there of
perfectly legal and standard xml files that do use hyphens (crossdomain,xml,
for example).

Cheers
Juan Pablo Califano


2008/7/3, Steven Sacks [EMAIL PROTECTED]:

 Just because you CAN do it (as this document is just that, documentation),
 it doesn't mean you SHOULD.

 I mean, you CAN put underscores in class names.  You CAN start class names
 with lower case characters.  You can make all your variable names ALL CAPS
 even if they're not constants.  You can put 10 underscores and dollar signs
 alternating _$_$_$_$_$ before every variable name if you want to.  You can
 cast every variable as an Object, or as *.  The language supports it, and
 the documentation says you're able to do it.

 So just because XML supports it, and the documentation says it's allowed,
 doesn't mean it's in any way a good practice, or smart, or even acceptable.
  In fact, it is not.  I'll give you the number one reason why.

 Because XML is MEANT to be read by programming languages while still being
 human readable.

 Programming languages generally don't like hyphens in the middle of
 attribute names or variable names.  You have to do hacky stuff like bracket
 access to use them.

 Hence, you should never use hyphens in XML attributes or node names.
 ___
 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 question

2008-07-02 Thread Ian Thomas
Instead of just typing [EMAIL PROTECTED] (which won't work), use
the attribute() method:

node.attribute(some-attribute)

That should do it.

HTH,
   Ian

On Wed, Jul 2, 2008 at 5:35 PM, Alias™ [EMAIL PROTECTED] wrote:
 Hi guys,

 Quick E4X question.

 I have an XML node, with an attribute inside, the name of which
 contains a dash -.

 How can I access the value of this node via e4x inside actionscript?
 FDT doesn't seem to like the concept at all...

 Example:

 someNode some-attribute=attribute data

 I want to get the value of some-attribute.

 Thanks in advance,
 Alias
 ___
 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 question

2008-07-02 Thread Kenneth Kawamoto

var xml:XML = someNode some-attribute=attribute data /;
trace([EMAIL PROTECTED]some-attribute]);
trace(xml[@some-attribute]);
trace(xml.attribute(some-attribute));

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

Alias? wrote:

Hi guys,

Quick E4X question.

I have an XML node, with an attribute inside, the name of which
contains a dash -.

How can I access the value of this node via e4x inside actionscript?
FDT doesn't seem to like the concept at all...

Example:

someNode some-attribute=attribute data

I want to get the value of some-attribute.

Thanks in advance,
Alias

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


Re: [Flashcoders] E4X question

2008-07-02 Thread Steven Sacks
You might want to try following XML standards and best practices by not 
using hyphens in XML node or attribute names.


The only time I've seen hyphens in XML is when salespeople and other 
laymen end up writing XML schemas.  Why they're ever given authority to 
do such things is beyond me.


If it was me, I would fight tooth and nail to get those hyphens removed 
and replaced with camel case.  Best practices or die!  ;)

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


Re: [Flashcoders] E4X question

2008-07-02 Thread Rich Shupe
He may be working with a source he can't change, like your parsing HTML
without using CDATA tags.


On 7/2/08 1:56 PM, Steven Sacks [EMAIL PROTECTED] wrote:

 You might want to try following XML standards and best practices by not
 using hyphens in XML node or attribute names.
 
 The only time I've seen hyphens in XML is when salespeople and other
 laymen end up writing XML schemas.  Why they're ever given authority to
 do such things is beyond me.
 
 If it was me, I would fight tooth and nail to get those hyphens removed
 and replaced with camel case.  Best practices or die!  ;)

Rich
http://www.LearningActionScript3.com


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


Re: [Flashcoders] E4X question

2008-07-02 Thread Steven Sacks
Just because I'm parsing XHTML using the XML parser in Flash doesn't 
mean that the XHTML is not following best practices.  CDATA in XML is a 
best practice, but not in HTML.  I'm using the Flash E4X parser to parse 
HTML, which, while technically possible, has its own set of challenges 
due to XML expecting XML not XHTML.



Rich Shupe wrote:

He may be working with a source he can't change, like your parsing HTML
without using CDATA tags.


On 7/2/08 1:56 PM, Steven Sacks [EMAIL PROTECTED] wrote:


You might want to try following XML standards and best practices by not
using hyphens in XML node or attribute names.

The only time I've seen hyphens in XML is when salespeople and other
laymen end up writing XML schemas.  Why they're ever given authority to
do such things is beyond me.

If it was me, I would fight tooth and nail to get those hyphens removed
and replaced with camel case.  Best practices or die!  ;)


Rich
http://www.LearningActionScript3.com


___
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 question

2008-07-02 Thread Rich Shupe
I don't understand the subtleties here. Just because XHTML was following
it's own rules doesn't mean it was within best practices to use AS E4X to
parse it. I'm quite sure it is not considered best practice to work with
HTML in XML child nodes, without either CDATA or encoded entities, and your
experience reflected that.

And, although my opinion is insignificant, I would have done exactly what
you did. Best practices are just that, guidelines for which we should
strive. But, since there's no XHTML parser at the ready, you work with what
you have.


All of this is beside the point, however. I did not cite your example as a
criticism. I prefer not to do that. I mentioned it because I was suggesting
that maybe this recent question was posed because the author couldn't change
the source, just as you couldn't. And, therefore (best practices or not) the
author had to work with a hyphenated attribute name.

I think it would be difficult to find a defense for hyphenated attributes,
but there still may be times when you must work with them.




On 7/2/08 4:42 PM, Steven Sacks [EMAIL PROTECTED] wrote:

 Just because I'm parsing XHTML using the XML parser in Flash doesn't
 mean that the XHTML is not following best practices.  CDATA in XML is a
 best practice, but not in HTML.  I'm using the Flash E4X parser to parse
 HTML, which, while technically possible, has its own set of challenges
 due to XML expecting XML not XHTML.

Rich
http://www.LearningActionScript3.com


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


Re: [Flashcoders] E4X question

2008-07-02 Thread Steven Sacks
My point is that the source (XHTML) was following best practices for 
XHTML, including using strict mode.


By contrast, the OP's source was XML, but it was not following best 
practices, so Flash had some issues with hyphens, which aren't supposed 
to be there.


I guess I was just saying that it wasn't a fair comparison.  I had 
control over my source (XHTML), it's just that source wasn't exactly 
what E4X was designed for, but it followed the standards that E4X 
expected and the output was exactly what E4X would have output if it was 
XML, I was just having growing pains because of how Flash handled XML in 
AS1.


Hyphens in XML node names and attributes is just bad all around, and I 
refuse to accept that things that are within your power to change are 
unchangeable.


Some people choose the path of least resistance and figure out a way to 
parse the hyphens.  I choose the path of righteousness and figure out a 
way to get rid of the hyphens that shouldn't be there in the first 
place.  ;)



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


Re: [Flashcoders] E4X question

2008-07-02 Thread Rich Shupe
I guess I wasn't clear.

I said the author's question may have been posted, and the other answers may
have been valuable, because the source may NOT have been within the author's
power to change.

On 7/2/08 6:37 PM, Steven Sacks [EMAIL PROTECTED] wrote:

 Hyphens in XML node names and attributes is just bad all around, and I
 refuse to accept that things that are within your power to change are
 unchangeable.
 
 Some people choose the path of least resistance and figure out a way to
 parse the hyphens.  I choose the path of righteousness and figure out a
 way to get rid of the hyphens that shouldn't be there in the first
 place.  ;)

Rich
http://www.LearningActionScript3.com


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


Re: [Flashcoders] E4X question

2008-07-02 Thread Steven Sacks

Fair enough, Rich.  :)
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] E4X question

2008-07-02 Thread Juan Pablo Califano
Even though I personally prefer to avoid hyphens too, they are standard, if
W3C recommendations qualify as standards.

From the w3c xml spec:

# Characters '-' and '.' are allowed as name characters.

http://www.w3.org/TR/REC-xml/#xml-names

Definition: A Name is a token beginning with a letter or one of a few
punctuation characters, and continuing with letters, digits, hyphens,
underscores, colons, or full stops, together known as name characters.]
Names beginning with the string xml, or with any string which would match
(('X'|'x') ('M'|'m') ('L'|'l')), are reserved for standardization in this or
future versions of this specification.

http://www.w3.org/TR/REC-xml/#sec-common-syn
So, in this case, I guess avoiding hyphens is actually the path of least
resistance (probably, a wise approach after all!).

Cheers
Juan Pablo Califano


2008/7/2, Steven Sacks [EMAIL PROTECTED]:

 You might want to try following XML standards and best practices by not
 using hyphens in XML node or attribute names.

 The only time I've seen hyphens in XML is when salespeople and other laymen
 end up writing XML schemas.  Why they're ever given authority to do such
 things is beyond me.

 If it was me, I would fight tooth and nail to get those hyphens removed and
 replaced with camel case.  Best practices or die!  ;)
 ___
 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