Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Doubt in xsd  RSS feed

 
Pradeep Kumar
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,
I am learning XSD and these are my doubts.

1. where is "xmlns:xs="http://www.w3.org/2001/XMLSchema" defined. When we try to validate an XML against a schema where
does it look for the schema.
2. The significance of targetNamespace and elementFormDefault attributes in XSD document.


Can someone please explain me with this.
 
Campbell Ritchie
Marshal
Posts: 55747
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Too difficult a question for us beginners. Moving.
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
1) Try pasting http://www.w3.org/2001/XMLSchema.xsd into your web browser.
That is where the XML "schema of schemas" is defined. However, I assume that for most cases, this schema is built-in to the basic XML processing APIs.
Regretfully, I have not been able to come up with any proof of this.
2.1) targetNamespace
Declaring a target namespace is significant in the way that it determines to which namespace the definitions in a schema belong.
A namespace is like a box with a name on it. In this box you can put things, but in order to find things in a box, you first have to supply the name of the box in which to look, i.e. the namespace, and then what item to look for. Instead of having all things in one big box (in one namespace) namespaces helps you to group things into smaller groups. This also allows you to define items with the same names without name collisions (as long as they belong to different namespaces).
2.2) elementFormDefault
If elementFormDefault="qualified" means that the elements defined in the schema with this declaration must be qualified with a namespace prefix in an instance of the XML schema. A qualified element looks like this: <tns:someElement/>, an unqualified element looks like this <someElement/>
Please refer to these URLs for more information and examples:
http://www.w3.org/TR/xmlschema-0/#UnqualLocals
http://www.w3.org/TR/xmlschema-0/#QualLocals
Best wishes!
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!