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
Henry Zheng<br /> <br />I went numb when I learned to see.
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. ;-)