Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old March 1st, 2007, 06:25 AM
Bardo
Guest
 
Posts: n/a
Default (more!) elementFormDefault confusion

Hi all,

From what I can read, it doesn't look like I'm the only one getting confused
with the elementFormDefault and attributeFormDefault properties of XML
schemas.

I am wanting to get a full understanding of these properties, as I want to
be able to generate XML that conforms to these settings via the
XmlTextWriter.

The two main reference articles I can find are:
http://geekswithblogs.net/dmillard/a.../20/12935.aspx

http://blogs.msdn.com/ebattalio/arch...03/543154.aspx

However, I have a couple of questions regarding this:
1. In Minty Fresh's example, when using "qualified", the namespace
declaration is REMOVED. This is backward to what I would have thought. I
would have thought it is qualified when the xmlns="" is explicitly stated,
and unqualified when it is not preset. Could someone please explain this?

2. Is the Form property inherited from an attribute/element's direct parent,
or from the schema root itself?

3. When generating XML which conforms to these rules, is it simply a matter
of calling the correct overload of WriteStartElement and
WriteStartAttribute?
I.e. Call prefix overload when Form = Qualified, and call overload with no
prefix when Form = Unqualified?

4. Are these Form rules enforced by XML validation such as using the
XmlValidatingReader?

Thanks,

Bardo.


  #2  
Old March 1st, 2007, 07:55 AM
richard.hallgren@gmail.com
Guest
 
Posts: n/a
Default Re: (more!) elementFormDefault confusion

On 1 Mar, 07:12, "Bardo" <b...@nospam.bryn.com.auwrote:
Quote:
Hi all,
>
From what I can read, it doesn't look like I'm the only one getting confused
with the elementFormDefault and attributeFormDefault properties of XML
schemas.
>
I am wanting to get a full understanding of these properties, as I want to
be able to generate XML that conforms to these settings via the
XmlTextWriter.
>
The two main reference articles I can find are:http://geekswithblogs.net/dmillard/a.../20/12935.aspx
>
http://blogs.msdn.com/ebattalio/arch...03/543154.aspx
>
However, I have a couple of questions regarding this:
1. In Minty Fresh's example, when using "qualified", the namespace
declaration is REMOVED. This is backward to what I would have thought. I
would have thought it is qualified when the xmlns="" is explicitly stated,
and unqualified when it is not preset. Could someone please explain this?
>
The thing here isn't that the example uses a default namespace
(xmlns="http://Sample.Error"). That means two things in this example.
First it doesn't use a special namespace prefix (say <ns0:Error
xmlns:ns0="http://Sample.Error"><ns0:ErrorInfo /></ns0:Error>) as most
qualified/unqualified examples does. Secondly it means that all child
nodes are in the deafult namespace (which is the rule for qualified!).
However that would not have been the case if any child nodes would
have had the xmlns="" declared. That would have put them in a empty
namespace and the message would have been unqualified (as in the first
example).
Quote:
2. Is the Form property inherited from an attribute/element's direct parent,
or from the schema root itself?
>
Don't really know this ... One declared the elementFormDefault on the
schema node, this is the default (surprise, surprise). This can
however be overridden by the form attribute on element level. If means
that all the child elements of that element inherit the value declared
on the form attribute on the element node (and not the default) I
don't know.
Quote:
3. When generating XML which conforms to these rules, is it simply a matter
of calling the correct overload of WriteStartElement and
WriteStartAttribute?
I.e. Call prefix overload when Form = Qualified, and call overload with no
prefix when Form = Unqualified?
>
Yes ..? As the qualified/unqualified are just values on the schema
it's fully possible to use code to create a XML instance that don't
validate against the schema. Do I misunderstand your question?
Quote:
4. Are these Form rules enforced by XML validation such as using the
XmlValidatingReader?
>
Yes.
Quote:
Thanks,
>
Bardo.
Hi Bardo, excellent questions. I'll try and answer some of them (see
my comments below the different questions).

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles