NameA name describes an element. It is not unique: lots of elements can have the same name. Therefore, a name cannot be used to identify an individual element. Instead, it tells us the kind of element, similar to declaring the class of an object or the type of a variable. There are no predefined element types and (with a single exception explained later) there are no reserved element names . It is up to the user to create and maintain meaning. Flash ContextLexically, XML names are similar to ActionScript names. XML is slightly more permissive. There is a potential for trouble from two characters , the colon (:) and the period (.). These have special meaning in ActionScript but are permitted in XML names. Yet even in XML they imply a sense of namespace hierarchy. The colon is explicitly discouraged (though not forbidden) in the XML protocol. And use of the period seems only to invite disaster. We avoid the use of either one due to their use as namespace delimiters. Of course there is no requirement that an application map XML names directly to ActionScript names. Most applications that tried to do so would come across an obstacle larger than a dot or two. ActionScript names are unique within their scope (you cannot have two variables called "foo" on the same level). XML element names are very frequently identical to the names of their siblings. While ActionScript names serve to identify an individual datum, XML element names do not. SyntaxThe restrictions on names are simple. Names can use any letter in the alphabet. The alphabet does not have to be ASCII, Latin-1, or even 8 bit. XML supports Unicode and allows names in the current alphabet. Our examples, however, will all be within the Latin alphabet. Case matters, but it is your choice. There is no standard practice for use of case in XML. Often element names are all lower case with dashes standing in for spaces: first-name Names can use any digits, but they may not start with a digit: first-name2 XML defines no element names, but it does reserve all names beginning with the three letters "xml" (case insensitive), so xml-test is not a permitted name. Rules
Examples of Names
Bad examples
|