View Full Version : name characters
enumerator
05-30-2005, 02:26 AM
Where's the list of all allowable characters for element & attribute names?
A reference pointed to http://www.w3.org/TR/REC-xml/#CharClasses, but uh... :confused:
singedpiper
05-30-2005, 09:46 PM
the standard list i've always used for all languages is:
(I normally write this as a regex, but I don't know if you know them)
begin with an upper or lowercase letter (some languages allow _)
followed by a mix of the following:
lowercase letters
uppercase letters
numbers
_ (underscore)
- (dash - some languages do not allow this)
spaces, punctuation, accents, and foreign characters are not allowed.
I normally use a short description of what a variable does to name it. that way when I read my code again in a few months i'm not totally lost. single letter variable names like i or j should be reserved for use as counters for loops, as that's what most programmers recognize them as. a good way to have multiple words readable in one name isToWriteThemLikeThis, with the first letter of all words but the first capitalized. other people prefer to write_like_this with underscores for spaces.
also, i capitalize the first character of class names and make constants ALL_CAPS, it makes methods, classes, variables, and constants much easier to identify
enumerator
05-31-2005, 04:39 AM
I'm trying to figure out what all characters are compatible between Windows file names and XML names, because I want to generate an XML file name based on an element name.
I know which characters and device names are disallowed by the system, but not which characters are illegal in XML, exactly...
glenngv
05-31-2005, 06:52 AM
According to my test, XML element name and attribute name can be composed of alphanumeric characters, underscore or hyphen. The first character must be an alphabet and the rest can be a combination of the said characters.
enumerator
05-31-2005, 07:04 AM
This is what the MSXML reference states:
Element NamesAll elements must have names. Element names are case-sensitive and must start with a letter or underscore. An element name can contain letters, digits, hyphens, underscores, and periods.
Note Colons are reserved for use with namespaces. For more information about which Unicode characters are acceptable letters and digits, see Appendix B of the XML specification.
I'm hoping to find a list of those "noted" characters, without having to decipher the W3C nonsense... :)
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.