This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about elementFormDefault

 
Henry Zheng
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
If I set elementFormDefault attribute to "unqualified" in a schema, does it mean that I will not be allowed to add namespace prefixes to local elements belonging to this schema?
But in practice, I found I still can add prefixes to the local elements in the same schema file, however, it is not allowed to add prefix in other xml files which reference this schema.
I got a bit confused with this problem, can anyone shed some light on this?
What is the precise behavior of setting elementFormDefault to "unqualified"?
thanks
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From what i understand elementFormDefault is meant for the instance document, which is the XML document that references the schema.
I dont think it is meant for the schema file itself.
What is the precise behavior of setting elementFormDefault to "unqualified"?

So this means that xml file elements should NOT be namespace qualified which it seems is not the usual convention.
 
Richard Monson-Haefel
author
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is an expert from the book - actually there is a lot more examples and stuff but this should help some:
From pages 52 - 55
3.1.6 Qualified and Unqualified Elements
In Section 2.2.2 you learned that elements can be qualified by a namespace, or
unqualified; that is, that elements in an XML document may or may not require
QName prefixes. Global elements and attributes must always be qualified, which
means that in an XML instance you must prefix them to form a QName. The exception
is when a global element is a member of the default namespace, in which case it
does not have to be qualified with a prefix�all unqualified elements are assumed to
be part of the default namespace. The default namespace does not apply to global
attributes; global attributes must always be prefixed.
While global elements and attributes must always be qualified, local elements may
not need to be qualified. XML schema defines two attributes, elementsForm
Default and attributesFormDefault, that determine whether local elements
in an XML instance need to be qualified with a prefix or not. For example, the
schema for the Address Markup Language can be modified to require namespace
prefixes on all local elements in an XML instance, as in Listing 3�15.

---------
A word of warning: That section actually has some errors which have been fixed in the most recent printing but you may still run into them in earlier printings. Specifically, I misspelled the terms elementFormDefault and attributeFormDefault a couple of times - sorry about that. It should be elementFormDefault and attributeFormDefault. There are only a few errors in the book, but that's probably the worst of them, which I guess is not too bad compared to other books. ;-)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic