wood burning stoves 2.0*
The moose likes Product and Other Certifications and the fly likes Valid XML names Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Product and Other Certifications
Bookmark "Valid XML names" Watch "Valid XML names" New topic
Author

Valid XML names

Vasim Patel
Ranch Hand

Joined: Apr 29, 2004
Posts: 87
Following are the rules of valid XML names:

Element names are case sensitive.
Must begin with letter or underscore(_).
After initial character following are allowed
digits
period(.)
hyphen(-)
underscore(_)
colon( - legal but should be used except for namespaces
NO other characters are allowed like #, @, $, %
Element names cannot begin with xml, Xml, XMl, XmL, xML, xMl

1. Are there any other rules? If yes, please let me know.
2. About the last rule, I tried the following element names in XML Spy it allows me. Can I have a tag name that starts with XML or am I missing something.

<Root attr1="val1">
<xml></xml>
<xmlExtension></xmlExtension>
</Root>
Hari Vignesh Padmanaban
Ranch Hand

Joined: Oct 07, 2003
Posts: 578
Originally posted by Vasim Patel:
Following are the rules of valid XML names:


2. About the last rule, I tried the following element names in XML Spy it allows me. Can I have a tag name that starts with XML or am I missing something.

<Root attr1="val1">
<xml></xml>
<xmlExtension></xmlExtension>
</Root>


XML names starting with "XML" in any case combination are reserved by W3C for future standardization. So even though tehre is no rule , it is good practice to not have elemnts starting with xml, as in the future they might be processes differently by the XML processors once w3c comes up with special elemnts strating with "XML"!

here is the quote from w3c.org

"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 any string which would match (('X'|'x') ('M'|'m') ('L'|'l')), are reserved for standardization in this or future versions of this specification. "


W3C link see Section 2.3

HTH
Vasim Patel
Ranch Hand

Joined: Apr 29, 2004
Posts: 87
Thanks Hari. I understand there is no rule for strings starting with xml.
Pls check the mock test link:
(http://www.javaranch.com/xml/XMLexamList.jsp
Core XML (by Mapraputa Is))

I came across a question
10. Which of the following strings are a correct XML name?
a) xmlExtension
b) xslNewElement
c) XMLElement#123
d) myXMLElement123

where b and d are answers.
What do they mean by correct? Do they mean valid?
All the above 4 are valid but 'a' and 'c' do not follow the naming conventions of w3c. what is the correct answer from the exam point of view.
Hari Vignesh Padmanaban
Ranch Hand

Joined: Oct 07, 2003
Posts: 578
Originally posted by Vasim Patel:
Thanks Hari. I understand there is no rule for strings starting with xml.
Pls check the mock test link:
(http://www.javaranch.com/xml/XMLexamList.jsp
Core XML (by Mapraputa Is))

I came across a question
10. Which of the following strings are a correct XML name?
a) xmlExtension
b) xslNewElement
c) XMLElement#123
d) myXMLElement123

where b and d are answers.
What do they mean by correct? Do they mean valid?
All the above 4 are valid but 'a' and 'c' do not follow the naming conventions of w3c. what is the correct answer from the exam point of view.



Since they are reserved by W3C, I will suiggest that they are invalid names So the correct answers from teh exam point of view will still be "b" and "d"

We have to go with W3C here ..the exam is based on ther specification !
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Valid XML names
 
Similar Threads
Regular expression to replace all invalid xml characters
XML Certification Notes
a simple question
Help with choice & group tags
Whiz Labs question error