Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Complex Type creation

 
Sudhanshu Mishra
Ranch Hand
Posts: 236
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I came across a paragraph as per the site
XML SCHEMA:

The elements and attributes declared within the xsd:complexType element are considered local to the complex type. Local elements and attributes can only be used within the context where they're defined. This raises an interesting question about whether local elements/attributes need to be namespace qualified in instance documents. Since local elements and attributes will always contain an ancestor element (typically a global element) qualified by the target namespace, one could argue that it's not necessary.

Now,what does it mean,that i do not have to use namespace prefixes for the child elements and attributes in the XML document?Do the global elements always have to be prefixed with their namespaces in the xml schema?

Please guide me through.
Thanks
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe the article I pointed to you, in your other post http://www.coderanch.com/t/573881/XML/XML-schema#2612230 will help you understand this.
 
g tsuji
Ranch Hand
Posts: 656
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...Since local elements and attributes will always contain an ancestor element (typically a global element) qualified by the target namespace, one could argue that it's not necessary.

That is from some article. "One could argue"... that implies one could argue otherwise as well. So it has to be put it in the context of the complete article. That "argue" should just be trying to help anchoring something to readers' mind to help understanding of an aspect of the design. I wouldn't though "argue" otherwise with them. That wouldn't help.

Now,what does it mean,that i do not have to use namespace prefixes for the child elements and attributes in the XML document?

Now this is your digestion. Of course, it does not mean that. Besides, prefix is only an artefact for the convenience of the author of an instance xml document. Child elements and attributes have all the provisions available in the w3 schema language to be in any namespace imaginable. (It can be prefixed or non-prefixed in case of element having a default namespace; but for attributes, in case they are not in null namespace, must be prefixed.) But it is not easy to digested in one go, so I suggest you should not be too dragged by the leg by those subtleties before understanding other more readily unstandable and needed things first.

Do the global elements always have to be prefixed with their namespaces in the xml schema?

If the target namespace in the xml schema describing those globals (or locals, for that matter, be mindful) is not null and that the author of the instance document happens to not using default namespace for it, sure, it has to be prefixed. In case they are in null namespace, they aren't prefixed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic