• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Prolog declaration for a document

 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I always thought that every XML document "must" begin with the prolog declaration
<? xml version="1.0" ?>
The spec seems to say this is not a requirement. :roll:
Is this a validity constraint?
Just wanted to check if I really read it somewhere or should I just say my Mind is becoming Beautiful...
- madhav
 
John Wetherbie
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, this was just discussed in this thread. I'll have to take a closer look at the spec.
 
John Wetherbie
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Based on the BNF (or EBNF, whichever) from the spec:
prolog ::= XMLDecl? Misc* (doctypedecl Misc*)?
this seems to follow the discussion in the other thread. If you do include the xml declaration it must be the first thing in the doc.
 
Syed AliRaza Zaidi
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are write code will XML document can be still used with out prolog and epilog but what xml parser doesis a sipleprocess of default concatenation of this prolog declarative and the way u wrote declarative is not corect i think bcz any white space is not allowed between <? and xml first five characters are verification signal to parser.
If I am wong do correct me.
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just a note of caution -
The xml declaration, if present should be the first non-blank line in the XML document. Although it is not recommended, one can completely omit the xml declaration. Even today, some parsers don't check for the presence of xml declaration. For instance, try opening a sample XML document without the declaration using IE.
The XML declaration element is in fact, not a necessary requirement for a well formed document. IMO, W3C should fix this !
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
white space is not allowed between <? and xml first
Yup, it must not have the white space.
Thanks everyone.
- madhav
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic