Forums Register Login

Question about elementFormDefault

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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. ;-)
You've gotta fight it! Don't give in! Read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 999 times.
Similar Threads
namespace doubt
How to use elementFormDefault and attributeFormDefault?
Doubt in xsd
SOAP message namespace doubt?
Unmarshall Generated xml.
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 06:45:22.