Is it OK to use hyphen - in an XML element name?
e.g.
<rank-type>Rank</rank-type>
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As readily stated by Vinko and hacker, the answer is
Yes, dashes are allowed in names, whether for element names or attribute names. However a dash cannot be the first character in the name.
The W3C standard defines names as follows (section 2.3)
Ignoring the various extended ASCII charactes and double-byte characters (which starting with # sign in the syntax definition), a name needs to start with an upper or lower case letter (A-Z), a colon (:) or an underscore. The characters following this start character, if any, i.e. if the name is not a single character, can be any of the valid start characters and/or any of the digits (0-9), the famous dash (-) and the dot (.)
As pointed out in the other responses, where possible, it is advisable to avoid certain characters, even though they may be legal, lest we risk encountering some implementation specific difficulties with various parsers and interop layers.
The W3C itself has implicitly vindicated the use of dashes as these are extensively used in XSL for example.