specifications - Is a colon a legal first character in an XML tag name? -


according w3c xml recommendation, start tag-names have definition:

stag ::= '<' name (s attribute)* s? '>' 

..where name is:

name ::= namestartchar (namechar)* namestartchar ::= ":" | [a-z] | ... 

..(n.b., states colon can appear first character) suggesting following valid xml document:

<?xml version="1.0" ?><:doc></:doc> 

..but parser try in shows colon formatting error.

also, under appendices b (though depreciated part of document) explicitly states:

characters ':' , '_' allowed name-start characters. 

..and:

<?xml version="1.0" ?><_doc></_doc> 

..is accepted xml parsers i've tried.

so, colon valid first character in tag-name, , parsers i'm using wrong, or reading specification wrong?

yes, @ base xml level, colon (:) allowed name-start character. bnf rules cite specify this.

however, w3c xml recommendation clear colons should not used except namespaces purposes:

note:

the namespaces in xml recommendation [xml names] assigns meaning names containing colon characters. therefore, authors should not use colon in xml names except namespace purposes, xml processors must accept colon name character.

and xml namespace bnf rules tags based on qname, allow colon in name separated between prefix , localpart:

qname          ::= prefixedname | unprefixedname prefixedname   ::= prefix ':' localpart unprefixedname ::= localpart prefix         ::= ncname localpart      ::= ncname ncname         ::= name - (char* ':' char*) /* xml name, minus ":" */ 

one might ask why colon wasn't disallowed in namestartchar beginning. if we're lucky, c. m. sperberg-mcqueen may offer authoritative explanation. however, suspect it's matter of evolving notion of how namespaces expected designed.

the first published working draft in 1996 of w3c xml recommendation had definition of stag did not allow colon:

stag  ::= '<' name (s attribute)* s? '>' name  ::= (letter | '-') (letter | digit | '-' | '.')* 

by 1998, colons allowed in name,

name  ::= (letter | '_' | ':') (namechar)* 

and earlier form of admonition colon use read:

note: colon character within xml names reserved experimentation name spaces. meaning expected standardized @ future point, @ point documents using colon experimental purposes may need updated. (there no guarantee name-space mechanism adopted xml in fact use colon name-space delimiter.) in practice, means authors should not use colon in xml names except part of name-space experiments, xml processors should accept colon name character.

the need anticipated precise form perhaps not yet known when colon first introduced tag names.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -