Re: [Flashcoders] XMLList question
Jared wrote: My rule of thumb is anything that will be used for display text is in CDATA tags, not attributes Does that rule account for formatted text? You should see how Word does it. It's quite an elegant solution to the issue. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] XMLList question
Yep. If you control the output of the attributes and know for a fact that they won't have special characters, then you can use attributes, for instance id's, sequence fields, file paths, etc. but for anything that is user generated where you don't know whether or not there could be special characters (even if you don't think there would be), it's best to go the CDATA route. And yes, I have learned the hard way, you know where 1 year down the line, all of a sudden the entire application breaks and isn't displaying any data... quite a nightmare. - Taka On Fri, Feb 5, 2010 at 10:33 AM, Jared wrote: > My rule of thumb is anything that will be used for display text is in CDATA > tags, not attributes > > Sent from my iPhone > > > On Feb 4, 2010, at 8:09 AM, Dave Watts wrote: > > I always use CDATA tags for text in nodes where special characters might >>> exist. >>> >> >> I really strongly second this. This has been the cause of more >> problems I've seen than I can count. You never know what kind of >> characters you might be getting from a database query. >> >> Dave Watts, CTO, Fig Leaf Software >> http://www.figleaf.com/ >> http://training.figleaf.com/ >> >> Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on >> GSA Schedule, and provides the highest caliber vendor-authorized >> instruction at our training centers, online, or onsite. >> ___ >> 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] XMLList question
My rule of thumb is anything that will be used for display text is in CDATA tags, not attributes Sent from my iPhone On Feb 4, 2010, at 8:09 AM, Dave Watts wrote: I always use CDATA tags for text in nodes where special characters might exist. I really strongly second this. This has been the cause of more problems I've seen than I can count. You never know what kind of characters you might be getting from a database query. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or onsite. ___ 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] XMLList question
> I always use CDATA tags for text in nodes where special characters might > exist. I really strongly second this. This has been the cause of more problems I've seen than I can count. You never know what kind of characters you might be getting from a database query. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or onsite. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] XMLList question
1+ 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 Steven Sacks Sent: Wednesday, February 03, 2010 8:14 PM To: Flash Coders List Subject: Re: [Flashcoders] XMLList question I always use CDATA tags for text in nodes where special characters might exist. ___ 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] XMLList question
I always use CDATA tags for text in nodes where special characters might exist. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] XMLList question
not directed at you mate - it was a response to tk about someone whose name begins with b, ends in o and sounds a bit like flenno not entirely sure why it ended up in this thread - i think some of the guys have started a new one to discuss it sorry for the confusion best a On Wed, Feb 3, 2010 at 12:39 PM, Alexander Farber < alexander.far...@gmail.com> wrote: > Wrong thread again? I've actually read several AS books :-) > > > On Wed, Feb 3, 2010 at 11:30 AM, allandt bik-elliott > (thefieldcomic.com) wrote: > > i'll usually put output text content in html with a css file in CDATA > tags. > > Anything that describes that content goes into attributes - like jason > says, > > it uses the xml in the most efficient way. > > > > i also will use the sorting abilities of xml and xml list > > (myxml.nodesToSearch.(@attributeToFind == "searchText") is a revelation) > > sort to manipulate the data and instantiate classes to hold that data > > > > "He's working off of a very shallow and glib understanding of things, > thus > > it's a recurring issue where he comes to the list and asks for help > whenever > > he hits a wall." > > /agree but to a point - i think we've all come across situations when we > > were starting off that simply didn't make sense and resources like > > flashcoders are an excellent way of helping us to understand. That said, > the > > 12,000 lines of python code that you may have written several years ago > > doesn't mean that you can 'do' actionscript without bothering to read a > book > > first > > > > a > > > > On Wed, Feb 3, 2010 at 8:06 AM, Alexander Farber < > alexander.far...@gmail.com > >> wrote: > > > >> On Wed, Feb 3, 2010 at 8:07 AM, Cor wrote: > >> > I always use in xml. > >> > Is that a bad habbit? > >> > >> Not good for my app - if the user enters ]]> and then some XML > ___ > 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] XMLList question
Wrong thread again? I've actually read several AS books :-) On Wed, Feb 3, 2010 at 11:30 AM, allandt bik-elliott (thefieldcomic.com) wrote: > i'll usually put output text content in html with a css file in CDATA tags. > Anything that describes that content goes into attributes - like jason says, > it uses the xml in the most efficient way. > > i also will use the sorting abilities of xml and xml list > (myxml.nodesToSearch.(@attributeToFind == "searchText") is a revelation) > sort to manipulate the data and instantiate classes to hold that data > > "He's working off of a very shallow and glib understanding of things, thus > it's a recurring issue where he comes to the list and asks for help whenever > he hits a wall." > /agree but to a point - i think we've all come across situations when we > were starting off that simply didn't make sense and resources like > flashcoders are an excellent way of helping us to understand. That said, the > 12,000 lines of python code that you may have written several years ago > doesn't mean that you can 'do' actionscript without bothering to read a book > first > > a > > On Wed, Feb 3, 2010 at 8:06 AM, Alexander Farber > wrote: > >> On Wed, Feb 3, 2010 at 8:07 AM, Cor wrote: >> > I always use in xml. >> > Is that a bad habbit? >> >> Not good for my app - if the user enters ]]> and then some XML ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] XMLList question
i'll usually put output text content in html with a css file in CDATA tags. Anything that describes that content goes into attributes - like jason says, it uses the xml in the most efficient way. i also will use the sorting abilities of xml and xml list (myxml.nodesToSearch.(@attributeToFind == "searchText") is a revelation) sort to manipulate the data and instantiate classes to hold that data "He's working off of a very shallow and glib understanding of things, thus it's a recurring issue where he comes to the list and asks for help whenever he hits a wall." /agree but to a point - i think we've all come across situations when we were starting off that simply didn't make sense and resources like flashcoders are an excellent way of helping us to understand. That said, the 12,000 lines of python code that you may have written several years ago doesn't mean that you can 'do' actionscript without bothering to read a book first a On Wed, Feb 3, 2010 at 8:06 AM, Alexander Farber wrote: > On Wed, Feb 3, 2010 at 8:07 AM, Cor wrote: > > I always use in xml. > > Is that a bad habbit? > > Not good for my app - if the user enters ]]> and then some XML > ___ > 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] XMLList question
On Wed, Feb 3, 2010 at 8:07 AM, Cor wrote: > I always use in xml. > Is that a bad habbit? Not good for my app - if the user enters ]]> and then some XML ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] XMLList question
I always use in xml. Is that a bad habbit? -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Alexander Farber Sent: woensdag 3 februari 2010 7:23 To: Flash Coders List Subject: Re: [Flashcoders] XMLList question Thank you all! And, On Wed, Feb 3, 2010 at 2:21 AM, Steven Sacks wrote: > As a rule, I only put string values that never contain special characters in > attributes, otherwise you end up with XML validation errors (like putting > ampersands in attributes). > I was actually going to convert & < > " to & < > " wouldn't that work for attributes, have you had bad experience there? I also wonder if russian text (all in UTF8) will keep working ok in my AS3-program which I convert to XML now... Right now I have urlencoded records, separated by semicolons. Regards Alex ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.733 / Virus Database: 271.1.1/2663 - Release Date: 02/02/10 08:35:00 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] XMLList question
Thank you all! And, On Wed, Feb 3, 2010 at 2:21 AM, Steven Sacks wrote: > As a rule, I only put string values that never contain special characters in > attributes, otherwise you end up with XML validation errors (like putting > ampersands in attributes). > I was actually going to convert & < > " to & < > " wouldn't that work for attributes, have you had bad experience there? I also wonder if russian text (all in UTF8) will keep working ok in my AS3-program which I convert to XML now... Right now I have urlencoded records, separated by semicolons. Regards Alex ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] XMLList question
whoops, sorry wrong thread :) On Tue, Feb 2, 2010 at 5:38 PM, Taka Kojima wrote: > I'm siding with Steven on this one. > > Beno seems to be the worst offender, but it's not just him. It's quite > clear that he doesn't understand the fundamentals and basics -- that's his > main problem. > > He's working off of a very shallow and glib understanding of things, thus > it's a recurring issue where he comes to the list and asks for help whenever > he hits a wall. > > Asking for help is not bad, asking for help on questions that you really > should know the answer to and if you don't you should figure it out on your > own, is just lazy. Pick up a book on Actionscript and OOP fundamentals and > then you can start coming to the list to ask for help. > > > On Tue, Feb 2, 2010 at 5:21 PM, Steven Sacks wrote: > >> As a rule, I only put string values that never contain special characters >> in attributes, otherwise you end up with XML validation errors (like putting >> ampersands in attributes). >> >> Also, I generally put parsing code inside the constructor of the VO class >> (well, I call deserialize() because code inside constructors are >> interpreted). >> >> public class ValueObject >> { >>public var foo:String; >>public var bar:String; >> >>public function ValueObject(node:XML) >>{ >>deserialize(node); >>} >>private function deserialize(node:XML):void >>{ >>foo = no...@foo; >>bar = node.bar; >>} >> } >> >> There are exceptions to this rule, but they're rare. >> >> It makes it really easy to share VOs between multiple service classes when >> the parsing logic is contained with the VO instead of each service class >> (assuming that the xml is homogenized). >> >> ___ >> 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] XMLList question
I'm siding with Steven on this one. Beno seems to be the worst offender, but it's not just him. It's quite clear that he doesn't understand the fundamentals and basics -- that's his main problem. He's working off of a very shallow and glib understanding of things, thus it's a recurring issue where he comes to the list and asks for help whenever he hits a wall. Asking for help is not bad, asking for help on questions that you really should know the answer to and if you don't you should figure it out on your own, is just lazy. Pick up a book on Actionscript and OOP fundamentals and then you can start coming to the list to ask for help. On Tue, Feb 2, 2010 at 5:21 PM, Steven Sacks wrote: > As a rule, I only put string values that never contain special characters > in attributes, otherwise you end up with XML validation errors (like putting > ampersands in attributes). > > Also, I generally put parsing code inside the constructor of the VO class > (well, I call deserialize() because code inside constructors are > interpreted). > > public class ValueObject > { >public var foo:String; >public var bar:String; > >public function ValueObject(node:XML) >{ >deserialize(node); >} >private function deserialize(node:XML):void >{ >foo = no...@foo; >bar = node.bar; >} > } > > There are exceptions to this rule, but they're rare. > > It makes it really easy to share VOs between multiple service classes when > the parsing logic is contained with the VO instead of each service class > (assuming that the xml is homogenized). > > ___ > 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] XMLList question
As a rule, I only put string values that never contain special characters in attributes, otherwise you end up with XML validation errors (like putting ampersands in attributes). Also, I generally put parsing code inside the constructor of the VO class (well, I call deserialize() because code inside constructors are interpreted). public class ValueObject { public var foo:String; public var bar:String; public function ValueObject(node:XML) { deserialize(node); } private function deserialize(node:XML):void { foo = no...@foo; bar = node.bar; } } There are exceptions to this rule, but they're rare. It makes it really easy to share VOs between multiple service classes when the parsing logic is contained with the VO instead of each service class (assuming that the xml is homogenized). ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] XMLList question
This is how I would traverse that XML, seems more natural to me to do it this way: Given your XML: var lobby:XML = DE2 Alex 2_1211369175.jpg DE55 Vasja 55_1232308551.jpg ; Then: var _people:Array = []; for each (var infoXML:XML in lobby.info) { var personVO:PersonVO = new PersonVO(); personVO.label = infoXML.name; personVO.userid = infoXML.id; _people.push(personVO); } where PersonVO is a class that acts only as a Value Object (aka DTO - data transfer object), i.e.: package { public class PersonVO { public var name:String; public var userid:int; } } This allows typecasting and avoids generic objects among other things (like using the Vector class in FP10, you can typecast the array of your value objects - nice). See info here on DTOs/VOs: http://en.wikipedia.org/wiki/Value_Objects I would also, if possible, recommend changing your XML to this form instead: var lobby:XML = ; Much more compact that way (6 lines of XML vs. 12), fewer characters, succinct and as the file grows, will result in a much smaller filesize (and IMO, also easier to read). In my opinion, you would only need to break out into child nodes if the data was large enough to warrant it (i.e. a paragraph or long sentence of text), or there were sub hierarchies of the data where it made sense to have child nodes. In all other cases, I default to using attributes. But that's just me. Hope that helps, 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 Alexander Farber Sent: Tuesday, February 02, 2010 5:08 PM To: Flash Coders List Subject: [Flashcoders] XMLList question Hello, I'm parsing following XML: var lobby:XML = DE2 Alex 2_1211369175.jpg DE55 Vasja 55_1232308551.jpg ; var _people:Array = new Array(); setLobby(lobby.info); function setLobby(list:XMLList):void { for each (var info in list) { var item:Object = {label: info.name, userid: info.id}; _people.push(item); } } - but when I look in the debugger at the elements of the _people array, then I see that "label" and "userid" members are of type XMLList and not String. And that is why my string comparisions later in the code do not work. Am I supposed to call toString() explicitly: var item:Object = {label: info.name.toString(), userid: info.id.toString()}; or is there a more natural way? Thank you 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] XMLList question
XMLList implicitly converts to XML resulting in either the only XML object in the list or a runtime error. XML in turn implicitly converts to String. There is little you can do to fix your issue that you have not already done. The toString method does the same thing as the implicit conversions. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] XMLList question
Hello, I'm parsing following XML: var lobby:XML = DE2 Alex 2_1211369175.jpg DE55 Vasja 55_1232308551.jpg ; var _people:Array = new Array(); setLobby(lobby.info); function setLobby(list:XMLList):void { for each (var info in list) { var item:Object = {label: info.name, userid: info.id}; _people.push(item); } } - but when I look in the debugger at the elements of the _people array, then I see that "label" and "userid" members are of type XMLList and not String. And that is why my string comparisions later in the code do not work. Am I supposed to call toString() explicitly: var item:Object = {label: info.name.toString(), userid: info.id.toString()}; or is there a more natural way? Thank you Alex ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders